Proc glimmix for logistic regression has an lsmeans option

Thanks J for this info:

Use dist=binary and link=logit for logistic regressino using PROG GLIMMIX.

The lSMEANS statemetn is available from this and it produces probability scores. Use ilink option:

lsmeans &group / ilink ;

For difference in the groups, you use the DIFF option on the LSMEANS statement. The results are also on the logit scale. If you use the OR option, you will get the odds ratios for the group effect --

lsmeans &group /diff or;

Unfortunately, the difference in the probability scale between the groups are not directly available in PROC GLIMMIX. The magnitude of the difference is easy to compute -- you use the results from the ILINK option output, which gives you the estimated probabilities in each group, and compute the difference by hand or by using a data step, however, the appropriate standard errors for these differences are not available in PROC GLIMMIX.

How to explain HLM (response to an email)

Hello XXX, thanks for your email! I recently taught a premier for HLM, so I hope I can update my website with new material.

This time, I tried to say that HLM is simple, but equations make it difficult to learn (which is also the case for learning music instruments, like piano).

In the attached graph, I tried to compare my intuitive model (mental representation model) and a formal equation. When it is in my mind, coefficients are either random (red font) or fixed (blue). The red coefficients are adjusted for precision/reliability, while the blue ones are not (like OLS coefficients). I tried to show how the equation expresses the same idea, but I feel it quickly gets annoying.

HLM slide sample

Logistic regression and and comparison of group means in the model (using PROC GLIMMIX)

For logistic regression models in PROC GLIMMIX, you need to use dist=binary link=logit option on the MODEL statement (sorry I missed pointing this out in your program in my previous response). So please add these two options.

For logistic regression models, the estimations are all on the logit scale, so is the LSMEANS statement. To get the lsmeans on the original scale (the probability scale), you can use the ILINK option --

 

lsmeans &group / ilink ;

 

For difference in the groups, you use the DIFF option on the LSMEANS statement. The results are also on the logit scale. If you use the OR option, you will get the odds ratios for the group effect --

lsmeans &group /diff  or;

Unfortunately, the difference in the probability scale between the groups are not directly available in PROC GLIMMIX. The magnitude of the difference is easy to compute -- you use the results from the ILINK option output, which gives you the estimated probabilities in each group, and compute the difference by hand or by using a data step, however, the appropriate standard errors for these differences are not available in PROC GLIMMIX.

Thanks, JT.

Example: how to use ODS in PROC GLIMMIX or other procs

/*Use proc GLIMMIX to run an OLS regression
and saves results (parameter estiamtes) in a
data set named "john" using ODS*/
proc glimmix data=sashelp.class;
model height=weight /dist=normal link=identity solution;
ods output ParameterEstimates=john;
run;
/*Edit the result data*/
data john2;set john;

/*Create a new variable that indicates
the level of significance*/

/*Do not forget to specify a value length*/
length asterisk $ 3;

if Probt < 0.10 then asterisk="~";
if Probt < 0.05 then asterisk="*";
if Probt < 0.01 then asterisk="**";
if Probt < 0.001 then asterisk="***";

run;

/NOW FIND john2 in a work directory and right-click it
to open with Excel*/

/*You can also see this by PROC PRINT*/
proc print data=john2;
run;