The script first generates a 'seeds' dataset containing germination results. It then uses the `PROC MCMC` procedure to fit a binomial model with a logit link function and random effects ('delta'). The posterior distribution samples are saved in the 'postout' table. A `%CATER` macro is called to create the Caterpillar plot of the random effects. Finally, a `PROC TEMPLATE` step is used to view the source of the associated graph template.
Data Analysis
Type : CREATION_INTERNE
The data used ('seeds') is created directly in the script via a DATA step using the DATALINES statement.
1 Code Block
DATA STEP Data
Explanation : Creates the 'seeds' dataset containing variables r, n, seed, extract and an observation identifier 'ind'. The data is included directly in the code.
Explanation : Performs a Bayesian (MCMC) analysis on the 'seeds' data. Defines a binomial logistic model with random effects 'delta'. Posterior samples are stored in 'postout'. Result display is temporarily disabled to optimize execution.
Copied!
ods select none;
proc mcmc data=seeds outpost=postout seed=332786 nmc=20000;
parms beta0 0 beta1 0 beta2 0 beta3 0 s2 1;
prior s2 ~ igamma(0.01, s=0.01);
prior beta: ~ general(0);
w = beta0 + beta1*seed + beta2*extract + beta3*seed*extract;
random delta ~ normal(w, var=s2) subject=ind;
pi = logistic(delta);
model r ~ binomial(n = n, p = pi);
run;
ods select all;
w = beta0 + beta1*seed + beta2*extract + beta3*seed*extract;
7
random delta ~ normal(w, var=s2) subject=ind;
8
pi = logistic(delta);
9
model r ~ binomial(n = n, p = pi);
10
RUN;
11
ods select all;
3 Code Block
Macro Call
Explanation : Calls the `%CATER` macro (assumed to be defined in the environment or an autocall library) to generate the Caterpillar plot of variables starting with 'delta' from the 'postout' dataset.
Copied!
%CATER(data=postout, var=delta:);
1
%CATER(DATA=postout, var=delta:);
4 Code Block
PROC TEMPLATE
Explanation : Displays the source code of the ODS graph template 'Stat.MCMC.Graphics.Caterpillar' stored in 'sashelp.tmplmst', allowing inspection of the graph definition used.
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : SAS SAMPLE LIBRARY - NAME: MCMCCAT - PRODUCT: STAT
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.