SAS Textbook Examples
Multilevel Analysis Techniques and
Applications by Joop Hox
Chapter 6: The Logistic Model for Dichotomous Data and Proportions
Table 6.1 on page 11 using Thai educational data.
Method 1: 1st order MQL using SAS proc glimmix
proc glimmix data = thaieduc method=mmpl noitprint; class repeat; model repeat (descending) = sex / dist=binary solution; random intercept /subject=schoolid; nloptions tech=dbldog; run;
The GLIMMIX Procedure
Convergence criterion (PCONV=1.11022E-8) satisfied.
Fit Statistics
-2 Log Pseudo-Likelihood 40985.43 Generalized Chi-Square 6980.42 Gener. Chi-Square / DF 0.81
Covariance Parameter Estimates
Standard Cov Parm Subject Estimate Error
Intercept SCHOOLID 1.1400 0.1094
Solutions for Fixed Effects
Standard Effect Estimate Error DF t Value Pr > |t|
Intercept -1.9594 0.07137 410 -27.45 <.0001 SEX 0.4668 0.06306 8170 7.40 <.0001
Type III Tests of Fixed Effects
Num Den Effect DF DF F Value Pr > F
SEX 1 8170 54.80 <.0001
Method 2: 2nd order PQL, not available in SAS yet. Here the 1st order PQL using %glimmix. The default is PQL estimation method.
%glimmix(data=thaiedu, procopt = noprofile covtest, stmts=%str( class schoolid; model repeat = sex / solution ; random intercept /subject = schoolid type=un; parms (.2) (1) /eqcons = 2; ), error=binomial, link=logit ); run;
Covariance Parameter Estimates
Standard Z Cov Parm Subject Estimate Error Value Pr Z UN(1,1) SCHOOLID 1.2954 0.1337 9.69 <.0001 Residual 1.0000 0 . .
Fit Statistics
-2 Res Log Likelihood 43757.8 AIC (smaller is better) 43759.8 AICC (smaller is better) 43759.8 BIC (smaller is better) 43763.8
Solution for Fixed Effects
Standard Effect Estimate Error DF t Value Pr > |t| Intercept -2.2822 0.07851 410 -29.07 <.0001 SEX 0.5271 0.06829 8170 7.72 <.0001
GLIMMIX Model Statistics
Description Value Deviance 5581.8160 Scaled Deviance 5581.8160 Pearson Chi-Square 6278.0716 Scaled Pearson Chi-Square 6278.0716 Extra-Dispersion Scale 1.0000
Method 3: Full ML, numerical intergration estimation technique using SAS nlmixed.
proc nlmixed data = thaiedu qpoints = 10; parms beta0=-2 beta1=.5 s2u=.2 ; eta = beta0 + beta1*sex + u; expeta = exp(eta); p = expeta/(1+expeta); model repeat ~ binary(p); random u ~ normal(0,s2u) subject=schoolid; run;
The NLMIXED Procedure
Specifications Data Set WORK.THAIEDU Dependent Variable REPEAT Distribution for Dependent Variable Binary Random Effects u Distribution for Random Effects Normal Subject Variable SCHOOLID Optimization Technique Dual Quasi-Newton Integration Method Adaptive Gaussian Quadrature
Dimensions Observations Used 8582 Observations Not Used 0 Total Observations 8582 Subjects 411 Max Obs Per Subject 41 Parameters 3 Quadrature Points 10
Parameters beta0 beta1 s2u NegLogLike -2 0.5 0.2 3337.38347 Fit Statistics -2 Log Likelihood 6368.3 AIC (smaller is better) 6374.3 AICC (smaller is better) 6374.3 BIC (smaller is better) 6386.3
Parameter Estimates Standard Parameter Estimate Error DF t Value Pr > |t| Alpha Lower Upper Gradient beta0 -2.4895 0.09092 410 -27.38 <.0001 0.05 -2.6682 -2.3107 -0.00044 beta1 0.5540 0.07016 410 7.90 <.0001 0.05 0.4161 0.6919 -0.00053 s2u 1.6882 0.1932 410 8.74 <.0001 0.05 1.3085 2.0679 -0.0001
Table 6.2 on page 116 using data set metaresp.sas7bdat.