Thanks for your help. How would I extract each of the 3 values in the vector
individually?

Thanks again

On Thu, May 19, 2011 at 10:40 PM, Rolf Turner <rolf.turner@xtra.co.nz>wrote:

> On 20/05/11 13:46, Cheryl Johnson wrote:
>
>> Hello,
>>
>> I am randomly generating values and then using an ANOVA table to find the
>> mean square value. I would like to form a loop that extracts the mean
>> square
>> value from ANOVA in each iteration. Below is an example of what I am
>> doing.
>>
>> a<-rnorm(10)
>> b<-factor(c(1,1,2,2,3,3,4,4,5,5))
>> c<-factor(c(1,2,1,2,1,2,1,2,1,2))
>>
>> mylm<-lm(a~b+c)
>> anova(mylm)
>>
>> Since I would like to use a loop to generate this several times it would
>> be
>> helpful to know how to extract the mean square value from ANOVA.
>>
>
> anova(mylm)[["Mean Sq"]]
>
> strangely enough. :-)
>
> This gives you a *vector* (of length 3 in your setting), the last
> entry of which is the error (or residual) mean square, which is
> probably what you want since you refer the ``mean square value''
> (singular).
>
>    cheers,
>
>        Rolf Turner
>

	[[alternative HTML version deleted]]

