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

I am doing a segmented poisson regression to look at counts pre- and post- an intervention.

There is therefore a poisson regression line pre-intervention and post-intervention. The delineation is by week - 141 weeks total, the break point is week 105.

I can create a variable ("preintervention") and code it as 1 if week < 105 and 0 if week >=105.

 

I want to graph the poisson regression lines pre- and post- intervention.

The overall regresson would be:

proc genmod data=have;

model count=week / dist=poisson link=log;

run;

 

My questions is - how do I transform this into a visual graph (presumably using proc sgplot) that will divide into 2 separate poisson regression lines - 1 pre intervention and 1 post.

 

Thank you for any assistance!

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

1. Add a CLASS statement and list the PreIntervention variable.

2. Include the PreIntervention variable in the model

3. Use the OUTPUT statement to get the predicted values in a SAS data set.

4. Graph the predicted value vs weeks

 

/* simulate data as an example */
data have; call streaminit(1); preintervention = 1; do week = 1 to 105; count = rand("Poisson", 0.8); output; end; preintervention = 0; do week = 106 to 150; count = rand("Poisson", 2.4); output; end; run; /* end simulation */
/* read whatever data you have and graph the results */
proc genmod data=have plots=none; class preintervention; model count=week preintervention / dist=poisson link=log; output out=PoiOut pre=Pred; run; proc sgplot data=PoiOut; scatter x=week y=count / group=preintervention transparency=0.5; series x=week y=Pred / group=preintervention; run;

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ

1. Add a CLASS statement and list the PreIntervention variable.

2. Include the PreIntervention variable in the model

3. Use the OUTPUT statement to get the predicted values in a SAS data set.

4. Graph the predicted value vs weeks

 

/* simulate data as an example */
data have; call streaminit(1); preintervention = 1; do week = 1 to 105; count = rand("Poisson", 0.8); output; end; preintervention = 0; do week = 106 to 150; count = rand("Poisson", 2.4); output; end; run; /* end simulation */
/* read whatever data you have and graph the results */
proc genmod data=have plots=none; class preintervention; model count=week preintervention / dist=poisson link=log; output out=PoiOut pre=Pred; run; proc sgplot data=PoiOut; scatter x=week y=count / group=preintervention transparency=0.5; series x=week y=Pred / group=preintervention; run;
syoung15
Calcite | Level 5

Thank you for this. However, the graph does not look right.

 

Could you please clarify what the statements:

count=rand ("Poisson", 0.8);

and

count=rand ("Poisson, 2.4);

mean? It seems to be a random number generation, but I'm not sure why you would do that? And why are 0.8 and 2.4 chosen, in particular.

 

I want the graph to show the true count (which are outcomes per week and are in the range of 100-750, varying per week) and overlay the Poisson regression line, divided by pre and post intervention. When I use this code, "count" becomes a number between 1-3 or so...

 

Thank you for all of your assistance!

Rick_SAS
SAS Super FREQ

You did not provide any data, so I simulated some to illustrate the process. Ignore the DATA step and just focus on the PROC GENMOD and PROC SGPLOT steps.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 644 views
  • 1 like
  • 2 in conversation