The QLIM Procedure

Example 27.8 Bayesian Modeling

(View the complete code for this example.)

This example illustrates how to use the QLIM procedure to perform Bayesian analysis. The generated data mimic a hypothetical scenario in which you study the number of tickets sold for a sports event given the probability of the hosting team winning and the price of the tickets. The following statements create the data set:

title1 'Bayesian Analysis';

ods graphics on;

data test;
   do i=1 to 200;
      e1 = rannor(8726)*2000;
      WinChance = ranuni(8772);
      Price = 10+ranexp(8773)*4;
      y = 48000 + 5000*WinChance - 100 * price +  e1;
      if y>50000 then TicketSales = 50000;
      if y<=50000 then TicketSales = y;
      output;
   end;
   keep WinChance price  y TicketSales;
run;

The following statements perform Bayesian analysis of a Tobit model:

proc qlim data=test plots(prior)=all;
   model TicketSales = WinChance price;
   endogenous TicketSales ~ censored(lb=0 ub= 50000);
   prior intercept~normal(mean=48000);
   prior WinChance~normal(mean=5000);
   prior Price~normal(mean=-100);
   bayes NBI=10000 NMC=30000 THIN=1 ntrds=1 DIAG=ALL STATS=ALL seed=2;
run;

Output 27.8.1 shows the results from the maximum likelihood estimation and the Bayesian analysis with diffuse prior of this Tobit model.

Output 27.8.1: Bayesian Tobit Model

Bayesian Analysis

The QLIM Procedure

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept148119623.56504577.17<.0001
WinChance15242.083501559.1512229.38<.0001
Price1-106.73166540.660795-2.620.0087
_Sigma11939.607207134.34877214.44<.0001

Posterior Summaries
ParameterNMeanStandard
Deviation
Percentiles
25%50%75%
Intercept3000048109.4535.047750.548102.648460.1
WinChance300005212.9483.44878.85205.25533.0
Price30000-104.736.5224-128.6-104.2-79.4191
_Sigma300001950.9132.91858.41945.02034.0


Output 27.8.2 shows a graphical representation of MLE, prior, and posterior distributions.

Output 27.8.2: Predictive Analysis by Observation Number

Predictive Analysis by Observation Number
External File:images/qliex08agrapha1.png
External File:images/qliex08agrapha2.png
External File:images/qliex08agrapha3.png


The validity of the MCMC sampling phase can be monitored with Output 27.8.3.

Output 27.8.3: Predictive Analysis by Observation Number

Predictive Analysis by Observation Number
External File:images/qliex08agraphb1.png
External File:images/qliex08agraphb2.png
External File:images/qliex08agraphb3.png


Finally the prior and the posterior predictive analyses are represented in Output 27.8.4.

Output 27.8.4: Predictive Analysis by Observation Number

Predictive Analysis by Observation Number


Last updated: November 05, 2018