The GENMOD Procedure

Bayesian Analysis of a Linear Regression Model

(View the complete code for this example.)

Neter et al. (1996) describe a study of 54 patients undergoing a certain kind of liver operation in a surgical unit. The data set Surg contains survival time and certain covariates for each patient. Observations for the first 20 patients in the data set Surg are shown in Figure 45.7.

Figure 45.7: Surgical Unit Data

Obsx1x2x3x4ylogyLogx1
16.762812.592002.30101.90211
25.159661.701012.00431.62924
37.457832.162042.30962.00148
46.573412.011012.00431.87180
57.8651154.305092.70672.05412
65.838721.42801.90311.75786
75.746631.91801.90311.74047
83.768812.571272.10381.30833
96.067932.502022.30541.79176
103.776942.402032.30751.30833
116.384834.133292.51721.84055
126.751431.86651.81291.90211
135.8961143.958302.91911.75786
145.883883.953302.51851.75786
157.762673.401682.22532.04122
167.474682.402172.33652.00148
176.085282.98871.93951.79176
183.751411.55341.53151.30833
197.368743.562152.33241.98787
205.657873.021722.23551.72277


Consider the model

where Y is the survival time, LogX1 is log(blood-clotting score), X2 is a prognostic index, X3 is an enzyme function test score, X4 is a liver function test score, and is an error term.

A question of scientific interest is whether blood clotting score has a positive effect on survival time. Using PROC GENMOD, you can obtain a maximum likelihood estimate of the coefficient and construct a null point hypothesis to test whether is equal to 0. However, if you are interested in finding the probability that the coefficient is positive, Bayesian analysis offers a convenient alternative. You can use Bayesian analysis to directly estimate the conditional probability, , using the posterior distribution samples, which are produced as part of the output by PROC GENMOD.

The example that follows shows how to use PROC GENMOD to carry out a Bayesian analysis of the linear model with a normal error term. The SEED= option is specified to maintain reproducibility; no other options are specified in the BAYES statement. By default, a uniform prior distribution is assumed on the regression coefficients. The uniform prior is a flat prior on the real line with a distribution that reflects ignorance of the location of the parameter, placing equal likelihood on all possible values the regression coefficient can take. Using the uniform prior in the following example, you would expect the Bayesian estimates to resemble the classical results of maximizing the likelihood. If you can elicit an informative prior distribution for the regression coefficients, you should use the COEFFPRIOR= option to specify it. A default noninformative gamma prior is used for the scale parameter .

You should make sure that the posterior distribution samples have achieved convergence before using them for Bayesian inference. PROC GENMOD produces three convergence diagnostics by default. If ODS Graphics is enabled as specified in the following SAS statements, diagnostic plots are also displayed. See the section Assessing Markov Chain Convergence in Chapter 7: Introduction to Bayesian Analysis Procedures, for more information about convergence diagnostics and their interpretation.

Summary statistics of the posterior distribution samples are produced by default. However, these statistics might not be sufficient for carrying out your Bayesian inference, and further processing of the posterior samples might be necessary. The following SAS statements request the Bayesian analysis, and the OUTPOST= option saves the samples in the SAS data set PostSurg for further processing:

proc genmod data=Surg;
   model y = Logx1 X2 X3 X4 / dist=normal;
   bayes seed=1 OutPost=PostSurg;
run;

The results of this analysis are shown in the following figures. The "Model Information" table in Figure 45.8 summarizes information about the model you fit and the size of the simulation.

Figure 45.8: Model Information

The GENMOD Procedure
 
Bayesian Analysis

Model Information
Data SetWORK.SURG 
Burn-In Size2000 
MC Sample Size10000 
Thinning1 
Sampling AlgorithmConjugate 
DistributionNormal 
Link FunctionIdentity 
Dependent VariableySurvival Time


The "Analysis of Maximum Likelihood Parameter Estimates" table in Figure 45.9 summarizes maximum likelihood estimates of the model parameters.

Figure 45.9: Maximum Likelihood Parameter Estimates

Analysis Of Maximum Likelihood Parameter Estimates
ParameterDFEstimateStandard
Error
Wald 95% Confidence Limits
Intercept1-730.55985.4333-898.005-563.112
Logx11171.875838.225096.9561246.7954
x214.30190.55663.21095.3929
x314.03090.49963.05175.0100
x4118.137712.0721-5.523241.7986
Scale159.85915.759949.570572.2832

Note:The scale parameter was estimated by maximum likelihood.



Since no prior distributions for the regression coefficients were specified, the default noninformative uniform distributions shown in the "Uniform Prior for Regression Coefficients" table in Figure 45.10 are used. Noninformative priors are appropriate if you have no prior knowledge of the likely range of values of the parameters, and if you want to make probability statements about the parameters or functions of the parameters. See, for example, Ibrahim, Chen, and Sinha (2001) for more information about choosing prior distributions.

Figure 45.10: Regression Coefficient Priors

The GENMOD Procedure
 
Bayesian Analysis

Uniform Prior for Regression
Coefficients
ParameterPrior
InterceptConstant
Logx1Constant
x2Constant
x3Constant
x4Constant


The default noninformative improper prior distribution for the normal dispersion parameter is shown in the "Independent Prior Distributions for Model Parameters" table in Figure 45.11.

Figure 45.11: Scale Parameter Prior

Independent Prior Distributions
for Model Parameters
ParameterPrior Distribution
DispersionImproper


By default, the maximum likelihood estimates of the regression parameters are used as the starting values for the simulation when noninformative prior distributions are used. These are listed in the "Initial Values and Seeds" table in Figure 45.12.

