【问题标题】:gls() vs. lme() in the nlme packagenlme 包中的 gls() 与 lme()
【发布时间】:2010-11-26 13:50:28
【问题描述】:

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

  1. 之间有什么区别 它们在模型类型方面 可以合身,而合身 过程?
  2. 什么是设计 有两个功能的理性 拟合线性混合模型,其中大多数 仅其他系统(例如 SAS SPSS) 有吗?

更新:增加了赏金。有兴趣了解拟合过程中的差异,以及合理性。

【问题讨论】:

    标签: r statistics


    【解决方案1】:

    有趣的问题。

    原则上唯一的区别是 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 “没有随机参数”吗?即,它仍然模拟随机效应?
    【解决方案2】:

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

    gls 函数用于拟合 扩展线性模型,使用任一 最大似然,或受限 最大似然。可以查看 作为一个 lme 函数,没有 参数随机

    有关更多详细信息,将正畸数据集的lme 分析(从同一本书的 p147 开始)与gls 分析(从 p250 开始)进行比较会很有启发性。首先,比较


    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 位),但标准误不同,相关矩阵也是如此。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-28
      • 1970-01-01
      • 1970-01-01
      • 2021-01-18
      • 1970-01-01
      相关资源
      最近更新 更多