这可能是一个显而易见的问题,我还没有找到(R newbie)的答案,但是当使用lmer
函数生成混合效果模型时,则使用以下方式显示结果:
screenreg(list(model4re), single.row = TRUE)
我们以星形的形式得到beta估计,标准误差和显着性水平的列表。
使用什么测试来确定标记星星的这些p值(重要的是我认识到如何使用这些模型适当地确定重要影响存在一些争论)以及我们如何提取用于这些模型的p值分?
答案 0 :(得分:1)
可以找到R中可用于计算lmer
估计参数的p值的方法的详细说明,输入?lme4::pvalues
。
下面我展示了计算Kenward-Roger校正测试的p值的代码:
library(lmerTest)
fm1 <- lmerTest::lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
lmerTest::anova(fm1)
#############
Analysis of Variance Table of type III with Satterthwaite
approximation for degrees of freedom
Sum Sq Mean Sq NumDF DenDF F.value Pr(>F)
Days 30031 30031 1 17 45.853 3.264e-06 ***
stargazer
包中的stargazer
命令打印估算参数的p值:
library(stargazer)
fm2 <- lme4::lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
stargazer(fm2, type="text", report="vcp")
===============================================
Dependent variable:
---------------------------
Reaction
-----------------------------------------------
Days 10.467
p = 0.000
Constant 251.405
p = 0.000
-----------------------------------------------
Observations 180
Log Likelihood -871.814
Akaike Inf. Crit. 1,755.628
Bayesian Inf. Crit. 1,774.786
===============================================
Note: *p<0.1; **p<0.05; ***p<0.01
答案 1 :(得分:1)
在texreg
中,lme4
对象的p值由extract.lmerMod
命令计算。
请参阅以下示例:
library(lme4)
data(oats, package="MASS")
(fm1 <- lmer(Y ~ V*N + (1| B/V), data = oats))
##############
Linear mixed model fit by REML ['merModLmerTest']
Formula: Y ~ V * N + (1 | B/V)
Data: oats
REML criterion at convergence: 529.0285
Random effects:
Groups Name Std.Dev.
V:B (Intercept) 10.30
B (Intercept) 14.65
Residual 13.31
Number of obs: 72, groups: V:B, 18; B, 6
Fixed Effects:
(Intercept) VMarvellous VVictory N0.2cwt N0.4cwt N0.6cwt
80.0000 6.6667 -8.5000 18.5000 34.6667 44.8333
VMarvellous:N0.2cwt VVictory:N0.2cwt VMarvellous:N0.4cwt VVictory:N0.4cwt VMarvellous:N0.6cwt VVictory:N0.6cwt
3.3333 -0.3333 -4.1667 4.6667 -4.6667 2.1667
###############
使用extract.lmerMod
我们得到:
extract.lmerMod(fm1)
###############
coef. s.e. p
(Intercept) 80.0000000 9.106977 1.570989e-18
VMarvellous 6.6666667 9.715025 4.925730e-01
VVictory -8.5000000 9.715025 3.816101e-01
N0.2cwt 18.5000000 7.682954 1.604334e-02
N0.4cwt 34.6666667 7.682954 6.417271e-06
N0.6cwt 44.8333333 7.682954 5.365224e-09
VMarvellous:N0.2cwt 3.3333333 10.865337 7.590063e-01
VVictory:N0.2cwt -0.3333333 10.865337 9.755259e-01
VMarvellous:N0.4cwt -4.1666667 10.865337 7.013620e-01
VVictory:N0.4cwt 4.6666667 10.865337 6.675591e-01
VMarvellous:N0.6cwt -4.6666667 10.865337 6.675591e-01
VVictory:N0.6cwt 2.1666667 10.865337 8.419413e-01
GOF dec. places
AIC 559.0285 TRUE
BIC 593.1785 TRUE
Log Likelihood -264.5143 TRUE
Num. obs. 72.0000 FALSE
Num. groups: V:B 18.0000 FALSE
Num. groups: B 6.0000 FALSE
Var: V:B (Intercept) 106.0618 TRUE
Var: B (Intercept) 214.4771 TRUE
Var: Residual 177.0833 TRUE
查看extract.lmerMod
函数,p值计算如下:
betas <- lme4::fixef(fm1)
Vcov <- vcov(fm1)
Vcov <- as.matrix(Vcov)
se <- sqrt(diag(Vcov))
zval <- betas/se
(pval <- 2 * pnorm(abs(zval), lower.tail = FALSE))
##################
(Intercept) VMarvellous VVictory N0.2cwt N0.4cwt N0.6cwt VMarvellous:N0.2cwt VVictory:N0.2cwt
1.570989e-18 4.925730e-01 3.816101e-01 1.604334e-02 6.417271e-06 5.365224e-09 7.590063e-01 9.755259e-01
VMarvellous:N0.4cwt VVictory:N0.4cwt VMarvellous:N0.6cwt VVictory:N0.6cwt
7.013620e-01 6.675591e-01 6.675591e-01 8.419413e-01