Figure 45.12: MCMC Initial Values and Seeds

Initial Values of the Chain
ChainSeedInterceptLogx1x2x3x4Dispersion
11-730.559171.87584.3018964.03087818.13773449.176


Summary statistics for the posterior sample are displayed in the "Fit Statistics," "Descriptive Statistics for the Posterior Sample," "Interval Statistics for the Posterior Sample," and "Posterior Correlation Matrix" tables in Figure 45.13, Figure 45.14, Figure 45.15, and Figure 45.16, respectively.

Figure 45.13: Fit Statistics

Fit Statistics
DIC (smaller is better)607.796
pD (effective number of parameters)6.062


Figure 45.14: Descriptive Statistics

The GENMOD Procedure
 
Bayesian Analysis

Posterior Summaries
ParameterNMeanStandard
Deviation
Percentiles
25%50%75%
Intercept10000-730.091.2102-789.6-729.6-670.5
Logx110000171.740.6455144.2171.6198.6
x2100004.29880.59523.90294.29194.6903
x3100004.03080.53593.66414.02674.3921
x41000018.085812.91239.447118.123026.8141
Dispersion100004113.1867.73497.23995.94606.4


Figure 45.15: Interval Statistics

Posterior Intervals
ParameterAlphaEqual-Tail IntervalHPD Interval
Intercept0.050-908.6-549.8-906.9-549.1
Logx10.05091.9723252.594.1279254.0
x20.0503.10915.47783.17055.5167
x30.0502.98035.10312.92275.0343
x40.050-7.304343.6387-8.844041.8229
Dispersion0.0502741.56096.62540.15810.0


Figure 45.16: Posterior Sample Correlation Matrix

Posterior Correlation Matrix
ParameterInterceptLogx1x2x3x4Dispersion
Intercept1.000-0.857-0.579-0.7120.5820.000
Logx1-0.8571.0000.2860.491-0.6400.007
x2-0.5790.2861.0000.302-0.489-0.009
x3-0.7120.4910.3021.000-0.618-0.006
x40.582-0.640-0.489-0.6181.0000.003
Dispersion0.0000.007-0.009-0.0060.0031.000


Since noninformative prior distributions were used, the posterior sample means, standard deviations, and interval statistics shown in Figure 45.13 and Figure 45.14 are consistent with the maximum likelihood estimates shown in Figure 45.9.

By default, PROC GENMOD computes three convergence diagnostics: the lag1, lag5, lag10, and lag50 autocorrelations (Figure 45.17); Geweke diagnostic statistics (Figure 45.18); and effective sample sizes (Figure 45.19). There is no indication that the Markov chain has not converged. See the section Assessing Markov Chain Convergence in Chapter 7: Introduction to Bayesian Analysis Procedures, for more information about convergence diagnostics and their interpretation.

Figure 45.17: Posterior Sample Autocorrelations

The GENMOD Procedure
 
Bayesian Analysis

Posterior Autocorrelations
ParameterLag 1Lag 5Lag 10Lag 50
Intercept-0.0059-0.0037-0.01520.0010
Logx1-0.0002-0.0064-0.0066-0.0054
x2-0.0120-0.0026-0.0267-0.0168
x30.00360.0033-0.00350.0004
x40.0034-0.00640.0083-0.0124
Dispersion-0.00110.0091-0.02790.0037


Figure 45.18: Geweke Diagnostic Statistics

Geweke Diagnostics
ParameterzPr > |z|
Intercept-1.08150.2795
Logx11.66670.0956
x20.09770.9222
x30.25060.8021
x4-1.10820.2678
Dispersion0.24510.8064


Figure 45.19: Effective Sample Sizes

Effective Sample Sizes
ParameterESSAutocorrelation
Time
Efficiency
Intercept10000.01.00001.0000
Logx110000.01.00001.0000
x210245.20.97611.0245
x310000.01.00001.0000
x410000.01.00001.0000
Dispersion10000.01.00001.0000


Trace, autocorrelation, and density plots for the seven model parameters, shown in Figure 45.20 through Figure 45.25, are useful in diagnosing whether the Markov chain of posterior samples has converged. These plots show no evidence that the chain has not converged. See the section Visual Analysis via Trace Plots in Chapter 7: Introduction to Bayesian Analysis Procedures, for help with interpreting these diagnostic plots.

Figure 45.20: Diagnostic Plots for Intercept

Diagnostic Plots for


Figure 45.21: Diagnostic Plots for logX1

Diagnostic Plots for


Figure 45.22: Diagnostic Plots for X2

Diagnostic Plots for


Figure 45.23: Diagnostic Plots for X3

Diagnostic Plots for


Figure 45.24: Diagnostic Plots for X4

Diagnostic Plots for


Figure 45.25: Diagnostic Plots for X5

Diagnostic Plots for


Suppose, for illustration, a question of scientific interest is whether blood clotting score has a positive effect on survival time. Since the model parameters are regarded as random quantities in a Bayesian analysis, you can answer this question by estimating the conditional probability of being positive, given the data, , from the posterior distribution samples. The following SAS statements compute the estimate of the probability of being positive:

data Prob;
   set PostSurg;
   Indicator = (logX1 > 0);
   label Indicator= 'log(Blood Clotting Score) > 0';
run;

proc Means data = Prob(keep=Indicator) n mean;
run;

As shown in Figure 45.26, there is a 1.00 probability of a positive relationship between the logarithm of a blood clotting score and survival time, adjusted for the other covariates.

Figure 45.26: Probability That

The MEANS Procedure

Analysis Variable : Indicator
log(Blood Clotting Score)
> 0
NMean
100000.9999000