使用 R 包交互 (jtools) 对 merMod 对象进行简单斜率测试 [英] Simple slopes test for merMod object with R package interactions (jtools)

查看:160
本文介绍了使用 R 包交互 (jtools) 对 merMod 对象进行简单斜率测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对使用 lmer 获得的混合效应模型进行简单的斜率分析.

模型类似如下:

data(Orthodont,package="nlme")mod <- lme4::lmer(距离~年龄*性别+(1|主题),数据=正畸)

当尝试使用 interactions 包中的函数 sim_slopes 进行简单的斜率分析时,我收到以下错误消息.

interactions::sim_slopes(model=mod, pred=age, modx=Sex)

<块引用>

错误:请求的列之一不存在.
回溯:
1. 交互::sim_slopes(model = mod, pred = age, modx = Sex)
5. jtools:::summ.merMod(...)
6. jtools:::create_table(...)
另外:警告信息:
Johnson-Neyman 区间不适用于因子调节器.

有人对可能出现的问题有什么想法吗?

请注意,它适用于 reghelper 包,但我需要这些测试的 p 值,而 reghelper 不提供.

reghelper::simple_slopes(mod)

sessionInfo() 的输出是:

<块引用>

R 版本 3.6.0 (2019-04-26)平台:x86_64-pc-linux-gnu(64 位)运行于:Ubuntu 18.04.2长期服务

矩阵产品:默认BLAS:
/usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1 LAPACK:/usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

语言环境:[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
LC_TIME=en_CA.UTF-8 [4] LC_COLLATE=en_CA.UTF-8
LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8 [7]LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_CA.UTF-8LC_IDENTIFICATION=C

附加基础包:[1] stats graphics grDevices utils
数据集方法基础

通过命名空间加载(且未附加):
[1] Rcpp_1.0.1 magrittr_1.5 splines_3.6.0 MASS_7.3-51.1
[5] munsell_0.5.0 colorspace_1.4-1格子_0.20-38 rlang_0.3.4
[9] minqa_1.2.4 plyr_1.8.4 tools_3.6.0 grid_3.6.0
[13] gtable_0.3.0 nlme_3.1-140 cli_1.1.0 assertthat_0.2.1
[17]digest_0.6.19 lme4_1.1-21 lazyeval_0.2.2 tibble_2.1.2
[21] crayon_1.3.4 Matrix_1.2-17 reghelper_0.3.4 nloptr_1.2.1

[25] ggplot2_3.1.1 交互_1.1.0 jtools_2.0.1 pander_0.6.3
[29] compiler_3.6.0 pillar_1.4.1 scales_1.0.0 boot_1.3-20
[33] pkgconfig_2.0.2

解决方案

我通过分离 lmerTest 解决了这个问题.

I'm trying to conduct a simple slopes analysis for a mixed effects model obtained with lmer.

The model is similar to the following:

data(Orthodont,package="nlme")
mod <- lme4::lmer(distance ~ age*Sex + (1|Subject), data=Orthodont)

When trying to conduct a simple slopes analysis with the function sim_slopes in the package interactions, I obtain the following error message.

interactions::sim_slopes(model=mod, pred=age, modx=Sex)

Error: One of the requested columns does not exist.
Backtrace:
1. interactions::sim_slopes(model = mod, pred = age, modx = Sex)
5. jtools:::summ.merMod(...)
6. jtools:::create_table(...)
In addition: Warning message:
Johnson-Neyman intervals are not available for factor moderators.

Would any one have any thoughts on what the problem might be?

Note that it works well with the package reghelper, but I need p values for these tests, which reghelper does not provide.

reghelper::simple_slopes(mod)

The output of sessionInfo() is:

R version 3.6.0 (2019-04-26) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 18.04.2 LTS

Matrix products: default BLAS:
/usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
LC_TIME=en_CA.UTF-8 [4] LC_COLLATE=en_CA.UTF-8
LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils
datasets methods base

loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 magrittr_1.5 splines_3.6.0 MASS_7.3-51.1
[5] munsell_0.5.0 colorspace_1.4-1 lattice_0.20-38 rlang_0.3.4
[9] minqa_1.2.4 plyr_1.8.4 tools_3.6.0 grid_3.6.0
[13] gtable_0.3.0 nlme_3.1-140 cli_1.1.0 assertthat_0.2.1
[17] digest_0.6.19 lme4_1.1-21 lazyeval_0.2.2 tibble_2.1.2
[21] crayon_1.3.4 Matrix_1.2-17 reghelper_0.3.4 nloptr_1.2.1

[25] ggplot2_3.1.1 interactions_1.1.0 jtools_2.0.1 pander_0.6.3
[29] compiler_3.6.0 pillar_1.4.1 scales_1.0.0 boot_1.3-20
[33] pkgconfig_2.0.2

解决方案

I solved the problem by detaching lmerTest.

这篇关于使用 R 包交互 (jtools) 对 merMod 对象进行简单斜率测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