I get an error message when fitting a full random two-level null model with the package R2MLwiN
. My dataframe is a subset of a Multiple Indicator Cluster Survey developed by UNICEF for Mozambique. My response variable is agem.18
a binary ("Yes", "No")
indicating whether the woman got married before the age of 18 y.o. or not.
> table(moz.20$agem.18, useNA = "ifany")
No Yes
5934 5405
My two levels are, in descending order, province
and w.id
. This is the code I run
# Random effect
F1 <- logit(agem.18) ~ 1 + (1 | province) + (1 | w.id)
rand.eff <- runMLwiN(Formula = F1, D = "Binomial", data = moz.20)
This is the error message I get
Invalid link function specified: NA
Error in runMLwiN(Formula = F1, D = "Binomial", data = df) :
I initially thought that the logit
function was masked by the car
package, but this is not the case. I also thought that the proble was in the denom
call in the link function, but I read that R2MLwiN should automatically create the denom
as a set of 1s. I do not get any error if I use the package lme4
with the same data, variable and levels:
(fit <- glmer(agem.18 ~ 1 + (1 | province), family = binomial("logit"), data = moz.20)
Generalized linear mixed model fit by maximum likelihood (Laplace
Approximation) [glmerMod]
Family: binomial ( logit )
Formula: agem.18 ~ 1 + (1 | province)
Data: moz.20
AIC BIC logLik deviance df.resid
14907.498 14922.170 -7451.749 14903.498 11337
Random effects:
Groups Name Std.Dev.
province (Intercept) 0.5366
Number of obs: 11339, groups: province, 11
Fixed Effects:
(Intercept)
-0.04992
I do not encounter the same problem if I use a very similar formula included in the demo UserGuide09.R
for the package R2MLwiN
.
(mymodel1 <- runMLwiN(logit(use) ~ 1 + lc, D = "Binomial", data = bang))
My only guess at the moment is that for some reasons, R2MLwiN
fails to recognise my response variable agem.18
as binary.
Any suggestion?
Thanks
Manolo