Re: [R] LME with 2 factors with 3 levels each

2010-10-13 Thread Ista Zahn
Hi Laura,

If you want ANOVA output, ask for it! A general strategy that almost
always works in R is to fit 2 models, one without the term(s) you want
to test, and one with. Then use the anova() function to test them.
(models must be nested, and in the lmer() case you need to use REML =
FALSE).

So, try something like this:

m1 - lmer(PTR ~ Test  +  Group + (1 | student), data=ptr)
m2 - lmer(PTR ~ Test * Group + (1 | student), data=ptr)
anova(m1, m2)

Best,
Ista

On Tue, Oct 12, 2010 at 11:59 PM, Laura Halderman lk...@pitt.edu wrote:
 Hello.  I am new to R and new to linear mixed effects modeling.  I am trying 
 to model some data which has two factors.  Each factor has three levels 
 rather than continuous data.  Specifically, we measured speech at Test 1, 
 Test 2 and Test 3.  We also had three groups of subjects: RepTP, RepNTP and 
 NoRepNTP.

 I am having a really hard time interpreting this data since all the examples 
 I have seen in the book I am using (Baayen, 2008) either have continuous 
 variables or factors with only two levels.  What I find particularly 
 confusing are the interaction terms in the output.  The output doesn't 
 present the full interaction (3 X 3) as I would expect with an ANOVA.

Instead, it only presents an interaction term for one Test and one
Group, presumably comparing it to the reference Test and reference
Group.  Therefore, it is hard to know what to do with the interactions
that aren't significant.  In the book, non-significant interactions
are dropped from the model.  However, in my model, I'm only ever
seeing the 2 X 2 interactions, not the full 3 X 3 interaction, so it's
not clear what I should do when only two levels of group and two
levels of test interact but the third group doesn't.

 If anyone can assist me in interpreting the output, I would really appreciate 
 it.  I may be trying to interpret it too much like an ANOVA where you would 
 be looking for main effects of Test (was there improvement from Test 1 to 
 Test 2), main effects of Group (was one of the Groups better than the other) 
 and the interactions of the two factors (did one Group improve more than 
 another Group from Test 1 to Test 2, for example).  I guess another question 
 to pose here is, is it pointless to do an LME analysis with more than two 
 levels of a factor?  Is it too much like trying to do an ANOVA?  
 Alternatively, it's possible that what I'm doing is acceptable, I'm just not 
 able to interpret it correctly.

 I have provided output from my model to hopefully illustrate my question.  
 I'm happy to provide additional information/output if someone is interested 
 in helping me with this problem.

 Thank you,
  Laura

 Linear mixed model fit by REML
 Formula: PTR ~ Test * Group + (1 | student)
   Data: ptr
 AIC             BIC             logLik  deviance        REMLdev
  -625.7         -559.8          323.9           -706.5          -647.7
 Random effects:
  Groups Name            Variance        Std.Dev.
  student        (Intercept)     0.0010119       0.03181
  Residual                       0.0457782       0.21396
 Number of obs: 2952, groups: studentID, 20

 Fixed effects:
                                Estimate        Std. Error      t value
 (Intercept)                     0.547962        0.016476        33.26
 Testtest2                       -0.007263       0.015889        -0.46
 Testtest1                       -0.050653       0.016305        -3.11
 GroupNoRepNTP   0.008065        0.022675        0.36
 GroupRepNTP             -0.018314       0.025483        -0.72
 Testtest2:GroupNoRepNTP  0.006073   0.021936    0.28
 Testtest1:GroupNoRepNTP  0.013901   0.022613    0.61
 Testtest2:GroupRepNTP   0.046684        0.024995        1.87
 Testtest1:GroupRepNTP   0.039994        0.025181        1.59

 Note: The reference level for Test is Test3.  The reference level for Group 
 is RepTP.  The interaction p value (after running pvals.fnc with the MCMC) 
 for Testtest2:GroupRepNTP is p = .062 which I'm willing to accept and 
 interpret since speech data with English Language Learners is particularly 
 variable.
 __
 R-help@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.




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

