This script illustrates the use of the BCHOICE procedure to fit a discrete choice model (here, chocolate preferences) and predict choice probabilities for a set of user-defined scenarios (covariates). It creates training data and a design matrix (DesignMatrix), runs the MCMC simulation, and generates posterior predictive distributions via the PREDDIST statement.
Data Analysis
Type : INTERNAL_CREATION
Training data (Chocs) and covariates for prediction (DesignMatrix) are entirely created within the script via DATA and DATALINES steps.
1 Code Block
DATA STEP Data
Explanation : Creation of the 'Chocs' dataset containing observed choices (Choice variable) for 10 subjects (Subj) based on binary product characteristics (Dark, Soft, Nuts).
Explanation : Creation of a 'DesignMatrix' table containing the 8 possible combinations of attributes for which predicted probabilities are to be calculated.
Explanation : Execution of PROC BCHOICE to fit the model. The MODEL statement specifies the response and effects. The PREDDIST statement uses the 'DesignMatrix' covariates to generate predictive distributions (Probabilities) in the 'Predout' output table.
Copied!
proc bchoice data=Chocs outpost=Bsamp nmc=10000 thin=2 seed=124;
class Dark(ref='0') Soft(ref='0') Nuts(ref='0') Subj;
model Choice = Dark Soft Nuts / choiceset=(Subj);
preddist covariates=DesignMatrix nalter=8 outpred=Predout;
run;
Explanation : Call to the %SUMINT macro to summarize the credibility intervals of the predicted probabilities (variables starting with Prob_1_) contained in the 'Predout' table.
Copied!
%SUMINT(data=Predout, var=Prob_1_:)
1
%SUMINT(DATA=Predout, var=Prob_1_:)
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: BCHCEX7, 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.