I have been trying to solve this for days, so any help would be appreciated!
I am trying to make an interaction plot for an OLS Regression. This is the code I am using:
interact <- lm(ele$vt_c ~ ele$Immigrants:ele$X.qual, data = as.data.frame(ele))
interact_plot(model = interact, pred=Immigrants, modx =X.qual, modx.values = NULL, data = ele)
This is the error that is coming up
Error in ecdf(d[[modx]]) : 'x' must have 1 or more non-missing values
In addition: Warning message:
immigrants and X.qual are not included in an interaction with one another in the model.
Reproducible data
if (!"interactions" %in% installed.packages()) install.packages("interactions")
library(interactions)
ele = structure(list(vt_c = c(68.37056, 67.55938, 69.25354, 67.54727,
67.39343, 67.81161, 65.81312, 64.68675, 70.8572, 72.1439, 67.39006,
64.89897, 62.81833, 63.82975, 58.99062, 67.69617, 68.17096, 65.24267,
67.08106, 66.47592, 68.40781, 70.40636, 69.50657, 72.37613, 70.24236,
67.50159, 71.77177, 67.09047, 74.58491, 70.64892, 65.20199, 70.03566,
70.23142, 71.62487, 66.87982, 70.72528, 66.97507, 69.38713, 67.20061,
68.79907, 67.05735, 67.38101, 66.10595, 60.97635, 61.9047, 61.28828,
72.11577, 63.04311, 71.04747, 77.16823, 63.77144, 72.5249, 69.10145,
74.61647, 55.0847, 70.97664, 73.40273, 72.02715, 69.28485, 68.66256,
77.92079, 69.78192, 71.32363, 79.13777, 76.21347, 72.96919, 71.95923,
70.94545, 64.8141, 55.98621, 74.19439, 72.70276, 68.77999, 63.09397,
61.72898), Immigrants = c(57.3, 55.1, 50.6, 45.7, 42.8, 51.7,
51.2, 50.9, 44.9, 44.5, 44.3, 42.7, 50.5, 50.5, 39.2, 50.6, 39.7,
38.9, 39.2, 41.8, 42.5, 43.1, 39.5, 41.1, 44.2, 38.6, 41.8, 40.1,
43.8, 41.9, 38.2, 38.9, 37.5, 40.8, 33.2, 41.6, 38.1, 30, 38.8,
34.4, 36.5, 32.1, 41.3, 30.6, 32.9, 27.8, 35.4, 28.7, 37.1, 33.3,
29.8, 29.8, 33.8, 32.8, 28.8, 32.6, 31.6, 30.7, 28.6, 30.9, 34.7,
24.6, 24.7, 28.4, 26, 26.2, 27.4, 26.1, 22.6, 24.7, 32.4, 22.9,
26.4, 22.2, 22.1), X.qual = c(32.9, 29.8, 30.8, 32.5, 18.3, 47.3,
30.5, 29.8, 32.7, 38.5, 42.5, 25.8, 54.5, 52.2, 24.9, 29.3, 30.5,
23, 37.6, 22.3, 35.2, 54, 39.6, 42.8, 30.4, 41.5, 47.5, 44.5,
48.4, 31.3, 25.9, 28.2, 41.6, 46.5, 24.8, 36.3, 45.2, 27, 48.7,
40, 42.1, 19.7, 53.7, 26, 21.8, 12.1, 51.6, 19.2, 46.6, 54.4,
24.9, 30.1, 47.4, 51.4, 29.7, 57.4, 48.8, 47.6, 34.3, 22.8, 52,
21.8, 29.6, 55.2, 38.6, 37.4, 39.3, 25.9, 15.7, 19.8, 38.2, 39.3,
37.7, 18.3, 32.6)), class = "data.frame", row.names = c(NA, -75L
))
interact <- lm(vt_c ~ Immigrants:X.qual,
data = ele)
interact_plot(model = interact, pred=immigrants,
modx =X.qual, data = ele)
Thank you!