# [R] Between-group variance from ANOVA

peter dalgaard pdalgd at gmail.com
Thu Jul 26 10:30:02 CEST 2012

```On Jul 25, 2012, at 14:56 , arun wrote:

> Hi,
>
> From the ANOVA results, you could get MSE and MS of group.  MSE is basically sigma^2 error.  MS group of MS between group contains sigma^2 error+replication*sigma^2group (please check the formula.  It can be slightly different when the model complexity increases).
>
>
> Once, you get sigma^2 group, I guess you know how to calculate Vg and Vp.
>
>
> Once, you have all the values, except sigma^2 group, you can subtract and divide it by replication to get sigma^2 group.  In SAS, proc glm also shows the output with formula.
>
> A.K.
>

Beware, though, that this works for balanced designs only (identical group sizes). For unequal replication, you need to go the lme/lmer route.

-pd

>
>
>
> ----- Original Message -----
> From: Ista Zahn <istazahn at gmail.com>
> To: tedtoal <twtoal at ucdavis.edu>
> Cc: r-help at r-project.org
> Sent: Wednesday, July 25, 2012 6:21 AM
> Subject: Re: [R] Between-group variance from ANOVA
>
> There is nothing about R in your question, hence it is not appropriate
> for this list. Please consult with a local statistician, or post on a
> stats help list such as http://stats.stackexchange.com/
>
> On Tue, Jul 24, 2012 at 8:55 PM, tedtoal <twtoal at ucdavis.edu> wrote:
>> I'm trying also to understand how to get the between-group variance out of a
>> one-way ANOVA, but I'm beginning to think that in a sense, the variance does
>> not exist.  Emma said:
>>
>> *The model is response(i,j)= group(i)+ error(i,j)*
>>
>> Yes, if by group(i) you mean intercept + coefficient[i].
>>
>> *we assume that group~N(0,P^2) and error~N(0,sigma^2) *
>>
>> Only the error is assumed to be a random variable.  Group is a fixed effect,
>> not a random variable, and therefore it has no variance associated with it.
>> The model does not predict a variance for it.  One could compute the
>> variance of the coefficients and call this a group variance, but it seems to
>> me that isn't the right way to think about it.
>>
>> I'm trying to calculate a heritability value for a trait in an organism,
>> defined as Vg/Vp, where Vg = variance due to genotype and Vp = total
>> variance.  The model is p~g,  or p[i,j] = intercept + g_coefficient[i] +
>> error[i,j].  But to get Vg, I think it is actually necessary to use a
>> different model, where g is modelled as a random variable (a random effect),
>> so the model can estimate a variance associated with it.
>>
>> ted
>>
>>
>>
>>
>> --
>> View this message in context: http://r.789695.n4.nabble.com/Between-group-variance-from-ANOVA-tp901535p4637686.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> and provide commented, minimal, self-contained, reproducible code.
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help