问题描述
R新手在这里.我在使用lmerTest
和stargazer
时遇到问题.我正在按照此处的教程操作,以使stargazer
与R中的lme4
一起使用.
R novice here. I'm having issues working with lmerTest
and stargazer
. I was following the tutorial here to get stargazer
to work with lme4
in R.
我没有任何问题地运行了这个示例.
I ran this example with no issues.
library(lme4)
library(stargazer)
data(cake)
summary(M1 <- lmer(angle ~ temp + (1 | replicate) + (1|recipe:replicate), cake, REML= FALSE))
summary(M2 <- lmer(angle ~ factor(temperature) + (1 | replicate) + (1|recipe:replicate), cake, REML= FALSE))
anova(M1,M2)
stargazer(M1, M2, style="ajps", title="An Illustrative Model Using Cake Data", dep.var.labels.include = FALSE,
covariate.labels=c( "Temperature (Continuous)", "Temperature (Factor $<$ 185)", "Temperature (Factor $<$ 195)", "Temperature (Factor $<$ 205)", "Temperature (Factor $<$ 215)", "Temperature (Factor $<$ 225)")
)
虽然可行,但如果我包含lmerTest
软件包,则stargazer
不再有效.
While that works, if I include the lmerTest
package, stargazer
no longer works.
library(lme4)
library(lmerTest)
library(stargazer)
data(cake)
summary(M1 <- lmer(angle ~ temp + (1 | replicate) + (1|recipe:replicate), cake, REML= FALSE))
summary(M2 <- lmer(angle ~ factor(temperature) + (1 | replicate) + (1|recipe:replicate), cake, REML= FALSE))
anova(M1,M2)
stargazer(M1, M2, style="ajps", title="An Illustrative Model Using Cake Data", dep.var.labels.include = FALSE,
covariate.labels=c( "Temperature (Continuous)", "Temperature (Factor $<$ 185)", "Temperature (Factor $<$ 195)", "Temperature (Factor $<$ 205)", "Temperature (Factor $<$ 215)", "Temperature (Factor $<$ 225)")
)
Error in objects[[i]]$zelig.call :
$ operator not defined for this S4 class
我真的很想使用stargazer
,但是我的实验要求使用merModLmerTest
对象,而stargazer
不支持.有人知道解决方法吗?将merModLmerTest
对象转换为兼容的lmerMod
对象有多困难?
I really would like to use stargazer
but my experiments require the use of merModLmerTest
objects, which stargazer
doesn't support. Does someone know of a workaround? How difficult would it be to cast a merModLmerTest
object into a lmerMod
object that would be compatible?
推荐答案
这是一个简单的解决方法.将lmerTest
(位于类merModLmerTest
中)的输出转换为lmerMod
类.这将与观星者兼容.
This is an easy fix. Convert the output of the lmerTest
(which is in class merModLmerTest
) to the lmerMod
class. This will be compatible with stargazer.
class(model) <- "lmerMod"
这篇关于R stargazer,lme4和lmerTest不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!