[Date Index]
[Thread Index]
[Author Index]
Re: I need to find the correlation coefficient
*To*: mathgroup at smc.vnet.net
*Subject*: [mg15170] Re: [mg15134] I need to find the correlation coefficient
*From*: BobHanlon at aol.com
*Date*: Thu, 17 Dec 1998 00:27:48 -0500
*Sender*: owner-wri-mathgroup at wolfram.com
In a message dated 12/16/98 7:27:46 AM, divvy at hol.gr writes:
>...of a set of data based on several statistical models but cant do it
>with mathematica! My points are
>data={{1,16.5},{2,15.3},{3,14.0},{4,12.5},{5,12.3},{6,14}}; Does anybody
>know how one can do such a thing? There seems to be a command
>correlation[xlist,ylist,Scalemethod->method] but i dont know what
>either of the constituents of this command are! What is an xlist? or a
>ylist? And what are the options for method? Any input will be most
>gratefully accepted! Thanks!
>
Needs["Statistics`MultiDescriptiveStatistics`"]
data = {{1, 16.5}, {2, 15.3}, {3, 14.0}, {4, 12.5}, {5, 12.3}, {6, 14}};
?Correlation
Correlation[{x1, ...., xn}, {y1, ...., yn}] gives the linear
correlation coefficient between the x and y variables.
Correlation[xlist, ylist, ScaleMethod -> method] computes
correlation using a measure of scale other than
StandardDeviation (i.e., MeanDeviation, MedianDeviation,
QuartileDeviation).
You need your data structured as [{x1, x2, ..., xn}, {y1, y2, ..., yn}];
however, you have it in the form {{x1, y1}, {x2, y2}, ..., {xn, yn}}.
First, you need to transpose the data.
Transpose[data]
{{1, 2, 3, 4, 5, 6}, {16.5, 15.3, 14., 12.5, 12.3, 14}}
Note also that the input to Correlation is a sequence of lists rather
than a list of lists. Consequently, the outer Head from the Transpose
must be replaced with Sequence.
Correlation[Sequence @@ Transpose[data]]
-0.761857
The correlation is negative; i.e., as x increases, y tends to decrease.
To specify the ScaleMethod
Correlation[Sequence @@ Transpose[data],
ScaleMethod -> #]& /@ {StandardDeviation, MeanDeviation,
MedianDeviation, QuartileDeviation}
{-0.761857, -0.810054, -0.949457, -0.968828}
As expected, the result for StandardDeviation is the same as the
default.
Bob Hanlon
Prev by Date:
**Re: NIntegrate of a Decaying Exponential**
Next by Date:
**Systems Reliability Calculation**
Previous by thread:
**I need to find the correlation coefficient**
Next by thread:
**Re: Listable**
| |