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

Hi, I am working with a data, which is at customer x week x tier level and has other features- P1, P2, P3 and Sales. Treating Sales as a dependent variable and P1, P2 and P3 as independent variables I am planning to run a Bayesian regression model. Additionally, I would like to randomize this model at tier level(there are 4 tiers in the data). For e.g- if Model is Sales = B0+ B1*P1+ B2*P2+B3*P3, I would expect 4 intercepts B0 for each tier, 4 slopes B1 for each tier and so on.

 

I explored GENMOD, but it seems GENMOD does not support randomization. Next, I tested BGLIMM which seems to have worked best in my case but my current SAS version does not support BGLIMM. Lastly, I am left with only PROC MCMC. I have used below codes:

 

proc mcmc data=baymdb outpost=PostOut_re nmc=100 thin=5;
ods select Parameters REparameters PostSumInt tracepanel;
parms B0-B3 S2 ;
parms S2g 1;
prior B: ~ normal(0, var=1e6);
prior S2 ~ igamma(0.01, scale = 0.01);
prior S2g ~ general(0, lower=0);
random theta ~ normal(0,var=S2g) subject=tier ;
Mu = B0 + B1*P1 + B2*P2 +B3*P3 + theta ;
model LN_AHC_ENTNRX_ONE ~ normal(Mu,var=S2);

run;

 

However, the output of the above model does not have intercepts and estimates at tier level. I am seeing only overall level B0, B1, B2, B3.

 

Is there anything I am missing or if there is any other procedure which I could use? Thanks in advance for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
sham414
Calcite | Level 5

Thanks for the suggestion. This helped. I just had to made slight changes with the way I define intercept level random effect estimates: 

 

prior B: ~ normal(0, var=1e6);
prior S2 ~ igamma(0.01, scale = 0.01);
prior S2g ~ general(0, lower=0);

random b0 ~ normal(0,var=S2g) subject=tier monitor=(b0) ;

random b1~ normal(0,var=S2g) subject=tier monitor=(b1);

random b2~ normal(0,var=S2g) subject=tier monitor=(b2);

random b2~ normal(0,var=S2g) subject=tier monitor=(b3);
Mu = (B0+b0) + (B1+b1)*P1 + (B2+b2)*P2 +(B3+b3)*P3 ;

View solution in original post

2 REPLIES 2
SAS_Rob
SAS Employee

They are in the model via the RANDOM statement, but you will need to add the MONITOR= option on the RANDOM statement to see their distributions actually reported in the output.

random theta ~ normal(0,var=S2g) subject=tier monitor=(theta);

sham414
Calcite | Level 5

Thanks for the suggestion. This helped. I just had to made slight changes with the way I define intercept level random effect estimates: 

 

prior B: ~ normal(0, var=1e6);
prior S2 ~ igamma(0.01, scale = 0.01);
prior S2g ~ general(0, lower=0);

random b0 ~ normal(0,var=S2g) subject=tier monitor=(b0) ;

random b1~ normal(0,var=S2g) subject=tier monitor=(b1);

random b2~ normal(0,var=S2g) subject=tier monitor=(b2);

random b2~ normal(0,var=S2g) subject=tier monitor=(b3);
Mu = (B0+b0) + (B1+b1)*P1 + (B2+b2)*P2 +(B3+b3)*P3 ;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 2 replies
  • 627 views
  • 1 like
  • 2 in conversation