CQLIM Procedure

Example 12.5 Bayesian Analysis with Multiple Chains

This example shows how to perform Bayesian analysis with multiple chains in the CQLIM procedure by using a small data table.

The following DATA step creates the Christenson Associates airline data, a frequently cited data set (Greene 2000). The data measure the costs, prices of inputs, and utilization rates for six airlines from 1970 to 1984. This example analyzes the log transformations of cost (C), quantity (Q), and price (PF) and the untransformed load factor (LF). These statements assume that your libref is named mylib, but you can substitute any appropriately defined libref.

data mylib.airline;
   input Obs AirlineID T C Q PF LF;
   Year = T + 1969;
   lC   = log(C);
   lQ   = log(Q);
   lPF  = log(PF);
   label lC  = "Log Transformation of Costs";
   label lQ  = "Log Transformation of Quantity";
   label lPF = "Log Transformation of Price of Fuel";
   label LF  = "Load Factor (utilization index)";
datalines;
 1    1     1    1140640    0.95276     106650    0.53449
 2    1     2    1215690    0.98676     110307    0.53233
 3    1     3    1309570    1.09198     110574    0.54774
 4    1     4    1511530    1.17578     121974    0.54085
 5    1     5    1676730    1.16017     196606    0.59117

   ... more lines ...   

The following statements estimate a simple linear regression model in the Bayesian framework by using the No-U-Turn Sampler (NUTS). NUTS is specified in the SAMPLER= option, and several values controlling the sampler can be set as arguments to SAMPLER=NUTS. The NCHAIN= option controls the number of Markov chains, and the NSAMPLE= option controls the size of the posterior sample per chain. PROC CQLIM automatically aggregates the results of each of the chains to create the posterior statistics and MCMC diagnostics tables that you request. The BYCHAIN suboption of the STATISTICS= and DIAGNOSTICS= options additionally produces those tables separately for each chain. This example produces the "Posterior Summaries" table, the "MCMC Diagnostic Summaries" table, and the "Heidelberger-Welch Diagnostics" table for each chain as well as for all chains combined.

proc cqlim data = mylib.airline;
   model lC = lQ lPF LF;
   bayes seed = 2358 nsample = 2000 nchain = 4
         sampler = nuts(ntune = 2000)
         statistics(bychain) = summary
         diagnostics(bychain) = (summary heidel);
run;

Output 12.5.1 shows the Bayesian estimation results. The "Posterior Summaries" table contains the estimates of the posterior mean and posterior quantiles computed using all four chains. The other posterior summary statistics tables that are produced by the STATISTICS= option would similarly be computed using all four chains. The "MCMC Diagnostic Summaries" table contains basic convergence diagnostics aggregated across all four chains. The "Autocorrelation Diagnostics" table would also be aggregated for multiple chains. For more information about how this aggregation is performed, see the section Using Multiple Chains in Chapter 2, Introduction to Bayesian Analysis Procedures. The "Heidelberger-Welch Diagnostics" table displays a summary of all the Heidelberger-Welch tests performed for each chain. Specifically, it shows the number of chains for which each test passed for each parameter, as well as the largest number of iterations that were discarded for the stationarity test. The "Geweke Diagnostics" table and the "Raftery-Lewis Diagnostics" table both would be summarized similarly.

Output 12.5.1: Posterior Summaries and MCMC Diagnostics

The CQLIM Procedure

Posterior Summaries
ParameterNMeanStandard
Deviation
Percentiles
2.5%25%50%75%97.5%
Intercept80009.51890.23699.05769.36029.52009.67809.9897
lQ80000.88340.01360.85650.87430.88350.89240.9110
lPF80000.45440.02060.41460.43970.45430.46850.4936
LF8000-1.63870.3551-2.3521-1.8720-1.6356-1.3933-0.9782
_Sigma80000.12620.009940.10850.11920.12550.13250.1466

The CQLIM Procedure

MCMC Diagnostic Summaries
ParameterMCSEMCSE/SDESSAutocorrelation
Time
ESS/N
Intercept0.006340.02681394.95.73500.1744
lQ0.0003580.02631449.65.51870.1812
lPF0.0005360.02611469.35.44490.1837
LF0.008650.02441686.14.74480.2108
_Sigma0.0002160.02182111.83.78820.2640

Heidelberger-Welch Diagnostics
ParameterStationarity TestHalf-Width Test
Chains
Tested
Tests
Passed
Largest
Iterations
Discarded
Chains
Tested
Tests
Passed
Intercept4420044
lQ44044
lPF4420044
LF44044
_Sigma44044


Detailed results for each chain are available in Output 12.5.2 as a result of the BYCHAIN options. The "Posterior Summaries by Chain" table contains the estimates of the posterior mean and posterior quantiles computed separately for each chain. Similarly, the "MCMC Diagnostic Summaries by Chain" table contains basic convergence diagnostics computed for each chain, and the "Heidelberger-Welch Diagnostics by Chain" table contains the Heidelberger-Welch diagnostics computed for each chain. For more information about the differences between the tables in Output 12.5.1 and Output 12.5.2, see the section Using Multiple Chains in Chapter 2, Introduction to Bayesian Analysis Procedures.

