1

My data look like this

Study   NDF ADF CP  Eeff
1   35.8    24.4    18.6    34.83181476
1   35.8    24.4    18.6    33.76824264
1   35.8    24.4    18.6    32.67390287
1   35.8    24.4    18.6    33.05520666
2   39.7    23.4    16.1    33.19730252
2   39.4    22.9    16.3    34.04709188
3   28.9    20.6    18.7    33.22501606
3   27.1    18.9    17.9    33.80766289

Of course, I have 80 lines like this. I used lme function to run a mixed model (Study as random effect), as following:

fm1<-lme(Eeff~NDF+ADF+CP,random=~1|Study, data=na.omit(phuong))

I got this result:

Fixed effects: Ratio ~ ADF + CP + FCM + DMI + DIM 
                 Value  Std.Error  DF   t-value p-value
(Intercept)  3.1199808 0.16237303 158 19.214896  0.0000
ADF         -0.0265626 0.00406990 158 -6.526603  0.0000
CP          -0.0534021 0.00539108 158 -9.905636  0.0000
FCM         -0.0149314 0.00353524 158 -4.223598  0.0000
DMI          0.0072318 0.00498779 158  1.449894  0.1491
DIM         -0.0008994 0.00019408 158 -4.634076  0.0000
 Correlation: 
    (Intr) ADF    CP     FCM    DMI   
ADF -0.628                            
CP  -0.515  0.089                     
FCM -0.299  0.269 -0.203              
DMI -0.229 -0.145  0.083 -0.624       
DIM -0.113  0.127 -0.061  0.010 -0.047

These results show the case where intercept is random but slope is fixed. How can I see my 80 intercept, for example, like below when I used study as fixed effect:

Coefficients:
                            Estimate      Std. Error t value Pr(>|t|)    
(Intercept)        -0.0021083  0.0102536  -0.206 0.837351    
ADF                      0.0005248  0.0002962   1.772 0.078313 .  
CP                        0.0021131  0.0003277   6.448 1.26e-09 ***
factor(Study)2   0.0057274  0.0038709   1.480 0.140933    
factor(Study)3   0.0117722  0.0035262   3.338 0.001046 ** 
factor(Study)4   0.0091049  0.0043227   2.106 0.036730 *  
factor(Study)6   0.0149733  0.0045345   3.302 0.001182 ** 
factor(Study)7   0.0065518  0.0036837   1.779 0.077196 .  
factor(Study)8   0.0066134  0.0035371   1.870 0.063337 .  
factor(Study)9   0.0086758  0.0036641   2.368 0.019083 *  
factor(Study)10  0.0105657  0.0041296   2.559 0.011434 *  
factor(Study)11  0.0083694  0.0040194   2.082 0.038900 *  
factor(Study)16  0.0171258  0.0028962   5.913 1.95e-08 ***
factor(Study)18  0.0019277  0.0042300   0.456 0.649209    
factor(Study)20  0.0172469  0.0040412   4.268 3.36e-05 ***
factor(Study)23  0.0132676  0.0031658   4.191 4.57e-05 ***
factor(Study)24  0.0063313  0.0031519   2.009 0.046236 *  
factor(Study)25  0.0050929  0.0039135   1.301 0.194989    

Thank you very much, Phuong

Julius Vainora
  • 47,421
  • 9
  • 90
  • 102
hn.phuong
  • 835
  • 6
  • 15
  • 24

1 Answers1

3

You didn't give us a reproducible question, but the answer is to use coef, for example:

> library(nlme)
> fm1 <- lme(distance~age,random=~1|Subject,data=Orthodont)
> coef(fm1)
    (Intercept)       age
M16    15.84314 0.6601852
M05    15.84314 0.6601852
M02    16.17959 0.6601852
M11    16.40389 0.6601852
M07    16.51604 0.6601852
M08    16.62819 0.6601852
M03    16.96464 0.6601852
[snip]
  • use fixef() to get just the fixed effect coefficients
  • use ranef() to get just the random effects (i.e. deviations of each individual from the fixed coefficients
  • the Orthodont example in lme actually uses a random-slope(+intercept) model; here I have fitted a random-intercept model, so the estimated slope (age parameter) is the same for every individual
  • it looks like individuals are sorted in increasing order of estimated random effect
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • First thank you very much Ben. It is great! Second I am sorry for the problem of reproducible data. I still do not fully understand how to give you that? I though what I did was already reproducible. Could you please tell me more clearly, it would help me to annoy you next time when I ask. – hn.phuong Sep 13 '12 at 14:13
  • can I have a small question: What is meaning of the results in this part of mixed effect model used lme: Correlation: (Intr) ADF CP FCM DMI ADF -0.628 CP -0.515 0.089 FCM -0.299 0.269 -0.203 DMI -0.229 -0.145 0.083 -0.624 DIM -0.113 0.127 -0.061 0.010 -0.047 – hn.phuong Sep 13 '12 at 14:26
  • I think (hope? :-) ) you mean "*not* annoy you" (or "annoy you *less*") ... basically, "reproducible" means an example we can cut & paste to run ourselves -- see http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example . The "correlation" section you asked about shows the estimated correlations among the fixed effect parameters (which can help diagnose model instability, for example, but which can often be ignored) – Ben Bolker Sep 13 '12 at 14:36
  • Dear Ben, in my model if I want to put the random effect of each study on slope of (ADF, NDF, CP). How should the command look like? I tried with random intercept and random NDF like this: fmp3<-lme(Eeff~NDF+ADF+CP,random=~1+NDF|Study,data=na.omit(phuong)). It works But I tried adding ADF or both ADF and CP. It does not work: R gave this annoucement: Error in lme.formula(Eeff ~ NADF ADF + CP , random = ~1 + NDF+ADF + CP | Study, : nlminb problem, convergence error code = 1 message = iteration limit reached without convergence (10) Can you please help me? – hn.phuong Sep 13 '12 at 15:07
  • You're probably overfitting the model. Also, you can't fit interactions between slopes and studies unless the values of the predictors vary within studies. (These are turning into more appropriate questions for the r-sig-mixed-models mailing list or CrossValidated.) – Ben Bolker Sep 13 '12 at 15:16