The command predict <- ggpredict(fit_tw1, terms = "pko_dummy")
does not work and it gives me the following error. Do you know how to solve my problem?
Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) : factor as.factor(pa_dummy) has new level 0.0906593406593407
Can you help me?
Model: (The Model has fixed effects for countries (cown) and years (year))
fit_tw1 <- lm(parl_wom.per ~ as.factor(pko_dummy)*as.factor(pa_dummy) + as.factor(cown) + as.factor(year) + female_pko.per + lf_wom.per + ss.per + fdi.per + jud_ind.per + polity + as.factor(intensity_level) + as.factor(cons_ref),
data = subset(data9, rownames!="639"))
Reproducible sample of the dataset
structure(list(cown = c(432, 432, 432, 432, 432, 432, 432, 432,
432, 432, 432, 432, 432, 432, 432, 432, 432, 432, 432, 432),
year = c(1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
2008, 2009), intensity_level = c("1", "1", "0", "0", "1",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"1", "1", "1"), pa_dummy = c(0, 1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), pko_dummy = c(0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), parl_wom.per = c(NA,
NA, 0.023, 0.023, 0.023, 0.023, 0.023, 0.122449, 0.122449,
0.122449, 0.122449, 0.122449, 0.1020408, 0.1020408, 0.1020408,
0.1020408, 0.1020408, 0.1020408, 0.1020408, 0.1020408), exe_wom.per = c(0.0588235,
0.1052632, 0.0526316, 0.0952381, 0.1111111, 0.0555556, 0.125,
0.1176471, 0.2608696, 0.2727273, 0.45, 0.4210526, 0.15, 0.15,
0.15, 0.1923077, 0.1923077, 0.1923077, 0.1851852, 0.1785714
), gender_mean = c(0, 0, 1.75, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), gender_art = c(0, 0, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), female_pko.per = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
lf_wom.per = c(0.60855, 0.60834, 0.6082, 0.60815, 0.6082,
0.60838, 0.60806, 0.60798, 0.60804, 0.60811, 0.60813, 0.60782,
0.60752, 0.60725, 0.60701, 0.60681, 0.60616, 0.60564, 0.60525,
0.60495), ss.per = c(0.0679798984527588, 0.0723097991943359,
0.0827134037017822, 0.0837932968139648, 0.0957365036010742,
0.107322397232056, 0.112752199172974, 0.122838802337646,
0.133676099777222, 0.151076498031616, 0.174537200927734,
NA, NA, 0.221253795623779, 0.239939594268799, 0.25832540512085,
0.277074604034424, 0.303055400848389, 0.33731990814209, 0.36671989440918
), fdi.per = c(0.0021364, 0.0004424, -0.0077276, 0.001441,
0.0083661, 0.0411724, 0.009786, 0.0275705, 0.0032724, 0.0090061,
0.0203215, 0.0602065, -0.0031506, 0.0153489, 0.015555, 0.0256452,
0.0214593, 0.0252638, 0.0270809, 0.0631946), ele.sy = c(1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
polity = c(-7, NA, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
7, 7, 7, 7, 7), mus.per = c(0.944, 0.944, 0.944, 0.944, 0.944,
0.944, 0.944, 0.944, 0.944, 0.944, 0.944, 0.944, 0.944, 0.944,
0.944, 0.944, 0.944, 0.944, 0.944, 0.944), cons_ref = c(0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
jud_ind.per = c(0.476311308991478, 0.523786338536123, 0.557528417528326,
0.548066004702523, 0.548066004702523, 0.548066004702523,
0.548066004702523, 0.548066004702523, 0.548066004702523,
0.548066004702523, 0.548066004702523, 0.548066004702523,
0.548066004702523, 0.548066004702523, 0.548066004702523,
0.539288342106394, 0.539288342106394, 0.548066004702523,
0.539288342106394, 0.539288342106394)), row.names = c(NA,
-20L), class = c("tbl_df", "tbl", "data.frame"))