Output 12.5.2: Posterior Summaries and MCMC Diagnostics by Chain

The CQLIM Procedure

Posterior Summaries by Chain
ChainParameterNMeanStandard
Deviation
Percentiles
2.5%25%50%75%97.5%
1Intercept20009.52730.24269.06199.36459.51929.695210.0305
 lQ20000.88320.01320.85760.87530.88300.89190.9118
 lPF20000.45240.02090.41280.43830.45250.46670.4925
 LF2000-1.60990.3489-2.3108-1.8336-1.6070-1.3769-0.9698
 _Sigma20000.12630.01070.10860.11850.12540.13340.1471
2Intercept20009.51560.25079.02719.34359.52099.683510.0036
 lQ20000.88370.01470.85380.87350.88390.89320.9138
 lPF20000.45450.02040.41280.44010.45430.46880.4917
 LF2000-1.63470.3751-2.4184-1.8903-1.6307-1.3722-0.9120
 _Sigma20000.12660.009780.10910.11950.12570.13240.1476
3Intercept20009.51630.21839.09369.36779.51939.66299.9285
 lQ20000.88290.01360.85650.87310.88300.89270.9092
 lPF20000.45520.02040.41680.44040.45530.46910.4944
 LF2000-1.65430.3499-2.3549-1.8776-1.6564-1.4140-0.9975
 _Sigma20000.12590.009760.10770.11910.12560.13250.1456
4Intercept20009.51650.23489.04389.35659.52119.67359.9813
 lQ20000.88370.01290.85940.87530.88390.89170.9105
 lPF20000.45530.02040.41630.44030.45500.46880.4949
 LF2000-1.65590.3440-2.3441-1.8875-1.6461-1.4118-1.0155
 _Sigma20000.12590.009510.10850.11950.12540.13200.1464

The CQLIM Procedure

MCMC Diagnostic Summaries by Chain
ChainParameterMCSEMCSE/SDESSAutocorrelation
Time
ESS/N
1Intercept0.01470.0604274.17.29540.1371
 lQ0.0007840.0591285.96.99580.1429
 lPF0.001250.0598279.87.14700.1399
 LF0.01750.0502397.15.03650.1986
 _Sigma0.0005270.0495408.54.89600.2042
2Intercept0.01320.0528359.15.56940.1796
 lQ0.0007300.0498403.54.95620.2018
 lPF0.001030.0505392.85.09210.1964
 LF0.01860.0495408.54.89640.2042
 _Sigma0.0004340.0444506.53.94860.2533
3Intercept0.01170.0535349.45.72490.1747
 lQ0.0006970.0512381.45.24420.1907
 lPF0.0009900.0486423.44.72400.2117
 LF0.01740.0498403.64.95590.2018
 _Sigma0.0003800.0389659.93.03080.3300
4Intercept0.01100.0466459.74.35030.2299
 lQ0.0006380.0494409.94.87870.2050
 lPF0.001000.0491415.24.81670.2076
 LF0.01560.0452488.94.09050.2445
 _Sigma0.0003850.0405610.23.27760.3051

Heidelberger-Welch Diagnostics by Chain
ChainParameterStationarity TestHalf-Width Test
Cramer-von
Mises Stat
p-ValueTest
Outcome
Iterations
Discarded
Half-WidthMeanRelative
Half-Width
Test
Outcome
1Intercept0.29670.1381Passed2000.03159.51840.00331Passed
 lQ0.06790.7645Passed00.001540.88320.00174Passed
 lPF0.36020.0923Passed2000.002520.45330.00555Passed
 LF0.08530.6617Passed00.0362-1.6099-0.0225Passed
 _Sigma0.10540.5592Passed00.001030.12630.00818Passed
2Intercept0.06290.7955Passed00.02849.51560.00299Passed
 lQ0.18410.3005Passed00.001490.88370.00168Passed
 lPF0.09040.6339Passed00.002150.45450.00473Passed
 LF0.09040.6339Passed00.0395-1.6347-0.0241Passed
 _Sigma0.10820.5459Passed00.0009340.12660.00738Passed
3Intercept0.08960.6384Passed00.02269.51630.00238Passed
 lQ0.10320.5692Passed00.001430.88290.00162Passed
 lPF0.11250.5272Passed00.001930.45520.00425Passed
 LF0.02550.9886Passed00.0357-1.6543-0.0216Passed
 _Sigma0.06660.7726Passed00.0008170.12590.00649Passed
4Intercept0.03740.9461Passed00.02289.51650.00239Passed
 lQ0.09680.6006Passed00.001320.88370.00150Passed
 lPF0.08960.6382Passed00.002100.45530.00461Passed
 LF0.22740.2201Passed00.0310-1.6559-0.0187Passed
 _Sigma0.05650.8357Passed00.0006570.12590.00522Passed


Last updated: July 09, 2026