Multilevel analysis with two levels and two control variables

Reply
Occasional Contributor
Posts: 11

Multilevel analysis with two levels and two control variables

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

Respected Advisor
Posts: 2,655

Re: Multilevel analysis with two levels and two control variables

Posted in reply to oskarseriksson

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

Occasional Contributor
Posts: 11

Re: Multilevel analysis with two levels and two control variables

Posted in reply to SteveDenham

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

Respected Advisor
Posts: 2,655

Re: Multilevel analysis with two levels and two control variables

Posted in reply to oskarseriksson

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

Occasional Contributor
Posts: 11

Re: Multilevel analysis with two levels and two control variables

Posted in reply to SteveDenham

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!

Occasional Contributor
Posts: 16

Re: Multilevel analysis with two levels and two control variables

Posted in reply to oskarseriksson

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.

Occasional Contributor
Posts: 11

Re: Multilevel analysis with two levels and two control variables

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.

Ask a Question
Discussion stats
  • 6 replies
  • 720 views
  • 9 likes
  • 3 in conversation