[R] Between-group variance from ANOVA
Mark Difford
mark_difford at yahoo.co.uk
Tue Aug 25 09:52:26 CEST 2009
Hi Emma,
>> ...from this I can read the within-group variance. can anyone tell me how
>> i may find
>> out the between-group variance?
But it's in the table, above the "within-group" variance. Remember that F is
the ratio of these two quantities, i.e. the mean of the group variances
divided by the mean of the within-group variances . I will work with my
example since you never set seed so your answers are different from mine
(which really does not help matters).
set.seed(7)
TDat <- data.frame(response = c(rnorm(100, 5, 2), rnorm(100, 20, 2)))
TDat$group <- gl(2, 100, labels=c("A","B"))
summary(aov(response ~ group, data=TDat))
11225.25/3.64
[1] 3083.86
There is some rounding error on the mean squares (i.e. mean variances) but F
is correct. Using estimates calculated by a different route we have:
11225.249057/3.639801
[1] 3084.028
Does this answer your question?
Regards, Mark.
emj83 wrote:
>
> I have done this in R and this is the following ANOVA table I get:
>
>> summary(aov(response ~ group, data=TDat))
> Df Sum Sq Mean Sq F value Pr(>F)
> group 1 11203.5 11203.5 2505.0 < 2.2e-16 ***
> Residuals 198 885.5 4.5
>
> The model is response(i,j)= group(i)+ error(i,j),
>
> we assume that group~N(0,P^2) and error~N(0,sigma^2)
>
> I know that sigma^2 is equal to 4.5, how do I find out P^2?
>
> In the problem that I am trying to apply this to, I have more than 2
> groups. I was hoping there would be a function that helps you do this that
> I don't know about.
>
>
> Thanks for your help Emma
>
>
>
>
> Mark Difford wrote:
>>
>> Hi Emma,
>>
>>>>
>>
>> R gives you the tools to work this out.
>>
>> ## Example
>> set.seed(7)
>> TDat <- data.frame(response = c(rnorm(100, 5, 2), rnorm(100, 20, 2)))
>> TDat$group <- gl(2, 100, labels=c("A","B"))
>> with(TDat, boxplot(split(response, group)))
>> summary(aov(response ~ group, data=TDat))
>>
>> Regards, Mark.
>>
>>
>> emj83 wrote:
>>>
>>> can anyone advise me please?
>>>
>>>
>>> emj83 wrote:
>>>>
>>>> I have done some ANOVA tables for some data that I have, from this I
>>>> can read the within-group variance. can anyone tell me how i may find
>>>> out the between-group variance?
>>>>
>>>> Thanks Emma
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Between-group-variance-from-ANOVA-tp24954045p25129942.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list