# Thread: Pearson Critical Values

1. ## Pearson Critical Values

I am working on a project where I need to determine trends in maintenance conducted on large ships. I have man-day totals and the age of the ship when the maintenance was completed. Our hypothesis is that as the ship ages, more maintenance must be done each year to keep the equipment running. We currently track about 300 different pieces of equipment on each ship. So, I have created a table which is age of ship (columns) and equipment (rows). each cell contains the number of mandays it took took to repair that piece of equipment. I can easily calculate the LINEST and CORREL (using excel) for each row. The next question is "Does a linear model make sense for each piece of equipment"? I was using pearsons critical values (sample here: http://www.gifted.uconn.edu/Siegle/r...n/corrchrt.htm). The problem with this is that the available options for the level of significance aren't sufficient for me. Quite honestly, for this type of data, we can easily assume more risk by choosing a .15 or even .20 confidence factor. So my questions are:
1. How can I calculate critical values for other values of p?
2. Does my overall approach make sense? Do you see any glaring (or not-so-glaring-but-still-noteworthy) problems/omissions here?
Ultimately we will use this analysis to help us predict how much to budget for maintenance as the ship gets older. We use a lot of other predictors, but we are always looking for ways to improve our models.

Thanks in advance!

Skip

2. Anyone? Please?

3. Hi!

You can check the following

> http://www.alivelearn.net/?p=709 (Uses matlab)

EDIT : Check this too.

> The distribution of rho… [off of my blog]

4. LONG POST WARNING!

Those links were perfect! Thanks. In fact, the mathworld link on the first page you linked to pretty much gave me all the answers I needed.

http://mathworld.wolfram.com/Correla...tribution.html

I have written some Excel VBA code to calculate the critical value given the number of observations (N) and the desired level of significance (p). I am using the formulas given at line 42 at the link above. The problem is, my code works for even numbers perfectly, but not for odd numbers. Would anyone care to review my code and see if they can see where the err of my ways may lie?

Code:
``````Function Calculate_P_given_R_EVEN(intN As Integer, dblR As Double)

Dim intK As Integer
Dim intI As Integer
Dim theSum As Double
Dim thisValue As Double
Dim intNu As Integer
Const PI = 3.14159265358979

intNu = intN - 2
intI = (intNu - 2) / 2

theSum = 0
For intK = 0 To intI
thisValue = ((-1) ^ intK) * (u_fact(intI) / (u_fact(intI - intK) * u_fact(intK)) * ((Abs(dblR)) ^ (2 * intK + 1))) / (2 * intK + 1)
theSum = theSum + thisValue
Next

Calculate_P_given_R_EVEN = 1 - ((2 / Sqr(PI)) * Gamma((intNu + 1) / 2) / Gamma(intNu / 2)) * theSum
End Function``````

Code:
``````Function Calculate_P_given_R_ODD(intN As Integer, dblR As Double)

Dim intK As Integer
Dim intJ As Integer
Dim theSum As Double
Dim thisValue As Double
Dim intNu As Integer
Const PI = 3.14159265358979

intNu = intN - 2
'intJ = (intNu - 3) / 2
intJ = intN - 1

theSum = 0
For intK = 0 To intJ
thisValue = (doubleFact(2 * intK) / doubleFact(2 * intK + 1)) * ((1 - dblR ^ 2) ^ ((intK + 1) / 2))
theSum = theSum + thisValue
Next

Calculate_P_given_R_ODD = 1 - 2 / PI * ((WorksheetFunction.Asin(Abs(dblR))) + Abs(dblR) * theSum)
End Function``````

Code:
``````Function u_fact(number As Integer)
Dim i As Integer
u_fact = 1
For i = 1 To Int(number)
u_fact = u_fact * i
Next i

End Function``````

Code:
``````Function doubleFact(number As Integer)
Dim i As Integer
If (number = -1 Or number = 0) Then
doubleFact = 1
Else
If (number Mod 2 = 0) Then
doubleFact = 1
For i = number To 2 Step -2
doubleFact = doubleFact * i
Next i
Else
doubleFact = 1
For i = number To 1 Step -2
doubleFact = doubleFact * i
Next i
End If
End If
End Function``````

Here is some sample output:

Code:
``````N	R_obs    	P	Formula
5	0.878	   -0.086983393	=Calculate_P_given_R_ODD(A2,B2)
6	0.811	   0.050205866	=Calculate_P_given_R_EVEN(A3,B3)
7	0.754	   -0.15729136	=Calculate_P_given_R_ODD(A4,B4)
8	0.707	   0.049875332	=Calculate_P_given_R_EVEN(A5,B5)
9	0.666	   -0.198802168	=Calculate_P_given_R_ODD(A6,B6)
10	0.632	   0.049951112	=Calculate_P_given_R_EVEN(A7,B7)
11	0.602	   -0.225244593	=Calculate_P_given_R_ODD(A8,B8)
12	0.576	   0.049991652	=Calculate_P_given_R_EVEN(A9,B9)
13	0.553	   -0.243481684	=Calculate_P_given_R_ODD(A10,B10)
14	0.532	   0.050211396	=Calculate_P_given_R_EVEN(A11,B11``````
Which does agree with the table here
http://www.gifted.uconn.edu/Siegle/r...n/corrchrt.htm
for the even numbers, but obviously not for the odd numbers.

So, does anyone see where my code may be incorrect for the ODD function?

Thanks in advance!

Skip

5. Never mind. I solved it. the power in the summation should have been ^ (intK + 1 / 2)

 Tweet

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts