I analyzed a simple slope of the GLMM cross-level interaction terms for which significant associations were found. I used "reghelper" package in R.
if (require(lme4, quietly=TRUE)) {
model <- glmer(Y ~ X * W + (1|Com_ID), data=dat, family='binomial')
print(summary(model))
print(simple_slopes(model))
graph_model(model, y=Y, x=X, lines=W)
}
The outputs of summary and simple_slopes were as follows:
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: binomial ( logit )
Formula: Y ~ X * W + (1 | Com_ID)
Data: dat
AIC BIC logLik deviance df.resid
1441.5 1468.0 -715.7 1431.5 1473
Scaled residuals:
Min 1Q Median 3Q Max
-0.6387 -0.6055 -0.3888 -0.3147 3.1778
Random effects:
Groups Name Variance Std.Dev.
Com_ID (Intercept) 0.007915 0.08897
Number of obs: 1478, groups: Com_ID, 11
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.3638 0.1117 -12.204 < 2e-16 ***
X -0.4381 0.1095 -3.999 6.37e-05 ***
Wurban -0.1526 0.1562 -0.977 0.329
X:Wurban -0.1977 0.1489 -1.328 0.184
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) X Wurban
X 0.258
Wurban -0.722 -0.185
X:Wurban -0.187 -0.736 0.289
X W Test Estimate Std. Error t value
1 -1 0.0451892102738553 0.1820 0.2483 0.8039
2 0 -0.152553682044491 0.1562 -0.9766 0.3288
3 1 -0.350285976436759 0.2450 -1.4298 0.1528
4 sstest -0.438054016500106 0.1095 -3.9987 0.0001
5 sstest -0.635779394026394 0.1009 -6.3039 0.0000
The p-value of the simple slope cannot be identified in that package, so I found some articles introducing to a website(http://www.quantpsy.org/interact/hlm2.htm) and used the calculator. However, SE, z and p were "NaN" at simple intercepts and slopes at conditional values of w at w1(2). I don't know what caused this. Can I ask for help?
Y and X are binary data and X is scaled. W is a two-level factor type.
CASE 3 TWO-WAY INTERACTION SIMPLE SLOPES OUTPUT
Your Input
========================================================
w1(1) = 0
w1(2) = 1
x1(1) = -1
x1(2) = 1
Intercept = -1.07691
x1 Slope = -0.71724
w1 Slope = -0.03432
w1x1 Slope = -0.56498
alpha = 0.05
Asymptotic (Co)variances
========================================================
var(g00) 0.01709818
var(g10) 0.05253264
var(g01) 0.03291322
var(g11) 0.10903864
cov(g00,g01) -0.726
cov(g10,g11) -0.694
cov(g00,g10) -0.458
cov(g01,g11) -0.378
Region of Significance on w (level-2 predictor)
========================================================
w1 at lower bound of region = -0.0508
w1 at upper bound of region = 61.634
(simple slopes are significant *inside* this region.)
Simple Intercepts and Slopes at Conditional Values of w
========================================================
At w1(1)...
simple intercept = -1.0769(0.1308), z=-8.2358, p=0
simple slope = -0.7172(0.2292), z=-3.1293, p=0.0018
At w1(2)...
simple intercept = -1.1112(NaN), z=NaN, p=NaN # <--- Here
simple slope = -1.2822(NaN), z=NaN, p=NaN # <--- Here
Simple Intercepts and Slopes at Region Boundaries for w
========================================================
Lower Bound...
simple intercept = -1.0752(0.3016), z=-3.5652, p=0.0004
simple slope = -0.6885(0.3512), z=-1.9607, p=0.0499
Upper Bound...
simple intercept = -3.1922(5.9627), z=-0.5354, p=0.5924
simple slope = -35.5392(18.1305), z=-1.9602, p=0.05
Region of Significance on x (level-1 predictor)
========================================================
x1 at lower bound of region = 0.0426
x1 at upper bound of region = 29.4637
(simple slopes are significant *inside* this region.)
Simple Intercepts and Slopes at Conditional Values of x
========================================================
At x1(1)...
simple intercept = -0.3597(0.9928), z=-0.3623, p=0.7171
simple slope = 0.5307(0.9476), z=0.56, p=0.5755
At x1(2)...
simple intercept = -1.7941(NaN), z=NaN, p=NaN
simple slope = -0.5993(NaN), z=NaN, p=NaN
Simple Intercepts and Slopes at Region Boundaries for x
========================================================
Lower Bound...
simple intercept = -1.1075(NaN), z=NaN, p=NaN
simple slope = -0.0584(0.0301), z=-1.9404, p=0.0524
Upper Bound...
simple intercept = -22.2095(4.3165), z=-5.1452, p=0
simple slope = -16.6807(8.5098), z=-1.9602, p=0.05
Points to Plot
=======================================================
Line for w1(1): From {x1=-1, Y=-0.3597} to {x1=1, Y=-1.7941}
Line for w1(2): From {x1=-1, Y=0.171} to {x1=1, Y=-2.3934}
I found this website(https://groups.google.com/g/lavaan/c/lyjF4JZAgBk) and set 100000 at df_int and df_slp. But the result of "simple intercepts and slopes at conditional values of w at w1(2)" didn't change.