Programming the statistical procedures from SAS

Proc MCMC cannot generate stable results

Reply
New Contributor
Posts: 3

Proc MCMC cannot generate stable results

[ Edited ]

Hello there,

 

I've tried a simple regression on both SAS and Winbugs, but SAS generated different estimates everytime I hit "run" even though I didn't change any values (just press "run" again and again), while Winbugs gave me quite stable results.

 

Here is my SAS code, would someone tell me anything I missed in the program? Or SAS MCMC itself is not functioning well?

 

Thank you.

 

===============================

Data Base;

Input ID $ Y X_mu X_sigma;

Datalines;

A 15 4 1.1

B 8 1.2 0.8

C 12 2.8 1

;

run;

 

Proc MCMC Data=base nmc=10000 Autocorlag=10000 thin=1 nbi=10000 monitor = (intercept beta X);

Parms intercept beta X;

       Model Y ~ normal(Intercept + beta * X , sd=1);

                Prior Intercept ~ normal(0, sd=100);

                Prior beta ~ normal(0, sd=100);

                Prior X ~ lognormal(X_mu, sd= X_sigma);

Run;

 

===================================

For running five times, SAS generated estimates of beta as -1.3, 7.8, -2.3, 0.4, 2.3 (and kept changing...), 

and Winbugs generated a stable range 0.70, 0.75, 0.70, 0.70, 0.70.

SAS Super FREQ
Posts: 3,305

Re: Proc MCMC cannot generate stable results

If you want the same results, use the SEED= option in the PROC MCMC statement:

    proc MCMC Data=base SEED=12345 ...;

This sets the random number seed. By default, SEED=0, and PROC MCMC gets a random number seed from the time of day.

New Contributor
Posts: 3

Re: Proc MCMC cannot generate stable results

[ Edited ]

Thank you, @Rick_SAS. The Seed option did work, and the results are the same now.

But I checked the posterior values for each iteration, found that the values were barely moved no matter the seed was set or not (the first 20 values are as belows.) I need to increase the thinning rate, say 10, or the nmc to 200,000 to maker sure the results are right, but then it takes a lot of running time. Is this normal for SAS?

Thanks.

 

IterationinterceptbetaxLog Prior DensityLog-LikelihoodLog Posterior
19.60.123.7-14.3-15.8-30.2
29.50.123.7-14.3-15.4-29.8
39.40.123.5-14.4-15.4-29.8
49.40.123.5-14.4-15.4-29.8
59.40.123.5-14.4-15.4-29.8
69.10.123.9-14.3-15.9-30.2
79.20.123.8-14.3-15.8-30.1
89.20.123.8-14.3-15.8-30.1
99.50.125.2-14.3-15.8-30.1
109.50.126.0-14.3-15.1-29.4
119.10.127.0-14.3-15.2-29.5
129.00.127.4-14.3-15.2-29.5
139.00.127.4-14.3-15.2-29.5
149.00.127.4-14.3-15.2-29.5
159.00.127.4-14.3-15.2-29.5
169.00.127.4-14.3-15.2-29.5
179.00.127.4-14.3-15.2-29.5
189.00.127.4-14.3-15.2-29.5
198.90.125.5-14.3-15.7-30.0
208.90.125.5-14.3-15.7-30.0
Valued Guide
Valued Guide
Posts: 673

Re: Proc MCMC cannot generate stable results

You are not getting any mixing at all in the chain. Your profile plots must look very strange. It is probably related to the fact that you do not have a free residual variance parameter. You are fixing the standard deviation (variance) at a constant in the model. This usually is a parameter with a prior.

I don't know why you are treating X as a parameter rather than as a fixed predictor variable. I assume you have a good reason (perhaps, as a measurement-error model).

Valued Guide
Valued Guide
Posts: 673

Re: Proc MCMC cannot generate stable results

The problem is your treatment of X as a parameter. I tried this with some data, and MCMC cannot mix. If you just had a model with X_mu as the predictor variable, it runs fine. Of course, you may have a reason to treat the predictor as a variable, although I am not aware of a reason for doing so.

New Contributor
Posts: 3

Re: Proc MCMC cannot generate stable results

Thank you, @lvm. This helps a lot.

 

yeah, I was guessing the "X" was the reason. When I set X constant, everything looks fine. But since X is an estimation instead of an observation in my work, I need to assign a distribution for X. I may need to figure out a way to solve this problem.

Ask a Question
Discussion stats
  • 5 replies
  • 337 views
  • 0 likes
  • 3 in conversation