Documentation Example 19 for PROC MCMC
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: MCMCEX19 */
/* TITLE: Documentation Example 19 for PROC MCMC */
/* Implement a New Sampling Algorithm */
/* PRODUCT: STAT */
/* SYSTEM: ALL */
/* KEYS: */
/* PROCS: MCMC */
/* DATA: */
/* */
/* SUPPORT: Fang Chen */
/* REF: PROC MCMC, EXAMPLE 19 */
/* MISC: */
/****************************************************************/
title 'Implement a New Sampling Algorithm';
data inputdata;
input remiss cell smear infil li blast temp;
ind = _n_;
cnst = 1;
label remiss='Complete Remission';
datalines;
1 0.8 0.83 0.66 1.9 1.1 0.996
1 0.9 0.36 0.32 1.4 0.74 0.992
0 0.8 0.88 0.7 0.8 0.176 0.982
0 1 0.87 0.87 0.7 1.053 0.986
1 0.9 0.75 0.68 1.3 0.519 0.98
0 1 0.65 0.65 0.6 0.519 0.982
1 0.95 0.97 0.92 1 1.23 0.992
0 0.95 0.87 0.83 1.9 1.354 1.02
0 1 0.45 0.45 0.8 0.322 0.999
0 0.95 0.36 0.34 0.5 0 1.038
0 0.85 0.39 0.33 0.7 0.279 0.988
0 0.7 0.76 0.53 1.2 0.146 0.982
0 0.8 0.46 0.37 0.4 0.38 1.006
0 0.2 0.39 0.08 0.8 0.114 0.99
0 1 0.9 0.9 1.1 1.037 0.99
1 1 0.84 0.84 1.9 2.064 1.02
0 0.65 0.42 0.27 0.5 0.114 1.014
0 1 0.75 0.75 1 1.322 1.004
0 0.5 0.44 0.22 0.6 0.114 0.99
1 1 0.63 0.63 1.1 1.072 0.986
0 1 0.33 0.33 0.4 0.176 1.01
0 0.9 0.93 0.84 0.6 1.591 1.02
1 1 0.58 0.58 1 0.531 1.002
0 0.95 0.32 0.3 1.6 0.886 0.988
1 1 0.6 0.6 1.7 0.964 0.99
1 1 0.69 0.69 0.9 0.398 0.986
0 1 0.73 0.73 0.7 0.398 0.986
;
proc mcmc data=inputdata nmc=100000 propcov=quanew seed=17
outpost=mcmcout;
ods select PostSummaries ess;
parms beta0-beta6;
prior beta: ~ normal(0,var=25);
mu = beta0 + beta1*cell + beta2*smear +
beta3*infil + beta4*li + beta5*blast + beta6*temp;
p = cdf('normal', mu, 0, 1);
model remiss ~ bern(p);
run;
proc fcmp outlib=sasuser.funcs.uds;
/******************************************/
/* Generate left-truncated normal variate */
/******************************************/
function rltnorm(mu,sig,lwr);
if lwr