BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
CrystalS1
Fluorite | Level 6

Hi SAS users,

 

I am using proc glimmix to fit a 3-level mixed effects model with a continuous outcome, 2 binary independent variables(var1: 1 vs 0, var2: 1 vs 0), and their interaction. I want to estimate the effect of var1 when var2 =1, and the effect of var1 when var2=0. But the estimate gave nothing in the outputs, could you please let me know what I did wrong in the following codes:

 

 

proc glimmix data = data;
class level3_ID level2_ID var1(ref='0') var2(ref='0');
model y = var1 var2  var1* var2/solution cl;
random intercept/type = un subject = level3_ID;
random intercept/type = un subject = level2_ID(level3_ID);

estimate "effect estimate of var1 when var2 = 1" var1 1 0 var1*var2 1 0 0 0 /cl;

estimate "effect estimate of var1 when var2 = 0" var1 1 0 var1*var2 0 0 1 0 /cl;

run;

 

If proc genmod can do the same thing, it would be better, as the normality may not hold. But I am not sure how to do the 3-level model in proc genmod with a continuous outcome.

 

Any help would be greatly appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

Does this do what you want?

 

estimate "effect estimate of var1 when var2 = 1" 
    var1 1 -1 
    var1*var2 0 1 0 -1 / cl;
estimate "effect estimate of var1 when var2 = 0" 
    var1 1 -1
    var1*var2 1 0 -1 0 / cl;

 

Unsolicited input: Do you really want to use TYPE=UN on your random statements? In most scenarios with nested subjects, I would not think so.

View solution in original post

3 REPLIES 3
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

Does this do what you want?

 

estimate "effect estimate of var1 when var2 = 1" 
    var1 1 -1 
    var1*var2 0 1 0 -1 / cl;
estimate "effect estimate of var1 when var2 = 0" 
    var1 1 -1
    var1*var2 1 0 -1 0 / cl;

 

Unsolicited input: Do you really want to use TYPE=UN on your random statements? In most scenarios with nested subjects, I would not think so.

CrystalS1
Fluorite | Level 6

Thanks so much!  The code works very well, only need to switch the titles.

 

Could you please let me know how you got the values for the interactions:  0 1 0 -1 and 1 0 -1 0?  I really want to figure out the rule.

 

For Type=UN, is there any disadvantage using this for nested clusters? Should I use CHOL or CS instead?

 

Many thanks!

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

Ah, yes, changing the reference levels for var1 and var2 will change the order of the coefficients. My apologies, I overlooked that.

 

See http://support.sas.com/kb/24/447.html for a tutorial on writing estimate and contrast statements. The LSMESTIMATE statement allows you to write estimate statements using lsmeans instead of parameters; see https://support.sas.com/resources/papers/proceedings11/351-2011.pdf

 

Using type=un does not produce wrong results, but if you look at the "Covariance Parameter Estimates" table, you will see that there is only one variance estimate for each level and as such there is no need to estimate covariances. Using type=un suggests that you might not understand the usage of the random statement as well as you might want to.

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 3749 views
  • 0 likes
  • 2 in conversation