nlme包中的gls()与lme()有什么区别?

24

在nlme软件包中,有两个函数可以用于拟合线性模型(lme和gls)。

  1. 它们在哪些模型类型以及拟合过程方面有何不同?
  2. 为什么要设计两个函数来拟合线性混合模型,而大多数其他系统(例如SAS SPSS)只有一个函数?

更新:添加悬赏。希望了解拟合过程和设计理念上的差异。

2个回答

28

摘自Pinheiro&Bates 2000,第5.4节,p250:

gls函数用于拟合扩展线性模型,使用最大似然或受限制的最大似然。它可以被视为没有随机参数的lme函数。

更多详情可参考同一书中lme分析和p250开始的gls分析进行比较。首先,比较


orth.lme <- lme(distance ~ Sex * I(age-11), data=Orthodont)
summary(orth.lme)

Linear mixed-effects model fit by REML
 Data: Orthodont 
       AIC     BIC    logLik
  458.9891 498.655 -214.4945

Random effects:
 Formula: ~Sex * I(age - 11) | Subject
 Structure: General positive-definite
                      StdDev    Corr                
(Intercept)           1.7178454 (Intr) SexFml I(-11)
SexFemale             1.6956351 -0.307              
I(age - 11)           0.2937695 -0.009 -0.146       
SexFemale:I(age - 11) 0.3160597  0.168  0.290 -0.964
Residual              1.2551778                     

Fixed effects: distance ~ Sex * I(age - 11) 
                          Value Std.Error DF  t-value p-value
(Intercept)           24.968750 0.4572240 79 54.60945  0.0000
SexFemale             -2.321023 0.7823126 25 -2.96687  0.0065
I(age - 11)            0.784375 0.1015733 79  7.72226  0.0000
SexFemale:I(age - 11) -0.304830 0.1346293 79 -2.26421  0.0263
 Correlation: 
                      (Intr) SexFml I(-11)
SexFemale             -0.584              
I(age - 11)           -0.006  0.004       
SexFemale:I(age - 11)  0.005  0.144 -0.754

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-2.96534486 -0.38609670  0.03647795  0.43142668  3.99155835 

Number of Observations: 108
Number of Groups: 27

orth.gls <- gls(distance ~ Sex * I(age-11), data=Orthodont)
summary(orth.gls)

Generalized least squares fit by REML
  Model: distance ~ Sex * I(age - 11) 
  Data: Orthodont 
       AIC      BIC    logLik
  493.5591 506.7811 -241.7796

Coefficients:
                          Value Std.Error  t-value p-value
(Intercept)           24.968750 0.2821186 88.50444  0.0000
SexFemale             -2.321023 0.4419949 -5.25124  0.0000
I(age - 11)            0.784375 0.1261673  6.21694  0.0000
SexFemale:I(age - 11) -0.304830 0.1976661 -1.54214  0.1261

 Correlation: 
                      (Intr) SexFml I(-11)
SexFemale             -0.638              
I(age - 11)            0.000  0.000       
SexFemale:I(age - 11)  0.000  0.000 -0.638

Standardized residuals:
        Min          Q1         Med          Q3         Max 
-2.48814895 -0.58569115 -0.07451734  0.58924709  2.32476465 

Residual standard error: 2.256949 
Degrees of freedom: 108 total; 104 residual
请注意,固定效应的估计值相同(保留6位小数),但标准误差和相关矩阵是不同的。

4
有趣的问题。
原则上,gls和lme的唯一区别在于gls无法拟合具有随机效应的模型,而lme可以。因此,下面的命令:
fm1 <- gls(follicles ~ sin(2*pi*Time)+cos(2*pi*Time),Ovary,
           correlation=corAR1(form=~1|Mare))

并且

lm1 <- lme(follicles~sin(2*pi*Time)+cos(2*pi*Time),Ovary,
           correlation=corAR1(form=~1|Mare))

应该会得到相同的结果,但实际上并不是这样。拟合参数略有不同。


这是真的吗?GLS不能拟合带有随机效应的模型,这不仅仅是Richie所说的类似于没有随机参数的LME吗?也就是说,它仍然可以对随机效应进行建模? - user2363642

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接