The script analyzes a dataset simulating potentially interval-censored event times (tl and tr). It presents two approaches to model interval censoring with PROC MCMC: a manual approach defining a custom likelihood function (llike) based on logpdf, logsdf, and logcdf functions, and a more concise approach using the MODEL statement with CLOWER and CUPPER options to directly specify the limits of the censoring interval. Both approaches estimate the same parameters mu and sigma.
Data Analysis
Type : CREATION_INTERNE
The 'cosmetic' dataset is created internally via a DATALINES statement. It contains 'tl' (lower event time) and 'tr' (upper event time) variables that define the censoring intervals. A dot ('.') indicates a missing value for left or right censoring. The 't' variable is initialized as missing.
1 Code Block
DATA STEP Data
Explanation : This DATA block creates the 'cosmetic' dataset from the provided data lines (DATALINES). The 'tl' (lower time) and 'tr' (upper time) variables are read. The 't' variable is initialized as missing. Labels are defined for 'tl'. Note that the part ' @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json' of the INPUT statement is syntactically incorrect in this context and does not participate in reading the data, which comes exclusively from DATALINES.
Explanation : This first PROC MCMC block performs Bayesian inference for a normal regression model with interval censoring. It uses a custom likelihood function ('llike') to handle different types of censoring (left, right, interval censoring, and uncensored observations). The 'mu' and 'sigma' parameters are defined with non-informative priors. The MISSING=AC option handles missing values for chain analysis. The ODS SELECT PostSumInt statement selects the output table containing summaries and credibility intervals of the parameters.
Copied!
proc mcmc data=cosmetic outpost=postout seed=1 nmc=20000 missing=AC;
ods select PostSumInt;
parms mu 60 sigma 50;
prior mu ~ normal(0, sd=1000);
prior sigma ~ gamma(shape=0.001,iscale=0.001);
if (tl^=. and tr^=. and tl=tr) then
llike = logpdf('normal',tr,mu,sigma);
else if (tl^=. and tr=.) then
llike = logsdf('normal',tl,mu,sigma);
else if (tl=. and tr^=.) then
llike = logcdf('normal',tr,mu,sigma);
else
llike = log(sdf('normal',tl,mu,sigma) -
sdf('normal',tr,mu,sigma));
model general(llike);
run;
Explanation : This second PROC MCMC block performs the same Bayesian inference but in a more simplified way by using the CLOWER and CUPPER options of the MODEL statement. These options allow direct specification of the lower and upper limits of the censoring interval for the 't' variable, thus simplifying the likelihood implementation compared to the manual approach of the previous block. The MISSING=ACMODELY option is used for missing values in the model. ODS SELECT NONE suppresses all output from this procedure.
Copied!
proc mcmc data=cosmetic outpost=postout seed=117207154
nmc=20000 missing=ACMODELY;
ods select none;
parms mu 60 sigma 50;
prior mu ~ normal(0, sd=1000);
prior sigma ~ gamma(shape=0.001,iscale=0.001);
model t ~ normal(mu, sd=sigma, clower=tl, cupper=tr);
run;
model t ~ normal(mu, sd=sigma, clower=tl, cupper=tr);
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.