Proc mixed and Proc glimmix produce identical results

PROC MIXED and PROC GLIMMIX produce identical results for the following linear model settings.

proc glimmix data=kaz.asdf;
where IMPACT_ANALYSIS=1;
class school;
model
y =
x1 x2 x3
/solution ddfm=kr dist=normal link=identity s ;
random school;
run;

proc mixed data=kaz.asdf;
where IMPACT_ANALYSIS=1;
class school;
model
y =
x1 x2 x3
/solution s ddfm=kr;
random school;
run;

How to derive subgroup adjusted outcome averages and conduct pairwise stat-test

When you run a statistical interaction model (e.g., Y=TREATMENT + GENDER + TREATMENT*GENDER), you also want to run a mathematically equivalent model:
Y= T_MALE + C_MALE + T_FEMALE + C_FEMALE.

SUBGROUP defines the four groups below.

This is for linear model (HLM because I have the random statement).  

proc glimmix data=asdf3 namelen=32;
class CAMPUSID  SUBGROUP;
model y=
x1 x2 x3
SUBGROUP
/solution ddfm=kr dist=normal link=identity s noint;
lsmeans SUBGROUP / ilink diff;
random int / subject = CAMPUSID;
ods output ModelInfo=x1var1 ParameterEstimates=x2var1 CovParms=x3var1
nobs=x4var1 Diffs=DIF_RESULT1;
run;

This is for logistic regression model.  

proc glimmix data=asdf METHOD=RSPL;
class CAMPUS_14 subgroup;
model y=x1 x2 x3 subgroup
/dist=binomial link=logit s ddfm=kr;
lsmeans group / ilink diff;
ods output  ModelInfo=x1var1 ParameterEstimates=x2var1 CovParms=x3var1
Diffs=DIF_RESULT1 LSMeans=LS1;
run;

Automate the choice between HLM and non-HLM

When running PROC GLIMMIX (SAS) in a macro-driven way (e.g., running similar models 100 times), what gets annoying is some HLM models do not converge and you have to comb through output and decide which models to convert to fixed effect models, which is simpler and is easier to converge.   The following allows the execution of a fixed model (non-HLM) when a random effect model (HLM) fails.

The following macro (%mend checkds;) checks if the first random effect model produces one of the result files (parameter estimates) and if it doesn't exist (i.e., random effect model did not converge), it will run the model without the random effect statement.

 

proc glimmix data=asdf METHOD=RSPL;
class CAMPUS_14;
model &out = &main

stud_char
interX

&predictors
/dist=binomial link=logit s ddfm=kr STDCOEF;
random int / subject = CAMPUS_14;
covtest /wald;
ods output
ParameterEstimates=kaz1
CovParms=uekawa1
ModelInfo=estes
dimensions=diminfo
ConvergenceStatus=concon
FitStatistics=FITSTAT

;
run;

data hlm1;
hlm1="HLM ";
run;

/*Check if converged and if not run fixed model*/
%macro checkds(dsn);
%if %sysfunc(exist(&dsn)) %then %do;
/*there is concon created*/
%end;
%else %do;
/*delete imcomplete data from the previous proc
that did not converge*/
proc datasets;
delete kaz1 estes diminfo concon FITSTAT hlm1;
run;

proc glimmix data=asdf METHOD=RSPL;
class CAMPUS_14;
model &out = &main
stud_char
interX
&predictors
/dist=binomial link=logit s ddfm=kr;
ods output
ParameterEstimates=kaz1
/*CovParms=uekawa1*/
/*nobs=jeana */
ModelInfo=estes
dimensions=diminfo
/*ConvergenceStatus=concon*/
FitStatistics=FITSTAT;
run;

data hlm1;
hlm1="Fixed";
run;

%end;
%mend checkds;
/* Invoke the macro, pass a non-existent data set name to test */
*%checkds(work.concon);
*%checkds(work.uekawa1);
%checkds(work.FITSTAT);

STDCOEF to request standardized coefficients from PROC GLIMMIX

proc glimmix data=qc2 METHOD=RSPL;
class group_ID;
model Y = X
/dist=binomial link=logit s ddfm=kr STDCOEF;
run;

It is not clear how coefficients are standardized.  Based on my investigation, centering is definitely done around the variable's grand mean; however, SD used for standardization is not 1.  When I simulated it, SD was around 0.036 (meaning I created a z-score using mean=0 and STD=0.036 to get the same coefficient off STDCOEF,

Stat test on between-group variance

proc glimmix data=temp2 /*Method=RSPL*/ ;
class  CAMPUS;
model Y=/dist=binomial link=logit s ddfm=kr;
random int / subject = CAMPUS_14;
  covtest /wald;
