BookmarkSubscribeRSS Feed
hellorc
Obsidian | Level 7

Hello SAS community,

 

I am currently trying to fit a Poisson regression model with random intercept and fixed slope. I am not sure if it makes sense to include a random intercept. The sample size is about 300, and the data contains variables:

 

ID: identification

classroom: classroom # (integer from 1 to 9)

fail: binary response variable whether the student failed an exam (1=fail, 0=no fail)

size: size of the classroom in sq. ft. (continuous)

gender: gender of the student (0,1)

 

I am trying to compute:

(1) the exam fail rate ratio depending on size of the classroom, adjusted for classroom #

(1) the exam fail rate ratio for male vs. female students, adjusted for classroom #

 

So the current SAS code I have is:

proc glimmix;
class id classroom gender;
model fail = classroom size / solution ;
random intercept /subject = classroom g type=un;
run;

proc glimmix;
class id classroom gender;
model fail = classroom gender / solution ;
random intercept /subject = classroom g type=un;
run;

I have few questions:

-I would like to consider classroom # as a random intercept. Should I include ID as well? (i.e.) subject = classroom(ID)

-The same classroom would have the same size. So for example all students in classroom 1 would have same size variable. Does it make sense to include both classroom and size variables (one fixed, one random) in the model?

-Please advise on what other possible approach there is.

 

Thank you,

RC

 

 

 

 

 

2 REPLIES 2
StatsMan
SAS Super FREQ

If CLASSROOM is a random effect, then you do not list that effect on the MODEL statement. Only fixed effects appear on the MODEL statement. If you have multiple observations for each student in a classroom, then you could try ID(CLASSROOM) as an additional random effect. If you only have one observation per student, then you do not have enough data to include ID(CLASSROOM) in the model. 

 

Yes, you can include both student-level and classroom-level covariates in the model. GLIMMIX will assign the correct df to those effects based on how they change or do not change within levels of the random effect.

SteveDenham
Jade | Level 19

One thing to remember about GLIMMIX is that it only has a RANDOM statement, and no REPEATED statement as in many other of the linear modeling procs. So it is entirely possible that an effect be included in the MODEL statement and a RANDOM statement, so long as the residual option is applied. That requires by subject processing.  And, if you wish to model a G-side repeated measures design (which occurs quite a bit with count data), you can dispense with the residual option.

 

It is just one more of those things that you need to be very cognizant of when writing GLIMMIX code.

 

SteveDenham

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 713 views
  • 0 likes
  • 3 in conversation