BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ha33
Obsidian | Level 7

Hello everyone,

 

I am attempting to model the effects of an intervention in the same individuals before and after the initiate it. 

 

I am not a statistician by training so I might be using some terms wrong. 

 

The response variable is whether or not individuals redeem a prescription (binary).  Data looks similar to this: 

 

ID month half_year outcome prev_treated
1 -3 -1 0 0
1 -2 -1 0 0
1 -1 -1 1 0
1 0 1 1 0
2 1 1 0 1
2 2 1 1 1

 

Month 0 is the month of the start of intervention. Half_year is 6-month period in relation to start of the intervention. Prev_treated denotes whether individuals had attempted a former treatment. 

 

We are interested in estimating the odds ratio for outcome=1 in half_years -4, -3, -2, -1, 1, 2, 3, 4.

 

We expect that: 

1) The likelihood of experiencing an outcome  at time of intervention is different for individuals.

2) Individuals will have a different change in likeilhood post-intervention (response will be individual).

3) The "measurements" are performed at equally spaced intervals, and closer measurements will be correlated. 

 

Considering this, we have made a model with proc glimmix that looks like this: 

 

 

proc glimmix data = have;

class ID half_year(ref-4)  month prev_treated;

model outcome(Event="1")= half_year prev_treated / dist=binary link=logit oddsratio s;

random intercept / subject=ID;

random month/subject=ID residual type=AR(1);

run;

 

We have included the two random statements to accomodate both 1) and 2). 

 

I am a little confused as to why month must be in the class-statement to be modeled as a random effect.

 

Also I am not sure that the longitudinal nature of the data is captured (it is not just randomly repeated measurements, but ordered measurements that are correlated) but I guess the  type=AR(1) might capture this? 

 

I have also read some documentation about G- and R-side effects in relation to the two random statements, but isn't the point to accomodate  random variation in starting points (intercepts) between individuals, and random variation in developments/"slope" between individuals after intervention? 

 

All in all, I would like some feedback model and if you think it makes sense.

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

Regarding month as a "random" effect - note that the RANDOM statement that applies to month has the residual option. That means that the model is fit with month as an R-side variable. That is the definition of a repeated effect in GLIMMIX. The question then becomes - "what sort of residual can you get from a binary distribution?" Can you get a value that is independent of the mean? If not (and this is common in binary data), you probably need to do some jiggering of the algorithm used and of that particular RANDOM statement. You may wish to try this code:

 

proc glimmix data = have method=quad;
class ID half_year(ref-4)  month prev_treated;
model outcome(Event="1")= half_year prev_treated / dist=binary link=logit oddsratio s;
nloptions maxiter=1000;
random intercept / subject=ID;
random month/subject=ID  type=AR(1);
run;

This shifts the repeated effect to a G-side random effect, still with a specified covariance structure. The method is now adaptive quadrature, rather than the default restricted pseudo-likelihood. I also added an NLOPTIONS statement so that you would have a relatively reasonable chance of convergence. The default number of iterations in GLIMMIX is 20, and I have yet to see a binary distribution converge in 20 or less iterations.

Once you get this to run successfully, you will probably want to compare the levels of half_year and prev_treated. Search this site for information on the %NLest (https://support.sas.com/kb/58/775.html ) and %NLmeans  (https://support.sas.com/kb/62/362.html) macros.

 

SteveDenham

 

 

 

View solution in original post

1 REPLY 1
SteveDenham
Jade | Level 19

Regarding month as a "random" effect - note that the RANDOM statement that applies to month has the residual option. That means that the model is fit with month as an R-side variable. That is the definition of a repeated effect in GLIMMIX. The question then becomes - "what sort of residual can you get from a binary distribution?" Can you get a value that is independent of the mean? If not (and this is common in binary data), you probably need to do some jiggering of the algorithm used and of that particular RANDOM statement. You may wish to try this code:

 

proc glimmix data = have method=quad;
class ID half_year(ref-4)  month prev_treated;
model outcome(Event="1")= half_year prev_treated / dist=binary link=logit oddsratio s;
nloptions maxiter=1000;
random intercept / subject=ID;
random month/subject=ID  type=AR(1);
run;

This shifts the repeated effect to a G-side random effect, still with a specified covariance structure. The method is now adaptive quadrature, rather than the default restricted pseudo-likelihood. I also added an NLOPTIONS statement so that you would have a relatively reasonable chance of convergence. The default number of iterations in GLIMMIX is 20, and I have yet to see a binary distribution converge in 20 or less iterations.

Once you get this to run successfully, you will probably want to compare the levels of half_year and prev_treated. Search this site for information on the %NLest (https://support.sas.com/kb/58/775.html ) and %NLmeans  (https://support.sas.com/kb/62/362.html) macros.

 

SteveDenham

 

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 521 views
  • 3 likes
  • 2 in conversation