[英]Extracting p-values for fixed effects from nlme/lme4 output
我正在嘗試從混合效果模型的摘要調用創建的對象中包含的固定效果表中提取單個元素(特別是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()
等效的功能是什么固定效果。
您可以使用以下方法提取p值:
modelLME$tTable[,5]
(Intercept) group rep group:rep
0.0000003012047 0.7666983225269 0.1051210824864 0.9976213300628
通常,查看str(modelLME)
有助於查找不同的組件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.