Reputation: 13
I'm trying to summarize a lmer
model with sjPlot::tab_model
. It works until I try to get "kr" p-values to also obtain degrees of freedom. I have pbkrtest
installed, and can use it separately, but it's unsuccessfully called by tab_model
. Does anyone know what I'm missing?
I ran a linear mixed effects model. I can generate a table using
tab_model(BWRTmod1b,show.stat = TRUE)
When I change the call to get p-values based on the Kenward-Roger approximated degrees of freedom like this:
tab_model(BWRTmod1b,p.val= "kr" ,show.stat = TRUE)
I get the following error message:
Error in round(attr(pv, "df.kr", exact = TRUE)) : non-numeric argument to mathematical function
I have googled the problem and the only thing I found was a missing pbkrtest
package, but that's not the case here. I also googled the error message itself and found that this can happen when a data frame is fed into a function that wants numerical input. I have also updated R and reinstalled/updated all packages and that didn't help.
I don't know whether and how I can fix this and it's also entirely possible that I am missing something else. Any hints would be appreciated.
# working
tab_model(BWRTmod1b,show.stat = TRUE)
# not working
tab_model(BWRTmod1b,p.val= "kr" ,show.stat = TRUE)
# long term goal
tab_model(BWRTmod1b,p.val= "kr", show.df=TRUE ,show.stat = TRUE)
I expected to generate a table of my linear mixed effects model results that includes degrees of freedom. I can generate a table with a summary based on Wald approximation, but I cannot get the Kenward-Roger version with degrees of freedom.
Upvotes: 1
Views: 565
Reputation: 226597
This turns out to be a bug/infelicitous interaction between the lmerTest
and sjPlot
packages. Reproducible example:
library(lmerTest)
fm3 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy,
REML=TRUE)
sjPlot::tab_model(fm3,p.val="kr")
## Error in round(attr(pv, "df.kr", exact = TRUE)) :
## non-numeric argument to mathematical function
whereas the same thing works if you start with library(lme4)
instead of library(lmerTest)
. It should now be fixed in the development version of sjPlot
Not sure how this interacts with REML=TRUE
...
Upvotes: 0