[R] F test

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Jul 23 11:27:18 CEST 2008


Vicki Meng wrote:
> --- On Tue, 7/22/08, Peter Dalgaard <p.dalgaard at biostat.ku.dk> wrote:
>
> From: Peter Dalgaard <p.dalgaard at biostat.ku.dk>
> Subject: Re: [R] F test
> To: vycshmily at yahoo.com
> Cc: r-help at r-project.org
> Date: Tuesday, July 22, 2008, 11:51 PM
>
> Vicki Meng wrote:
>   
>> Dear R users,
>>  
>> I need to do a F test on the hypothesis that a 2 by 1 vector (X_1,
>>     
> X_2)' has the mean vector  (M_1, M_2)'. Specifically, I would like to
> assume the X vector comes from a bivariate Normal distribution (M, Sigma).
> Then, given 1000 observations on X, I wanted to test if the means of X agree
> with the means of the target Normal distribution. Any function or package in R
> could do such a test? Thanks!
>   
>>   
>>     
> library(MASS) # for multivariate normal RNG
> X <- mvrnorm(1000, Sigma=matrix(c(2,1,1,3),2), mu=c(3,4))
>
> Y <- sweep(X,2,c(3,4))
> m1 <- lm(Y~1)
> m2 <- lm(Y~0)
> anova(m1, m2)
>
> I don't want to push my luck, but could anybody explain the above codes for me a little more?In the above experiment, X are draws obtained from a bivariate normal distribution with the means set to (3,4), but how to read the anova table to see if the means of X are (3,4)?The F-statistic obtained from 'anova(m1,m2)' is 0.73 in one case, and 4.7 in another case. I don't understand how to interpret them.Thank you!Vicki.
>   
The Pr(>F) indicates the p-value for the hypothesis that X has mean 
(3,4) (i.e. that the Y has mean zero) against the alternative of X 
having arbitrary mean. As with all simulated data, it can be significant 
even if draws are made from the true distribution (approx. 5 percent of 
the time if you test at the 0.05 level, etc.).

If you have trouble with the theory of multivariate tests in general, 
then you probably need to pick up a book on the subject, e.g. one of 
those listed on the help pages for anova.mlm and manova.

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list