BookmarkSubscribeRSS Feed
csfcgua1
Fluorite | Level 6

Hello,

 

It seems dirichlet distributions are not allowed for the random statement in Proc MCMC, so I used gamma distributions instead.

Proc MCMC Data=mydata;

   array delta[3] delta1 delta2 delta3;
   array p[3] p1 p2 p3;

   model  .........

   random delta1 ~ gamma(0.1, iscale=0.1) subject = ID ;
   random delta2 ~ gamma(0.1, iscale=0.1) subject = ID ;
   random delta3 ~ gamma(0.1, iscale=0.1) subject = ID ;

   p1 = delta1/sum(delta1, delta2, delta3); 
   p2 = delta2/sum(delta1, delta2, delta3);
   p3 = 1 - p1 - p2;

Run;

I expected that every ID should have its own post-distribution/summary of p, but SAS just generated a summary of p for the whole group.

 

I could compute the p from the results of delta for each ID afterward. But is it possible to obtain p directly from Proc MCMC?

 

Thanks.

2 REPLIES 2
ballardw
Super User

Did you try BY group processing?

BY ID;

 

would be my first approach if I needed output for each level of ID.

csfcgua1
Fluorite | Level 6

Thanks.

Yes. I thought about using BY at first, but I immediately realized that ALL of the  parameters would be estimated by ID, which is not necessary. 

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 521 views
  • 0 likes
  • 2 in conversation