Community Member

Joined:

Oct 1, 2011

## Computing Sample Covariance

I have the following matrix: [35 36 40, 38 37 40, 48 41 42, 50 46 54] for which I am trying to compute the sample covariance.  When calculating by hand, the sample covariance matrix should be: [40.6875 23.5 28.0, 23.5 15.5 21.5, 28.0 21.5 34.0] however I am unable to recreate this in JMP.  I found an option for calculating covariance, but it does not return the same result.

Can anyone help point me in the right direction?  I'm extremely new to this software and never used software as an undergraduate.

Thanks!

Anna

Super User

Joined:

Jun 23, 2011

## Re: Computing Sample Covariance

Try the JSL code below (open a script windom and paste and hit run).

sample_Q = Covariance( [35 36 40, 38 37 40, 48 41 42, 50 46 54] );

pop_Q = Covariance( [35 36 40, 38 37 40, 48 41 42, 50 46 54] ) * 3 / 4;

Show( sample_Q, pop_Q );

You should get the results

sample_Q =

[          54,25 31,33 37,33,

31,33 20,66 28,66,

37,33 28,66 45,33];

pop_Q =

[          40,6875 23,5 28,

23,5 15,5 21,5,

28 21,5 34];

The latter equals your calculation. The difference between the two is a factor of 3/4 i.e. (N-1)/1. I think the equation you have used is actually not for the (unbiased) sample covariance but rather the population covariance which would be the right choice if the population mean is known. Try to use N-1 as denominator instead of N and you should end up with the same covariance estimate as JMPs formula.