Reputation: 123
I am trying to perform a 3-level multilevel model to identify factors that shape practice; Zone Level, HH level, and Individual level.
Here is a snip of my dataset
ZoneID Zone HouseID Access PersonID Age Gender Education Practice
UZ Urban HH1 No P1 31 Female Secondary No
UZ Urban HH2 No P2 33 Female Tertiary No
UZ Urban HH3 Yes P3 44 Female Tertiary Yes
UZ Urban HH4 No P4 28 Male Tertiary No
UZ Urban HH5 Yes P5 38 Female Tertiary No
UZ Urban HH6 No P6 33 Female Secondary No
UZ Urban HH7 Yes P7 45 Female Secondary Yes
UZ Urban HH8 Yes P8 20 Female Secondary No
UZ Urban HH9 Yes P9 44 Female Tertiary No
UZ Urban HH9 Yes P10 19 Female Primary No
UZ Urban HH10 No P11 26 Female Secondary No
UZ Urban HH10 No P12 26 Female Secondary No
UZ Urban HH10 No P13 32 Male Secondary No
UZ Urban HH11 No P14 25 Female Secondary No
UZ Urban HH11 No P15 36 Male Secondary No
UZ Urban HH12 Yes P16 47 Female Secondary Yes
UZ Urban HH13 Yes P17 24 Female Secondary Yes
UZ Urban HH13 Yes P18 38 Female Secondary Yes
UZ Urban HH13 Yes P19 23 Female Secondary Yes
UZ Urban HH13 Yes P20 46 Male Secondary No
UZ Urban HH13 Yes P21 45 Male Secondary No
UZ Urban HH13 Yes P22 40 Male Secondary No
UZ Urban HH14 Yes P23 53 Female Secondary No
UZ Urban HH15 Yes P24 64 Female Tertiary Yes
UZ Urban HH15 Yes P25 68 Male Tertiary No
UZ Urban HH16 Yes P26 55 Female No education Yes
UZ Urban HH17 Yes P27 28 Female Secondary Yes
UZ Urban HH18 Yes P28 56 Female Secondary No
UZ Urban HH19 Yes P29 39 Female Tertiary Yes
UZ Urban HH19 Yes P30 46 Male Secondary No
UZ Urban HH19 Yes P31 11 Male Primary No
UZ Urban HH20 Yes P32 57 Female Secondary Yes
UZ Urban HH20 Yes P33 54 Female Tertiary Yes
UZ Urban HH20 Yes P34 28 Female Tertiary Yes
UZ Urban HH20 Yes P35 13 Female Primary Yes
UZ Urban HH20 Yes P36 10 Male Primary No
UZ Urban HH20 Yes P37 23 Male Primary No
UZ Urban HH21 Yes P38 42 Female Tertiary No
UZ Urban HH21 Yes P39 37 Male Tertiary No
UZ Urban HH22 Yes P40 43 Male Secondary No
PUZ Peri-urban HH23 Yes P41 78 Female No education Yes
PUZ Peri-urban HH23 Yes P42 36 Female Secondary Yes
PUZ Peri-urban HH23 Yes P43 16 Female Secondary Yes
PUZ Peri-urban HH23 Yes P44 15 Female Primary Yes
PUZ Peri-urban HH23 Yes P45 80 Male Primary No
PUZ Peri-urban HH23 Yes P46 14 Male Primary No
PUZ Peri-urban HH24 Yes P47 76 Female Tertiary Yes
PUZ Peri-urban HH24 Yes P48 34 Female Tertiary Yes
PUZ Peri-urban HH25 Yes P49 73 Female Tertiary Yes
PUZ Peri-urban HH25 Yes P50 29 Female Secondary Yes
PUZ Peri-urban HH25 Yes P51 10 Female Secondary Yes
PUZ Peri-urban HH26 Yes P52 77 Female Tertiary Yes
PUZ Peri-urban HH26 Yes P53 15 Female Secondary Yes
PUZ Peri-urban HH26 Yes P54 13 Female Primary Yes
PUZ Peri-urban HH26 Yes P55 13 Female Primary Yes
PUZ Peri-urban HH26 Yes P56 10 Female Primary No
PUZ Peri-urban HH26 Yes P57 30 Male Tertiary No
PUZ Peri-urban HH26 Yes P58 24 Male Tertiary No
PUZ Peri-urban HH26 Yes P59 44 Male Secondary No
PUZ Peri-urban HH27 Yes P60 50 Female Secondary Yes
PUZ Peri-urban HH27 Yes P61 21 Male Secondary No
PUZ Peri-urban HH28 Yes P62 48 Female Secondary Yes
PUZ Peri-urban HH28 Yes P63 64 Male Primary No
PUZ Peri-urban HH29 Yes P64 63 Female Secondary Yes
PUZ Peri-urban HH29 Yes P65 15 Female Primary Yes
PUZ Peri-urban HH29 Yes P66 14 Female Primary Yes
PUZ Peri-urban HH29 Yes P67 10 Female Primary Yes
PUZ Peri-urban HH29 Yes P68 43 Male Primary Yes
PUZ Peri-urban HH29 Yes P69 23 Male Primary Yes
PUZ Peri-urban HH30 Yes P70 60 Female Tertiary Yes
PUZ Peri-urban HH30 Yes P71 37 Female No education Yes
PUZ Peri-urban HH31 Yes P72 44 Male Primary Yes
PUZ Peri-urban HH32 Yes P73 55 Female Secondary Yes
PUZ Peri-urban HH32 Yes P74 52 Female Tertiary Yes
PUZ Peri-urban HH32 Yes P75 26 Female Secondary Yes
PUZ Peri-urban HH32 Yes P76 18 Female Primary Yes
PUZ Peri-urban HH32 Yes P77 18 Female Secondary Yes
PUZ Peri-urban HH32 Yes P78 53 Male Primary Yes
PUZ Peri-urban HH33 Yes P79 49 Female Secondary Yes
PUZ Peri-urban HH33 Yes P80 50 Male Secondary No
PUZ Peri-urban HH34 Yes P81 72 Female Primary Yes
PUZ Peri-urban HH34 Yes P82 66 Female Primary Yes
PUZ Peri-urban HH34 Yes P83 39 Female Secondary Yes
PUZ Peri-urban HH34 Yes P84 25 Female Tertiary Yes
PUZ Peri-urban HH34 Yes P85 27 Male Secondary No
PUZ Peri-urban HH34 Yes P86 11 Male Primary No
PUZ Peri-urban HH35 Yes P87 29 Female Tertiary Yes
PUZ Peri-urban HH35 Yes P88 59 Male No education No
PUZ Peri-urban HH36 Yes P89 44 Female Secondary Yes
PUZ Peri-urban HH36 Yes P90 13 Female Primary Yes
PUZ Peri-urban HH37 Yes P91 88 Female Primary Yes
PUZ Peri-urban HH37 Yes P92 45 Female Secondary Yes
PUZ Peri-urban HH37 Yes P93 10 Female Primary Yes
PUZ Peri-urban HH37 Yes P94 87 Male Primary No
PUZ Peri-urban HH37 Yes P95 11 Male Primary No
RZ Rural HH38 Yes P96 62 Female Secondary Yes
RZ Rural HH38 Yes P97 28 Female Tertiary Yes
RZ Rural HH38 Yes P98 21 Male Secondary Yes
RZ Rural HH38 Yes P99 18 Male Primary Yes
RZ Rural HH38 Yes P100 13 Male Primary No
RZ Rural HH39 Yes P101 65 Female Secondary Yes
RZ Rural HH39 Yes P102 66 Male Secondary No
RZ Rural HH39 Yes P103 20 Male Primary No
RZ Rural HH39 Yes P104 16 Male Secondary No
RZ Rural HH40 No P105 30 Female Secondary No
RZ Rural HH40 No P106 18 Female Secondary No
RZ Rural HH40 No P107 38 Male Secondary No
RZ Rural HH41 Yes P108 96 Female No education Yes
RZ Rural HH41 Yes P109 85 Female No education Yes
RZ Rural HH41 Yes P110 57 Female Tertiary Yes
RZ Rural HH41 Yes P111 28 Female Secondary Yes
RZ Rural HH41 Yes P112 15 Female Secondary Yes
RZ Rural HH41 Yes P113 12 Female Primary Yes
RZ Rural HH41 Yes P114 37 Male Secondary Yes
RZ Rural HH41 Yes P115 32 Male Secondary Yes
RZ Rural HH41 Yes P116 15 Male Secondary Yes
RZ Rural HH42 Yes P117 80 Female No education Yes
RZ Rural HH42 Yes P118 40 Female Secondary Yes
RZ Rural HH42 Yes P119 39 Male Secondary No
RZ Rural HH43 Yes P120 33 Female Secondary Yes
I have been trying to find a code that I can relate to and build on to address my research question with no success.
This is what I have done but it does not seem to be complete as it appears to only have the individual level, which I am not sure is analyse properly too, and I am unsure of how to reproduce the model for the three levels, to include the HH and Zone level:
model <- glmer(
Practice ~ Age + Gender + Education + (1 | ZoneID/HouseID),
data = OshingaliMLM,
family = binomial(link = "logit")
The results:
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: binomial ( logit )
Formula: Practice ~ Zone + Access + Marketing + Age + Gender + Education + Employnment + (1 | ZoneID/HouseID)
Data: OshingaliMLM
AIC BIC logLik deviance df.resid
240.4 304.6 -104.2 208.4 393
Scaled residuals:
Min 1Q Median 3Q Max
-6.9779 -0.0132 0.0112 0.1063 2.6693
Random effects:
Groups Name Variance Std.Dev.
HouseID:ZoneID (Intercept) 1.517e+01 3.8946
ZoneID (Intercept) 3.961e-04 0.0199
Number of obs: 409, groups: HouseID:ZoneID, 120; ZoneID, 4
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -4.31056 11.01055 -0.391 0.69543
ZoneRemote rural 2.91666 1.88224 1.550 0.12124
ZoneRural 0.13047 1.57362 0.083 0.93392
ZoneUrban -6.59533 2.24895 -2.933 0.00336 **
AccessYes 19.19813 24.22117 0.793 0.42800
MarketingYes -12.09891 26.44908 -0.457 0.64735
Age 0.01981 0.03214 0.616 0.53760
GenderMale -8.89134 1.72704 -5.148 2.63e-07 ***
EducationPrimary 1.62540 1.39860 1.162 0.24517
EducationSecondary 2.78063 1.51940 1.830 0.06724 .
EducationTertiary 3.48391 2.05194 1.698 0.08953 .
EmploynmentLeaners 1.89690 2.28033 0.832 0.40549
EmploynmentPensioners -1.09713 2.11383 -0.519 0.60374
EmploynmentUnemployed 2.49564 1.95557 1.276 0.20189
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation matrix not shown by default, as p = 14 > 12.
Use print(x, correlation=TRUE) or
vcov(x) if you need it
optimizer (Nelder_Mead) convergence code: 4 (failure to converge in 10000 evaluations)
Model failed to converge with max|grad| = 0.753382 (tol = 0.002, component 1)
Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?
failure to converge in 10000 evaluations
Upvotes: 1
Views: 69