I estimated a cross-classified logistic mixed model in R, with two types of level-2 subjects: 34 election dates and 408 municipalities. The level 1 observations are aggregated proportions of the voter turnout (dependent) and 2 independent variables. Then there are some characteristics on the election dates and some controls. I estimated cross-level interactions between the main independent variables and the types of elections (macro-level characteristic of election date). Therefore, the effects were estimated as random over election dates. Now I would like to plot the random effects: 34 regression lines in a plot, being of 4 different colors (according to the macro-level: the different types of elections).
Does anyone know how to plot such a thing in R?
UPDATE: Thanks for the hints! I'm quite new to R. I know how to estimate my models, but apart from that I still have a lot to learn.
This is my final model. "gemnr" is the municipality level. "Date" is the election date I was talking about. "Windchill" and "Rain" are the random effects over "Date", and are interacted with three types of elections "Provincie" "Gemeente" and "Europa". The rest of the variables are controls. The dependent variable is the real proportion of voters: cbind(opkomst, nnietgestemd), which stands for the number of votes(opkomst) and the number of non-voters (nnietgestemd).
# Model with controls and interactions.
model3b <- glmer (cbind(opkomst, nnietgestemd) ~
(1|gemnr)+(1+Windchill+Rain|Date) + Windchill + Windspeed + Rain + SP + lag_popkomst + Provincie + Gemeente + Europa + NB + OL + loginw
+ Provincie:Windchill + Gemeente:Windchill + Europa:Windchill + Provincie:Rain + Gemeente:Rain + Europa:Rain, family=binomial(link=logit))
And this is the result:
Generalized linear mixed model fit by maximum likelihood ['glmerMod']
Family: binomial ( logit )
Formula: cbind(opkomst, nnietgestemd) ~ (1 | gemnr) + (1 + Windchill + Rain | Date) + Windchill + Windspeed + Rain + SP + lag_popkomst + Provincie + Gemeente + Europa + NB + OL + loginw + Provincie:Windchill + Gemeente:Windchill + Europa:Windchill + Provincie:Rain + Gemeente:Rain + Europa:Rain
AIC BIC logLik deviance
1452503.3 1452691.4 -726226.6 1452453.3
Random effects:
Groups Name Variance Std.Dev. Corr
gemnr (Intercept) 0.0146186 0.12091
Date (Intercept) 0.1902650 0.43619
Windchill 0.0009727 0.03119 -0.07
Rain 0.0103655 0.10181 0.59 -0.10
Number of obs: 13735, groups: gemnr, 408; Date, 34
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.23067667 0.12124970 -1.9 0.057107 .
Windchill -0.00768949 0.00834125 -0.9 0.356600
Windspeed 0.01040831 0.00017884 58.2 < 0.0000000000000002 ***
Rain -0.00157012 0.02908864 -0.1 0.956953
SP 0.00045626 0.00001432 31.9 < 0.0000000000000002 ***
lag_popkomst 2.10911785 0.00386440 545.8 < 0.0000000000000002 ***
Provincie -1.09414033 0.25162607 -4.3 0.00001372100383 ***
Gemeente -0.60849053 0.18353633 -3.3 0.000915 ***
Europa -1.21169484 0.21694178 -5.6 0.00000002332356 ***
NB 0.07397575 0.01053297 7.0 0.00000000000217 ***
OL 0.00288172 0.00821660 0.4 0.725799
loginw -0.10297623 0.00721768 -14.3 < 0.0000000000000002 ***
Windchill:Provincie 0.01743852 0.01769197 1.0 0.324293
Windchill:Gemeente 0.01010439 0.01292002 0.8 0.434172
Windchill:Europa 0.01664707 0.01522839 1.1 0.274323
Rain:Provincie -0.13692131 0.05956872 -2.3 0.021531 *
Rain:Gemeente -0.03330741 0.04340056 -0.8 0.442819
Rain:Europa -0.04864840 0.05142619 -0.9 0.344156
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1