Closed ImanYZ closed 6 years ago
Do you have a reproducible example?
# load required packages
library(sjPlot)
library(sjmisc)
library(sjlabelled)
library(lme4)
# load sample data
data(efc)
# prepare grouping variables
efc$grp = as.factor(efc$e15relat)
levels(x = efc$grp) <- get_labels(efc$e15relat)
efc$care.level <- rec(efc$n4pstu, rec = "0=0;1=1;2=2;3:4=4", val.labels = c("none", "I", "II", "III"))
# data frame for fitted model
mydf <- data.frame(
neg_c_7 = efc$neg_c_7,
sex = to_factor(efc$c161sex),
c12hour = efc$c12hour,
barthel = efc$barthtot,
education = to_factor(efc$c172code),
grp = efc$grp,
carelevel = to_factor(efc$care.level)
)
# fit sample models
fit1 <- lmer(neg_c_7 ~ sex + c12hour + barthel + (1 | grp), data = mydf)
fit2 <- lmer(neg_c_7 ~ sex + c12hour + education + barthel + (1 | grp), data = mydf)
fit3 <- lmer(neg_c_7 ~ sex + c12hour + education + barthel +
(1 | grp) + (1 | carelevel), data = mydf)
sjt.lmer(fit1, fit2)
That code works fine for me. Are all your packages up to date, and do you have a clean environment/workspace?
I restarted RStudio and cleared the output, then ran the following. However, I still get the same error message! What else do you suggest me to do?
update.packages(ask = FALSE)
# load required packages
library(sjPlot)
library(sjmisc)
library(sjlabelled)
library(lme4)
# load sample data
data(efc)
# prepare grouping variables
efc$grp = as.factor(efc$e15relat)
levels(x = efc$grp) <- get_labels(efc$e15relat)
efc$care.level <- rec(efc$n4pstu, rec = "0=0;1=1;2=2;3:4=4", val.labels = c("none", "I", "II", "III"))
# data frame for fitted model
mydf <- data.frame(
neg_c_7 = efc$neg_c_7,
sex = to_factor(efc$c161sex),
c12hour = efc$c12hour,
barthel = efc$barthtot,
education = to_factor(efc$c172code),
grp = efc$grp,
carelevel = to_factor(efc$care.level)
)
# fit sample models
fit1 <- lmer(neg_c_7 ~ sex + c12hour + barthel + (1 | grp), data = mydf)
fit2 <- lmer(neg_c_7 ~ sex + c12hour + education + barthel + (1 | grp), data = mydf)
fit3 <- lmer(neg_c_7 ~ sex + c12hour + education + barthel +
(1 | grp) + (1 | carelevel), data = mydf)
sjt.lmer(fit1, fit2)
Can you post your session info please?
I cleaned my environment and it worked. Thank you so much.
It is in a conflict with the package "lmerTest". As soon as loading "lmerTest", sjt.lmer
returns the following error message:
Error in select_impl(.data, vars) : Column
6
cannot have NA as name
Same Error here. I have updated R Core and all packages to the latest version.
Session Info:
sessionInfo() R version 3.5.0 (2018-04-23) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS High Sierra 10.13.5
Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages: [1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] lmerTest_3.0-1 ggmap_2.6.1 scales_0.5.0 plyr_1.8.4 rgdal_1.3-2 maptools_0.9-2
[7] gpclib_1.5-5 WriteXLS_4.0.0 optimx_2013.8.7 usdm_1.1-18 raster_2.6-7 sp_1.3-1
[13] psych_1.8.4 polycor_0.7-9 sjstats_0.15.0 sjPlot_2.4.1 mvtnorm_1.0-8 MASS_7.3-50
[19] car_3.0-0 carData_3.0-1 AICcmodavg_2.1-1 rcompanion_1.13.2 piecewiseSEM_2.0.0 RLRsim_3.1-3
[25] ggcorrplot_0.1.1 dplyr_0.7.5 MuMIn_1.40.4 Hmisc_4.1-1 ggplot2_2.2.1 Formula_1.2-3
[31] survival_2.42-3 lattice_0.20-35 labelled_1.1.0 haven_1.1.1 foreign_0.8-70 install.load_1.2.1
[37] lme4_1.1-17 Matrix_1.2-14
loaded via a namespace (and not attached):
[1] proto_1.0.0 tidyselect_0.2.4 htmlwidgets_1.2 RVAideMemoire_0.9-69-3 miscTools_0.6-22
[6] munsell_0.5.0 codetools_0.2-15 DT_0.4 colorspace_1.3-2 knitr_1.20
[11] rstudioapi_0.7 stats4_3.5.0 DescTools_0.99.24 setRNG_2013.9-1 bayesplot_1.5.0
[16] emmeans_1.2.1 RgoogleMaps_1.4.2 mnormt_1.5-5 ordinal_2018.4-19 glmmTMB_0.2.1.0
[21] coda_0.19-1 TH.data_1.0-8 R6_2.2.2 arm_1.10-1 VGAM_1.0-5
[26] reshape_0.8.7 assertthat_0.2.0 promises_1.0.1 multcomp_1.4-8 nnet_7.3-12
[31] merTools_0.4.1 gtable_0.2.0 multcompView_0.1-7 sandwich_2.4-0 rlang_0.2.1
[36] EMT_1.1 splines_3.5.0 TMB_1.7.13 lazyeval_0.2.1 acepack_1.4.1
[41] Rcgmin_2013-2.21 broom_0.4.4 checkmate_1.8.5 reshape2_1.4.3 prediction_0.3.6
[46] abind_1.4-5 modelr_0.1.2 unmarked_0.12-2 backports_1.1.2 httpuv_1.4.3
[51] optextras_2016-8.8 tools_3.5.0 RColorBrewer_1.1-2 WRS2_0.9-2 ggridges_0.5.0
[56] Rcpp_0.12.17 base64enc_0.1-3 BSDA_1.2.0 purrr_0.2.5 rpart_4.1-13
[61] zoo_1.8-1 cluster_2.0.7-1 survey_3.33-2 Rvmmin_2018-4.17 magrittr_1.5
[66] data.table_1.11.4 openxlsx_4.1.0 manipulate_1.0.1 lmtest_0.9-36 effects_4.0-1
[71] sjmisc_2.7.2 hms_0.4.2 mime_0.5 xtable_1.8-2 pbkrtest_0.4-7
[76] rio_0.5.10 jpeg_0.1-8 readxl_1.1.0 gridExtra_2.3 ggeffects_0.3.4
[81] compiler_3.5.0 maps_3.3.0 tibble_1.4.2 crayon_1.3.4 minqa_1.2.4
[86] htmltools_0.3.6 mgcv_1.8-23 mc2d_0.1-18 later_0.7.3 hermite_1.1.2
[91] tidyr_0.8.1 expm_0.999-2 sjlabelled_1.0.11 boot_1.3-20 readr_1.1.1
[96] ade4_1.7-11 permute_0.9-4 quadprog_1.5-5 parallel_3.5.0 bindr_0.1.1
[101] forcats_0.3.0 pkgconfig_2.0.1 geosphere_1.5-7 numDeriv_2016.8-1 coin_1.2-2
[106] BB_2014.10-1 svUnit_0.7-12 blme_1.0-4 stringdist_0.9.5.1 estimability_1.3
[111] snakecase_0.9.1 stringr_1.3.1 digest_0.6.15 vegan_2.5-2 cellranger_1.1.0
[116] htmlTable_1.12 nortest_1.0-4 maxLik_1.3-4 curl_3.2 shiny_1.1.0
[121] modeltools_0.2-21 rjson_0.2.20 pwr_1.2-2 nloptr_1.0.4 nlme_3.1-137
[126] bindrcpp_0.2.2 mapproj_1.2.6 pillar_1.2.3 dfoptim_2018.2-1 glue_1.2.0
[131] zip_1.0.0 png_0.1-7 class_7.3-14 stringi_1.2.2 latticeExtra_0.6-28
[136] ucminf_1.1-4 e1071_1.6-8
Also in your case it looks like an issue with lmerTest. Models fitted with that package don't work in broom, I already opened an issue there.
Thanks. I've looked into the corresponding issue. It looks like the author's already on the problem. As a workaround, I took lmerTest out of my calculations.
I have the same problem. Please post a workaround
Simply use lme4::lmer()
instead of lmerTest.
I'm following the exact instructions in: https://cran.r-project.org/web/packages/sjPlot/vignettes/sjtlmer.html
However, as soon as I run
sjt.lmer(fit1, fit2)
, it returns this error message: