Programming the statistical procedures from SAS

linear combinations in mixed models

Reply
New Contributor
Posts: 2

linear combinations in mixed models

Does anyone know how to create linear combinations using proc mixed or plm? In Stata, the syntax is lincom.

For example, if you were to model the change in gallons of ice cream consumed for 6 months in a particular population, with data collected at each month. Contrast and lsmestimates can be used to compare the predicted means for each month (ie ice cream at 1 vs 2 months), but how can I test if the change from 1 to 2 months is different from the change from 2 to 3 months. The basic model would be:

proc mixed data=heatwave;

class id month;

model icecream=month;

random int /subject=id;

run;

Respected Advisor
Posts: 2,655

Re: linear combinations in mixed models

LSMESTIMATES are additve, so for your example, in GLIMMIX, I would have something like:

proc glimmix data=heatwave;

class id month;

model icecream=month;

random month/residual type=ar(1) subject=id;

random int / subject=id;

lsmestimate month 'Month 2 minus Month 1' -1 1 0 0 0 0,

                             'Month 3 minus Month 2' 0 -1 1 0 0 0,

                             'Difference' 1 -2 1 0 0 0;

run;

In this case, I just subtracted the first line from the second.  This could be extended as needed.

Steve Denham

Message was edited by: Steve Denham

New Contributor
Posts: 2

Re: linear combinations in mixed models

Aha! I knew it had to be something simple. Thanks!

Ask a Question
Discussion stats
  • 2 replies
  • 241 views
  • 0 likes
  • 2 in conversation