output out=gmxout_alglog residual=resid;
RUN;

PROC GLIMMIX non-convergence problem solutions

Tips and Strategies for Mixed Modeling with SAS/STAT® Procedures Kathleen Kiernan, Jill Tao, and Phil Gibbs, SAS Institute Inc., Cary, NC, USA

ABSTRACT Inherently, mixed modeling with SAS/STAT® procedures, such as GLIMMIX, MIXED, and NLMIXED is computationally intensive. Therefore, considerable memory and CPU time can be required. The default algorithms in these procedures might fail to converge for some data sets and models. This paper provides recommendations for circumventing memory problems and reducing execution times for your mixed modeling analyses. This paper also shows how the new HPMIXED procedure can be beneficial for certain situations, as with large sparse mixed models. Lastly, the discussion focuses on the best way to interpret and address common notes, warnings, and error messages that can occur with the estimation of mixed models in SAS software.

http://support.sas.com/resources/papers/proceedings12/332-2012.pdf

glimmix data=xxx METHOD=RSPL  ITDETAILS;
class  xxx;
model xxx=  xxx
/dist=binomial link=logit s ddfm=kr;
random int / subject = xxx;
NLOPTIONS MAXITER=100;
run;

Tables available from PROC GLIMMIX

Output Added:
-------------
Name: ModelInfo
Label: Model Information
Template: Stat.Glimmix.ModelInfo
Path: Glimmix.ModelInfo
-------------

Output Added:
-------------
Name: ClassLevels
Label: Class Level Information
Template: Stat.Glimmix.ClassLevels
Path: Glimmix.ClassLevels
-------------

Output Added:
-------------
Name: NObs
Label: Number of Observations
Template: Stat.Glimmix.NObs
Path: Glimmix.NObs
-------------

Output Added:
-------------
Name: Dimensions
Label: Dimensions
Template: Stat.Glimmix.Dimensions
Path: Glimmix.Dimensions
-------------

Output Added:
-------------
Name: OptInfo
Label: Optimization Information
Template: Stat.Glimmix.OptInfo
Path: Glimmix.OptInfo
-------------

Output Added:
-------------
Name: IterHistory
Label: Iteration History
Template: Stat.Glimmix.IterHistory
Path: Glimmix.IterHistory
-------------
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: At least one element of the gradient is greater than 1e-3.

Output Added:
-------------
Name: ConvergenceStatus
Label: Convergence Status
Template: Stat.Glimmix.ConvergenceStatus
Path: Glimmix.ConvergenceStatus
-------------

Output Added:
-------------
Name: FitStatistics
Label: Fit Statistics
Template: Stat.Glimmix.FitStatistics
Path: Glimmix.FitStatistics
-------------

Output Added:
-------------
Name: CovParms
Label: Covariance Parameter Estimates
Template: Stat.Glimmix.CovParms
Path: Glimmix.CovParms
-------------

Output Added:
-------------
Name: ParameterEstimates
Label: Solutions for Fixed Effects
Template: Stat.Glimmix.ParameterEstimates
Path: Glimmix.ParameterEstimates
-------------

Output Added:
-------------
Name: Tests3
Label: Type III Tests of Fixed Effects
Template: Stat.Glimmix.Tests3
Path: Glimmix.Tests3
-------------

SAS PROC GLIMMIX method=

The default technique is METHOD=RSPL, corresponding to maximizing the residual log pseudo-likelihood with an expansion about the current solutions of the best linear unbiased predictors of the random effects. In models for normal data with identity link, METHOD=RSPL and METHOD=RMPL are equivalent to restricted maximum likelihood estimation, and METHOD=MSPL and METHOD=MMPL are equivalent to maximum likelihood estimation.

***

The following SAS Usage Note:

  http://support.sas.com/kb/37107 

  http://support.sas.com/kb/40724

 

provide information on testing covariance parameters when using PROC MIXED and PROC GLIMMIX.

 

Logistic regression, comparing group means

proc glimmix data=asdf namelen=32;
where disaster_type /*age_desc*/ ne "";
class GROUPING_D_RISK_PT;

model &out
=
GROUPING_D_RISK_PT

/solution ddfm=kr dist=binomial link=logit s STDCOEF ;

lsmeans GROUPING_D_RISK_PT / ilink diff;

output out=gmxout residual=resid;
ods output
ParameterEstimates=kaz1
CovParms=uekawa1
nobs=jeana
ModelInfo=estes
dimensions=diminfo
ConvergenceStatus=concon
FitStatistics=FITSTAT
Diffs=DIF_RESULT
;
run;