library(mlmRev)
## Loading required package: lme4
## Loading required package: Matrix
str(Contraception)
## 'data.frame':    1934 obs. of  6 variables:
##  $ woman   : Factor w/ 1934 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ district: Factor w/ 60 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ use     : Factor w/ 2 levels "N","Y": 1 1 1 1 1 1 1 1 1 1 ...
##  $ livch   : Factor w/ 4 levels "0","1","2","3+": 4 1 3 4 1 1 4 4 2 4 ...
##  $ age     : num  18.44 -5.56 1.44 8.44 -13.56 ...
##  $ urban   : Factor w/ 2 levels "N","Y": 2 2 2 2 2 2 2 2 2 2 ...
library(lme4)

model16 <- glmer(use ~ 1+age+I(age^2)+urban+livch+(1|district), Contraception, binomial)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : Model failed to converge with max|grad| = 0.0067612 (tol =
## 0.001, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: very large eigenvalue
##  - Rescale variables?
print(model16, corr=FALSE)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: use ~ 1 + age + I(age^2) + urban + livch + (1 | district)
##    Data: Contraception
##       AIC       BIC    logLik  deviance  df.resid 
##  2388.729  2433.267 -1186.364  2372.729      1926 
## Random effects:
##  Groups   Name        Std.Dev.
##  district (Intercept) 0.4752  
## Number of obs: 1934, groups:  district, 60
## Fixed Effects:
## (Intercept)          age     I(age^2)       urbanY       livch1  
##   -1.035027     0.003535    -0.004562     0.697285     0.814977  
##      livch2      livch3+  
##    0.916459     0.915027  
## convergence code 0; 2 optimizer warnings; 0 lme4 warnings
Contraception <- within(Contraception, ch <- factor(livch != 0, labels = c("N", "Y")))
model17 <- glmer(use ~ 1+age+I(age^2)+urban+livch+(1|district), Contraception, binomial)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge with max|grad| = 0.0067612 (tol = 0.001, component 1)

## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: very large eigenvalue
##  - Rescale variables?
print(model17, corr=FALSE)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: use ~ 1 + age + I(age^2) + urban + livch + (1 | district)
##    Data: Contraception
##       AIC       BIC    logLik  deviance  df.resid 
##  2388.729  2433.267 -1186.364  2372.729      1926 
## Random effects:
##  Groups   Name        Std.Dev.
##  district (Intercept) 0.4752  
## Number of obs: 1934, groups:  district, 60
## Fixed Effects:
## (Intercept)          age     I(age^2)       urbanY       livch1  
##   -1.035027     0.003535    -0.004562     0.697285     0.814977  
##      livch2      livch3+  
##    0.916459     0.915027  
## convergence code 0; 2 optimizer warnings; 0 lme4 warnings
anova(model17,model16)
## Data: Contraception
## Models:
## model17: use ~ 1 + age + I(age^2) + urban + livch + (1 | district)
## model16: use ~ 1 + age + I(age^2) + urban + livch + (1 | district)
##         Df    AIC    BIC  logLik deviance Chisq Chi Df Pr(>Chisq)
## model17  8 2388.7 2433.3 -1186.4   2372.7                        
## model16  8 2388.7 2433.3 -1186.4   2372.7     0      0          1