The data is entirely generated within the script via a 'DATA' step and 'datalines' statement, creating the 'seeds' table.
1 Code Block
DATA STEP Data
Explanation : This code block creates a SAS dataset named 'seeds'. The data is read directly from the input stream (datalines). A variable 'ind' is added, serving as a unique identifier for each row (observation).
Explanation : This block performs a Bayesian analysis via the MCMC procedure. It defines the model parameters (beta0, beta1, beta2, beta3, s2) and their prior distributions. A hierarchical model is constructed with a random effect 'delta' following a normal distribution. The probability 'pi' is modeled by a logistic function of this random effect, and the response variable 'r' is assumed to follow a binomial distribution. The simulation generates 20000 samples from the posterior distribution, which are saved in the 'postout' table.
Copied!
proc mcmc data=seeds outpost=postout seed=332786 nmc=20000;
ods select PostSumInt;
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;
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;
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.
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.