BookmarkSubscribeRSS Feed
KKIND
Obsidian | Level 7

What is the equivalent of slice statement in a negative binomial regression model? 

9 REPLIES 9
Ksharp
Super User

Did you try SLICE statement of PROC GENMOD ?

another way is using LSMEANS + AT option

and another way is using EFFECTPLOT statement like:

 

data insure;
input n c car$ age;
carnum=1;
if car="medium" then carnum=2;
if car="large" then carnum=3;
ln = log(n);
datalines;
500 42 small 1
1200 37 medium 1
100 1 large 1
400 101 small 2
500 73 medium 2
300 14 large 2
;
proc genmod data=insure;
class  age;
model c = carnum age / dist=NEGBIN link=log ;
effectplot slicefit(x=carnum sliceby=age) / clm ;
run;

Ksharp_0-1714786119837.png

 

KKIND
Obsidian | Level 7

@Ksharp, many thanks! I will try your sample code and revert back asap. Have a great day!

 

Best

KKIND

KKIND
Obsidian | Level 7

Re: How to use VS Code with SAS OnDemand for Academics 

when I used the slice statement with multinomial logistic regression as follows.

C:\Users\kiran\OneDrive\HCUP-DBs\NEDS_2019\";

proc logistic data = NEDS.neds_2019_pneumonia_recat;

class died_visit (ref = "1") pay1recat (ref = "3") hosp_controlrecat (ref = "4") pl_nchsrecat (ref = "1") / param = glm;

model died_visit = pay1recat hosp_controlrecat pay1recat*hosp_controlrecat aweekend female pl_nchsrecat / link = glogit;

slice pay1recat*hosp_controlrecat/sliceby(pay1recat='3') diff oddsratio cl;

slice pay1recat*hosp_controlrecat/sliceby(pay1recat='2') diff oddsratio cl;

slice pay1recat*hosp_controlrecat/sliceby(pay1recat='1') diff oddsratio cl;

slice pay1recat*hosp_controlrecat/sliceby(hosp_controlrecat='1') diff oddsratio cl;

slice pay1recat*hosp_controlrecat/sliceby(hosp_controlrecat='2') diff oddsratio cl;

slice pay1recat*hosp_controlrecat/sliceby(hosp_controlrecat='3') diff oddsratio cl;

slice pay1recat*hosp_controlrecat/sliceby(hosp_controlrecat='4') diff oddsratio cl;

run;

one of the output tables I got and was looking for is

KKIND_0-1714936159387.png

Per my research question, I am looking at within hospital variation in outcomes by payer type (1=Medicare; 2=Medicaid; and 3= private insurance). From this output above, I can determine what is the difference in outcomes comparing between each payer type for each level of the hospital ownership type (hosp_controlrecat). Is there some way I can get similar outputs (comparing between payer types) under the proc genmod code? Thank you!

 

Best

KKIND

 

 

Ksharp
Super User

Did you try SLICE statement?

data insure;
input n c car$ age;
carnum=1;
if car="medium" then carnum=2;
if car="large" then carnum=3;
ln = log(n);
datalines;
500 42 small 1
1200 37 medium 1
100 1 large 1
400 101 small 2
500 73 medium 2
300 14 large 2
;
ods select  SliceDiffs;
proc genmod data=insure;
class  carnum age;
model c = carnum|age / dist=NEGBIN link=log offset=ln;
slice carnum*age /sliceby=age diff cl  ;
run;

Ksharp_0-1714960880104.png

 

 

Or @StatDave  could give you a hand.

KKIND
Obsidian | Level 7

Dear Ksharp,

 

Thanks again for your efforts and sharing the code. I tried using it bit still couldn't get the output as you shared. 

 

Best

KKind

KKIND
Obsidian | Level 7

Dear Ksharp and all,

 

Thank you for your advice on the slice statement for the negative binomial regression statement . I have managed to find the correct code to get the comparison I was looking for. Here is the code and one of the output tables.

proc genmod data=NIS.nis_2019_septicemia_ipexcmicat;

class pay1recat (ref = "3") hosp_region (ref= "4") hosp_locteach (ref= "1") hosp_bedsize (ref= "1") h_contrlrecat (ref= "3") female (ref= "0") zipinc_qrtl (ref= "4") aprdrg_severity (ref= "4") racerecat (ref= "1") cmr_index_mortalitycat (ref= "1") / param=glm;

model los = pay1recat hosp_region pay1recat*hosp_region hosp_locteach pay1recat*hosp_locteach hosp_bedsize pay1recat*hosp_bedsize h_contrlrecat pay1recat*h_contrlrecat female zipinc_qrtl aprdrg_severity racerecat cmr_index_mortalitycat / dist=negbin link=log;

lsmeans pay1recat*hosp_region / adjust=tukey;

slice pay1recat*hosp_region / sliceby=hosp_region diff cl;

lsmeans pay1recat*hosp_locteach / adjust=tukey;

slice pay1recat*hosp_locteach / sliceby=hosp_locteach diff cl;

lsmeans pay1recat*hosp_bedsize / adjust=tukey;

slice pay1recat*hosp_bedsize / sliceby=hosp_bedsize diff cl;

lsmeans pay1recat*h_contrlrecat / adjust=tukey;

slice pay1recat*h_contrlrecat / sliceby=h_contrlrecat diff cl;

run;

 

KKIND_1-1717774013352.png

 

 

Ksharp
Super User

It is better to post your question at STAT forum:

https://communities.sas.com/t5/Statistical-Procedures/bd-p/statistical_procedures

and calling @StatDave  @SteveDenham 

KKIND
Obsidian | Level 7

Hello Ksharp,

 

It is not a question > I was just updating the status of my question on teh slice statement for negative binomial regression that I had posed, informing that I have found teh solution and I pasted the solution and the corresponding output. Thanks!

SteveDenham
Jade | Level 19

Given that, you should mark @Ksharp 's post where he suggests a SLICE statement as a correct answer.

 

SteveDenham

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
  • 9 replies
  • 770 views
  • 1 like
  • 3 in conversation