# [R] Correlation ratio

Scot W. McNary smcnary at charm.net
Thu Jun 28 07:55:12 CEST 2007

```Suman,

Try this:

# some data
example(aov)

# the summary table
anova(npk.aov)

# extract sums of squares
SS <- anova(npk.aov)\$"Sum Sq"

SS
#[1] 343.2950000 189.2816667   8.4016667  95.2016667  21.2816667
33.1350000   0.4816667 185.2866667

# eta-squared for factor N
#SS factor N/SS Total
SS[2]/sum(SS)
#[1] 0.2159850

# partial eta-squared for factor N
# SS factor N/(SS Factor N + SS Residuals)
SS[2]/(sum(SS[2],SS[8]))
#[1] 0.5053328

Hope this helps,

Scot

suman Duvvuru wrote:
> Hi Bruce,
> correlation ratio (eta) is different from correlation coefficient (rho).
> While correlation coefficient captures only a linear relationship btw
> variables, correlation ratio captures both linear and non-linear
> relationships.  It is the defined as the ratio of the variance between
> arrays to the total variance.
>
> Thanks,
> Suman
>
>
> On 6/27/07, Bruce Willy <croero at hotmail.com> wrote:
>
>>  hello
>>
>> try cor(x, y = NULL, use = "all.obs",
>>      method = c("pearson", "kendall", "spearman"))
>>
>> in the R console, you can type "?cor" to get some help on a particular
>> function
>> and help.search("correlation") if you do know the keyword
>>
>>
>>> Date: Wed, 27 Jun 2007 18:00:05 -0400
>>> From: duvvuru.suman at gmail.com
>>> To: R-help at stat.math.ethz.ch
>>> Subject: [R] Correlation ratio
>>>
>>> Hi,
>>>
>>> I wanted to know how to compute the correlation ratio (eta) between two
>>> variables using R. Is there any function to compute the correlationratio.
>>>
>>> Any help will be very much appreciated.
>>>
>>> Thanks,
>>> Suman
>>>
>>>

--
Scot McNary
smcnary at charm dot net

```