R, ggplot2, jtools: johnson neyman plot 错误
R, ggplot2, jtools: johnson neyman plot error
我正在拼命尝试为以下交互绘制 Johnson-Neyman 图:
nxsc_20 <-lm(meandec20 ~ centered_nep*centered_selfcontrol + factor(study), data = allstudies_wide)
我得到以下输出:
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.28264 0.02260 12.508 < 2e-16 ***
centered_nep 0.08998 0.01192 7.551 7.41e-14 ***
centered_selfcontrol 0.01894 0.01021 1.856 0.06364 .
factor(study)2 0.03462 0.02531 1.368 0.17146
factor(study)3 0.35767 0.02635 13.573 < 2e-16 ***
factor(study)4 0.33224 0.03709 8.956 < 2e-16 ***
centered_nep:centered_selfcontrol 0.03706 0.01300 2.850 0.00443 **
现在我尝试制作 JN-Plot
johnson_neyman(nxsc_20, meandec20, centered_selfcontrol, alpha = 0.05, plot = TRUE)
我收到以下错误:
Fehler in vmat[pred, pred] : Indizierung außerhalb der Grenzen (Error in vmat[pred, pred] : indexing out of range)
谁能帮我解决这个问题?
非常感谢!
pred =
选项不适用于响应变量,而是用于您要在 y 轴上绘制的预测变量。这将起作用:
library(interactions)
allstudies_wide = data.frame(meandec20=rnorm(500),centered_nep = runif(500),
centered_selfcontrol = runif(500), study = sample(1:4,500,replace=TRUE))
nxsc_20 <-lm(meandec20 ~ centered_nep*centered_selfcontrol + factor(study),
data = allstudies_wide)
johnson_neyman(model = nxsc_20, pred = centered_nep,modx = centered_selfcontrol)
我正在拼命尝试为以下交互绘制 Johnson-Neyman 图:
nxsc_20 <-lm(meandec20 ~ centered_nep*centered_selfcontrol + factor(study), data = allstudies_wide)
我得到以下输出:
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.28264 0.02260 12.508 < 2e-16 ***
centered_nep 0.08998 0.01192 7.551 7.41e-14 ***
centered_selfcontrol 0.01894 0.01021 1.856 0.06364 .
factor(study)2 0.03462 0.02531 1.368 0.17146
factor(study)3 0.35767 0.02635 13.573 < 2e-16 ***
factor(study)4 0.33224 0.03709 8.956 < 2e-16 ***
centered_nep:centered_selfcontrol 0.03706 0.01300 2.850 0.00443 **
现在我尝试制作 JN-Plot
johnson_neyman(nxsc_20, meandec20, centered_selfcontrol, alpha = 0.05, plot = TRUE)
我收到以下错误:
Fehler in vmat[pred, pred] : Indizierung außerhalb der Grenzen (Error in vmat[pred, pred] : indexing out of range)
谁能帮我解决这个问题?
非常感谢!
pred =
选项不适用于响应变量,而是用于您要在 y 轴上绘制的预测变量。这将起作用:
library(interactions)
allstudies_wide = data.frame(meandec20=rnorm(500),centered_nep = runif(500),
centered_selfcontrol = runif(500), study = sample(1:4,500,replace=TRUE))
nxsc_20 <-lm(meandec20 ~ centered_nep*centered_selfcontrol + factor(study),
data = allstudies_wide)
johnson_neyman(model = nxsc_20, pred = centered_nep,modx = centered_selfcontrol)