__
R-help@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.


Re: [R] LME with 2 factors with 3 levels each

2010-10-13 Thread Dennis Murphy
Hi:

On Tue, Oct 12, 2010 at 8:59 PM, Laura Halderman lk...@pitt.edu wrote:

 Hello.  I am new to R and new to linear mixed effects modeling.  I am
 trying to model some data which has two factors.  Each factor has three
 levels rather than continuous data.  Specifically, we measured speech at
 Test 1, Test 2 and Test 3.  We also had three groups of subjects: RepTP,
 RepNTP and NoRepNTP.


Do you have three groups of subjects, where each subject is tested on three
separate occasions? Are the tests meant to be replicates, or is there some
other purpose for why they should be represented in the model? Based on this
description, it would appear to me that the groups constitute one factor,
the students nested within groups another, with three measurements taken on
each student. How many students per group?


 I am having a really hard time interpreting this data since all the
 examples I have seen in the book I am using (Baayen, 2008) either have
 continuous variables or factors with only two levels.  What I find
 particularly confusing are the interaction terms in the output.  The output
 doesn't present the full interaction (3 X 3) as I would expect with an
 ANOVA.  Instead, it only presents an interaction term for one Test and one
 Group, presumably comparing it to the reference Test and reference Group.
  Therefore, it is hard to know what to do with the interactions that aren't
 significant.  In the book, non-significant interactions are dropped from the
 model.  However, in my model, I'm only ever seeing the 2 X 2 interactions,
 not the full 3 X 3 interaction, so it's not clear what I should do when only
 two levels of group and two levels of test interact but the third group
 doesn't.


Let's get the design straight first and the model will work itself out...

Dennis


 If anyone can assist me in interpreting the output, I would really
 appreciate it.  I may be trying to interpret it too much like an ANOVA where
 you would be looking for main effects of Test (was there improvement from
 Test 1 to Test 2), main effects of Group (was one of the Groups better than
 the other) and the interactions of the two factors (did one Group improve
 more than another Group from Test 1 to Test 2, for example).  I guess
 another question to pose here is, is it pointless to do an LME analysis with
 more than two levels of a factor?  Is it too much like trying to do an
 ANOVA?  Alternatively, it's possible that what I'm doing is acceptable, I'm
 just not able to interpret it correctly.

 I have provided output from my model to hopefully illustrate my question.
  I'm happy to provide additional information/output if someone is interested
 in helping me with this problem.

 Thank you,
  Laura





 Linear mixed model fit by REML
 Formula: PTR ~ Test * Group + (1 | student)
   Data: ptr
 AIC BIC logLik  devianceREMLdev
  -625.7 -559.8  323.9   -706.5  -647.7
 Random effects:
  Groups NameVarianceStd.Dev.
  student(Intercept) 0.0010119   0.03181
  Residual   0.0457782   0.21396
 Number of obs: 2952, groups: studentID, 20

 Fixed effects:
EstimateStd. Error  t value
 (Intercept) 0.5479620.01647633.26
 Testtest2   -0.007263   0.015889-0.46
 Testtest1   -0.050653   0.016305-3.11
 GroupNoRepNTP   0.0080650.0226750.36
 GroupRepNTP -0.018314   0.025483-0.72
 Testtest2:GroupNoRepNTP  0.006073   0.0219360.28
 Testtest1:GroupNoRepNTP  0.013901   0.0226130.61
 Testtest2:GroupRepNTP   0.0466840.0249951.87
 Testtest1:GroupRepNTP   0.0399940.0251811.59

 Note: The reference level for Test is Test3.  The reference level for Group
 is RepTP.  The interaction p value (after running pvals.fnc with the MCMC)
 for Testtest2:GroupRepNTP is p = .062 which I'm willing to accept and
 interpret since speech data with English Language Learners is particularly
 variable.
 __
 R-help@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.


[[alternative HTML version deleted]]

__
R-help@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.