[R] F test

Emmanuel Charpentier charpent at bacbuc.dyndns.org
Thu Apr 16 23:01:19 CEST 2009


Le jeudi 16 avril 2009 à 13:00 -0500, Jun Shen a écrit :
> Mike,
> 
> I kind of have the same question. What if for a mixed effect model, say
> using lme(), how to specify the interaction effect (between a fixed effect
> and a random effect)? 

With lme, you have to specify a *list* of random effects as the
"random=" argument, which, off the top of my (somewhat tired) limbic
system,  is specified by an "lmList", iirc. But I'm pretty sure that
"?lme" will give you much better information...

lmer is simpler. Say you basic model is "Z~Y" with another variable X
acting as a possible source of random variation. You express random
effects by adding (1|X) terms (meaning X is a simple (intercept) random
effect) to the model, or (Y|X), which specifies both an intercept random
effect of X and an effect of the slope of the (supposed) line binding Y
to the independent variable. If you want to specify a possible variation
of slopes with no possible intercept effect, say "Z~Y+(0+Y|X)" (unless
I'm mistaken : I never used that, because I never had to work on such a
model in a context where it would make sense...).

> and where to find the result of the interaction?

Ah. That's the (multi-)million dollars question. You're dealing with a
fixed*random interaction, which has a totally different meaning of a
fixed*fixed interaction. The test of the latter means "does the
(possible) effect of the first factor vary with levels of the second
factor ?", whereas the second reads as "does the random factor increase
variability about what I know of the effect of the fixed factor ?", with
totally different consequences.

Pinhero and Bates' book (2000), which among other thing, describes the
care, feeding and drinks of lme, give explanations about 1) why the
problem is computationnaly hard 2) how to get an approximate answer and
3) in which proportion previous advice might be misleading. This book
is, IMHO, required reading for anybody with more than a passing interest
on the subject, and I won't paraphrase it...

Since then, Pr Bates started to develop lme4, which has different inner
algorithms. In the cours of this work, he started to have doubts about
the "conventional wisdom" about testing effects in mixed models, and did
not (yet) provide these "conventionals" means of testing. Instead, he
seems to work along the lines of MCMC sampling to assess various aspects
of mixed models. But there I suggest to walk along the R-SIG-mixed-model
archives, which are *very* interesting.

Of course, if you want an authoritative answer (i. e. an answer that
will pass a medical journal's reviewer unquestioned), you can always use
SAS' proc mixed. But I wouldn't swear this answer is "exact", or even
sensible, as far as I can judge...

Pr Bates seems to answer readily any (sensible) questions on the ME
mailing list, where you will also find folks much more authorized than
yours truly to answer this and that question...

HTH,

					Emmanuel Charpentier

> Thanks.
> 
> Jun
> 
> On Thu, Apr 16, 2009 at 12:08 PM, Mike Lawrence <Mike.Lawrence at dal.ca>wrote:
> 
> > summary(my_lm) will give you t-values, anova(my_lm) will give you
> > (equivalent) F-values. summary() might be preferred because it also
> > provides the estimates & SE.
> >
> > > a=data.frame(dv=rnorm(10),iv1=rnorm(10),iv2=rnorm(10))
> > > my_lm=lm(dv~iv1*iv2,a)
> > > summary(my_lm)
> >
> > Call:
> > lm(formula = dv ~ iv1 * iv2, data = a)
> >
> > Residuals:
> >    Min      1Q  Median      3Q     Max
> > -1.8484 -0.2059  0.1627  0.4623  1.0401
> >
> > Coefficients:
> >            Estimate Std. Error t value Pr(>|t|)
> > (Intercept)  -0.4864     0.4007  -1.214    0.270
> > iv1           0.8233     0.5538   1.487    0.188
> > iv2           0.2314     0.3863   0.599    0.571
> > iv1:iv2      -0.4110     0.5713  -0.719    0.499
> >
> > Residual standard error: 1.017 on 6 degrees of freedom
> > Multiple R-squared: 0.3161,     Adjusted R-squared: -0.02592
> > F-statistic: 0.9242 on 3 and 6 DF,  p-value: 0.4842
> >
> > > anova(my_lm)
> > Analysis of Variance Table
> >
> > Response: dv
> >          Df Sum Sq Mean Sq F value Pr(>F)
> > iv1        1 1.9149  1.9149  1.8530 0.2223
> > iv2        1 0.4156  0.4156  0.4021 0.5494
> > iv1:iv2    1 0.5348  0.5348  0.5175 0.4990
> > Residuals  6 6.2004  1.0334
> >
> >
> > On Thu, Apr 16, 2009 at 10:35 AM, kayj <kjaja27 at yahoo.com> wrote:
> > >
> > > Hi,
> > >
> > >
> > > How can I find the p-value for the F test for the interaction terms in a
> > > regression linear model lm ?
> > >
> > > I appreciate your help
> > >
> > >
> > > --
> > > View this message in context:
> > http://www.nabble.com/F-test-tp23078122p23078122.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
> > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
> >
> >
> > --
> > Mike Lawrence
> > Graduate Student
> > Department of Psychology
> > Dalhousie University
> >
> > Looking to arrange a meeting? Check my public calendar:
> > http://tr.im/mikes_public_calendar
> >
> > ~ Certainty is folly... I think. ~
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 




More information about the R-help mailing list