【问题标题】:Extracting p-values for fixed effects from nlme/lme4 output从 nlme/lme4 输出中提取固定效应的 p 值
【发布时间】:2016-06-10 07:35:40
【问题描述】:

我正在尝试从由混合效应模型的摘要调用创建的对象中包含的固定效应表中提取单个元素(特别是 p 值)。

玩具数据:

set.seed(1234)
score <- c(rnorm(8, 20, 3), rnorm(8, 35, 5))
rep <- rep(c(0,1,2,3), each = 8)
group <- rep(0:1, times = 16)
id <- factor(rep(1:8, times = 4))

df <- data.frame(id, group, rep, score)

现在创建一个模型

require(nlme)

modelLME <- summary(lme(score ~ group*rep, data = df, random = ~ rep|id))

modelLME

当我们调用它时,我们会得到输出

Linear mixed-effects model fit by REML
 Data: df 
       AIC      BIC    logLik
  219.6569 230.3146 -101.8285

Random effects:
 Formula: ~rep | id
 Structure: General positive-definite, Log-Cholesky parametrization
            StdDev       Corr  
(Intercept) 2.664083e-04 (Intr)
rep         2.484345e-05 0     
Residual    7.476621e+00       

Fixed effects: score ~ group * rep 
                Value Std.Error DF   t-value p-value
(Intercept) 22.624455  3.127695 22  7.233587  0.0000
group       -1.373324  4.423229  6 -0.310480  0.7667
rep          2.825635  1.671823 22  1.690152  0.1051
group:rep    0.007129  2.364315 22  0.003015  0.9976
 Correlation: 
          (Intr) group  rep   
group     -0.707              
rep       -0.802  0.567       
group:rep  0.567 -0.802 -0.707

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-1.86631781 -0.74498367  0.03515508  0.76672652  1.91896578 

Number of Observations: 32
Number of Groups: 8 

现在我可以通过

提取固定效应的参数估计
fixef(modelLME)

但是如何提取 p 值?

要提取我们调用的整个随机效应表

VarCorr(modelLME)

然后通过子集函数[,] 提取该表中的各个元素。但是我不知道VarCorr()的等价函数对于固定效果是什么。

【问题讨论】:

    标签: r lme4 nlme


    【解决方案1】:

    您可以使用以下方法提取 p 值:

    modelLME$tTable[,5]
    
        (Intercept)           group             rep       group:rep 
    0.0000003012047 0.7666983225269 0.1051210824864 0.9976213300628 
    

    通常,查看str(modelLME) 有助于找到不同的组件。

    【讨论】:

    • 谢谢@beetroot。我确实运行了names(modelLME),但并不清楚tTable 是固定效果表。此外,使用VarCorr 调用的随机效果表也未列在此函数调用的元素列表中,因此我不确定固定效果是否也是如此。但他们是。干杯。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-11
    • 2021-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-08
    相关资源
    最近更新 更多