Jesse,

FYI, I am not a statistician either like you and Ed are. I am just a fan of Karl Pearson, who is credited for his work on Pearson?s family of distributions. So I couldn?t resist replying to this thread.

If you are just looking to find the degree of association between the two variables in your regression analysis routine, below is a code example that calculates the Pearson Product Moment Correlation Coefficient, also called ?Pearson's r?.

Note: I used data form the link you provided.

Code:

public class PearsonProductMoment {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
// input data
double x[] = { 3, 7, 2, 9, 8, 4, 1, 10, 6, 5 };
double y[] = { 11, 1, 19, 5, 17, 3, 15, 9, 15, 8 };
// Testing
System.out.println("PPM CC using definition formula: "
+ definition(x, y));
System.out.println("PPM CC using row score formula: "
+ Row_Score(x, y));
}
/*
* Method 1: This method calculates the Pearson Product Moment Correlation
* Coefficient by using the definition formula
*/
public static double definition(double dataX[], double dataY[]) {
double meanX = 0.0;
double meanY = 0.0;
// Calculate the number of elements
final int N = dataX.length;
for (int i = 0; i < N; i++) {
meanX += dataX[i];
meanY += dataY[i];
}
meanX /= N;
meanY /= N;
double upperZxy = 0.0;
double varX = 0.0, varY = 0.0;
for (int i = 0; i < N; i++) {
double Zxy = (dataX[i] - meanX) * (dataY[i] - meanY);
upperZxy += Zxy;
double varx = dataX[i] - meanX;
varX += varx * varx;
double vary = dataY[i] - meanY;
varY += vary * vary;
}
double r_definition = upperZxy
/ (N * Math.sqrt(varX / N) * Math.sqrt(varY / N));
return r_definition;
}
/*
* Method 2: This method calculates the Pearson Product Moment Correlation
* Coefficient by using the row score formula
*/
public static double Row_Score(double dataX[], double dataY[]) {
final int N = dataX.length;
double sumX = 0.0, sumY = 0.0, sumXY = 0.0, sumXX = 0.0, sumYY = 0.0;
for (int i = 0; i < N; i++) {
sumX += dataX[i];
sumY += dataY[i];
sumYY += dataY[i] * dataY[i];
sumXX += dataX[i] * dataX[i];
sumXY += dataX[i] * dataY[i];
}
double numerator = (N * sumXY - (sumX * sumY));
double denominator = Math.sqrt(N * sumXX - sumX * sumX)
* Math.sqrt(N * sumYY - sumY * sumY);
double r_Row_Score = numerator / denominator;
return r_Row_Score;
}
}

The result from this calculation gives similar result as in the original example shown on the link you gave.

Code:

PPM CC using definition formula: -0.3611811566150104
PPM CC using row score formula: -0.3611811566150105