org.statcato.statistics.inferential
Class CorrelationRegression

java.lang.Object
  extended by org.statcato.statistics.inferential.CorrelationRegression

public class CorrelationRegression
extends java.lang.Object

Linear correlation and regression between for two variables.

Since:
1.0
Version:
%I%, %G%
Author:
Margaret Yau

Constructor Summary
CorrelationRegression(java.util.Vector<java.lang.Double> x, java.util.Vector<java.lang.Double> y, double sig)
          Constructor.
 
Method Summary
 double CoefficientOfDetermination()
          Returns the coefficient of determination r^2, the amount of the variation in y that is explained by the regression line.
 double CriticalValue_r(double significance)
          Returns the critical value for r corresponding to the given significance.
 double CriticalValue_t(double significance)
           
 int DOF()
          Returns the degrees of freedom.
 double ExplainedVariation()
          Returns the explained variation (sum of differences between the predicted y value and the mean).
 double LinearCorrelationCoeff()
          Returns the linear correlation coefficient.
 int N()
          Returns the number of data pairs
 double PValue()
          Returns the p-Value corresponding to the test statistic.
 double RegressionEqSlope()
          Returns the slope of the regression equation b1.
 double RegressionEqYInt()
          Returns the y-intercept of the regression equation b0.
 double StandardError()
           
 double TestStatistic_t()
          Returns the test statistic t using the linear correlation correlation r.
 java.lang.String toString()
           
 double TotalVariation()
          Returns the total variation (sum of differences between the y value and the mean).
 double UnexplainedVariation()
          Returns the unexplained variation (sum of differences between the y value and the predicted y value).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CorrelationRegression

public CorrelationRegression(java.util.Vector<java.lang.Double> x,
                             java.util.Vector<java.lang.Double> y,
                             double sig)
Constructor. The x and y variables are provided as vectors of double type of the same length. The values in the two vectors at the same position are considered to be a data point.

Parameters:
x - independent variable
y - dependent variable
sig - significance
Method Detail

N

public int N()
Returns the number of data pairs

Returns:
n

DOF

public int DOF()
Returns the degrees of freedom.

Returns:
DOF

LinearCorrelationCoeff

public double LinearCorrelationCoeff()
Returns the linear correlation coefficient.

Returns:
r

TestStatistic_t

public double TestStatistic_t()
Returns the test statistic t using the linear correlation correlation r. t = r / sqrt((1 - r^2)/(n - 2)).

Returns:
test statistic t

RegressionEqSlope

public double RegressionEqSlope()
Returns the slope of the regression equation b1.

Returns:
b1 slope

RegressionEqYInt

public double RegressionEqYInt()
Returns the y-intercept of the regression equation b0.

Returns:
b0 y-intercept

TotalVariation

public double TotalVariation()
Returns the total variation (sum of differences between the y value and the mean).

Returns:
total variation

ExplainedVariation

public double ExplainedVariation()
Returns the explained variation (sum of differences between the predicted y value and the mean).

Returns:
explained variation

UnexplainedVariation

public double UnexplainedVariation()
Returns the unexplained variation (sum of differences between the y value and the predicted y value).

Returns:
unexplained variation

CoefficientOfDetermination

public double CoefficientOfDetermination()
Returns the coefficient of determination r^2, the amount of the variation in y that is explained by the regression line.

Returns:
r^2 coefficient of determination

StandardError

public double StandardError()

CriticalValue_r

public double CriticalValue_r(double significance)
Returns the critical value for r corresponding to the given significance.

Parameters:
significance - significance
Returns:
critical value (positive)

CriticalValue_t

public double CriticalValue_t(double significance)

PValue

public double PValue()
Returns the p-Value corresponding to the test statistic.

Returns:
p-Value

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object