Error with nlme

前端 未结 2 1385
野趣味
野趣味 2021-02-20 07:03

For IGF data from nlme library, I\'m getting this error message:

lme(conc ~ 1, data=IGF, random=~age|Lot)
Error in lme.formula(conc ~ 1         


        
2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-20 07:45

    If you plot the data, you can see that there is no effect of age, so it seems strange to be trying to fit a random effect of age in spite of this. No wonder it is not converging.

    library(nlme)
    library(ggplot2)
    
    dev.new(width=6, height=3)
    qplot(age, conc, data=IGF) + facet_wrap(~Lot, nrow=2) + geom_smooth(method='lm')
    

    enter image description here

    I think what you want to do is model a random effect of Lot on the intercept. We can try including age as a fixed effect, but we'll see that it is not significant and can be thrown out:

    > summary(lme(conc ~ 1 + age, data=IGF, random=~1|Lot))
    Linear mixed-effects model fit by REML
     Data: IGF 
           AIC      BIC    logLik
      604.8711 618.7094 -298.4355
    
    Random effects:
     Formula: ~1 | Lot
            (Intercept) Residual
    StdDev:  0.07153912 0.829998
    
    Fixed effects: conc ~ 1 + age 
                    Value  Std.Error  DF  t-value p-value
    (Intercept)  5.354435 0.10619982 226 50.41849  0.0000
    age         -0.000817 0.00396984 226 -0.20587  0.8371
     Correlation: 
        (Intr)
    age -0.828
    
    Standardized Within-Group Residuals:
            Min          Q1         Med          Q3         Max 
    -5.46774548 -0.43073893 -0.01519143  0.30336310  5.28952876 
    
    Number of Observations: 237
    Number of Groups: 10 
    

提交回复
热议问题