turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Multilevel analysis with two levels and two contro...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-19-2013 10:10 AM

Hello,

I'm about to perform an analysis with two levels, something I have never done before in SAS and to be honest it's been a couple of years since my last multilevel analysis.

I have to levels, REGIONAL and LOCAL, where the latter is (obviously) a subgroup of the former. My dependent variable is Y and my control variables are A and B, i. e. y = intercept + a + b + error, on two levels.

I want both the intercept and the coefficients to be "random", and when I have done that I want to be able to measure the adjusted explanatory power on both levels in order to find out how much is explained on each level. I could settle with just letting the intercept vary.

I have given it a couple of shots with PROC GLM and PROC GLIMMIX and PROC MIXED but I haven't done it right yet because my outputs look weird and my results are completely ridiculous.

What code would you use?

Merry xmas to you, fellow SAS-users!

O

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to oskarseriksson

12-19-2013 12:39 PM

Depending on the characteristics of the dependent variable Y, I would use either PROC MIXED or PROC GLIMMIX, and since you can do almost everything that MIXED does in GLIMMIX, plus more, I offer the following code;

proc glimmix data=yourdata;

class A B regional local subjid; /* Assumes that the control variables are categorical. If not, we will address as you provide more information */

model y=A B A*B/solution; /* Fixed effects */

random regional regional*local/subject=subjid s; /* Multiple level data random effects */

random intercept A B A*B/subject=subjid(regional local) s; /*Random slopes and intercepts for the control variables and their interaction */

Good luck.

Steve Denham

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SteveDenham

12-20-2013 07:17 AM

Hi Steve!

Y is continuous. The control variables A and B are also continuous.

I'll start with the code you provided and I look forward to more input from you! You are really helpful and I appreciate it.

On the future results of this analysis; need any of the variables be normally distributed or is it just the residuals that need be normally distributed? I have heard different opinions from fellow statisticians.

Happy holidays,

Oskar

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to oskarseriksson

12-20-2013 11:00 AM

Well, if A and B are both continuous, that does change some things. Any interaction would have to be created in a programming step.

New (untested) code:

proc glimmix data=yourdata;

AB=A*B;

class regional local subjid; /* Assumes that the control variables are categorical. If not, we will address as you provide more information */

model y=A B AB/solution; /* Fixed effects */

random regional regional*local/subject=subjid s; /* Multiple level data random effects */

random intercept A B AB/subject=subjid(regional local) s; /*Random slopes and intercepts for the control variables and their interaction */

run;

I would strongly suggest zero centering A and B in a data step prior to the proc, and if you are going to do that, you might as well define AB in the data step as the product of the zero centered A and B.

Steve Denham

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SteveDenham

01-02-2014 09:15 AM

Hi!

I used the PROC MIXED-code provided in the paper Adam1 referred to, and it worked. For some reason, I never got the interactions to work out when I used the code you wrote. Odd. However, the control variables weren't crucial to my analysis as I was mainly looking for the explained variation in one of my levels.

Thanks for being helpful!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to oskarseriksson

12-28-2013 05:34 AM

Among many tutorials on this topic, I think you would find this one helpfull: http://support.sas.com/resources/papers/proceedings13/433-2013.pdf

It describes multilevel models in proc mixed with 4 examples, both organizational and growth models.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Adam1

01-02-2014 09:12 AM

Thank you!

I used the PROC MIXED-code provided in the paper and it worked out perfectly. The paper was also very pedagogical and clear in its methodology, which helped a lot.