Introduction to Bayesian Analysis Using SAS R Software

Size: px
Start display at page:

Download "Introduction to Bayesian Analysis Using SAS R Software"

Transcription

1 Introduction to Bayesian Analysis Using SAS R Software Joseph G. Ibrahim Department of Biostatistics University of North Carolina

2 Introduction to Bayesian statistics Outline 1 Introduction to Bayesian statistics Background and concepts in Bayesian methods Prior distributions Advanced computational methods Convergence diagnostics and summary statistics Discussion and summary 2 The GENMOD, LIFEREG, and PHREG procedures 1 / 158

3 Introduction to Bayesian statistics Background and concepts in Bayesian methods Why Bayesian, Why Now? Philosophical differences aside, there are practical reasons that drive the recent popularity of Bayesian analysis. Simplicity in thinking about problems and answering scientific questions Flexibility in making inference on a wide range of models, such as data augmentation and hierarchical models Incorporation of prior information Heavy promotion by both practitioners and theoretical statisticians Development of efficient inference and sampling tools Fast computers 2 / 158

4 Introduction to Bayesian statistics Background and concepts in Bayesian methods Historical Highlights Bayes theorem was developed by the Reverend Thomas Bayes ( ). His paper was published in 1763, posthumously. He formulated a way to solve the question of inverse probability: after observing a collection of Events, what is Pr(one Event)? Given a probability distribution of p(x θ), where x is an observable quantity, the inverse probability is the probability distribution of an unobserved variable θ given x, p(θ x). The term Bayesian was coined around 1950, by R. A. Fisher. Some famous statisticians who laid foundation for modern Bayesian statistics: Harold Jeffreys, Bruno de Finetti, Frank Ramsey, Edwin Jaynes, L.J. Savage, B.O. Koopman, and so on. 3 / 158

5 Introduction to Bayesian statistics Background and concepts in Bayesian methods Two Different Points of View 1 Frequentist/Classical Probabilities are objective properties of the real world. Probability refers to limiting relative frequencies. Parameters θ are fixed, unknown constants. Statistical procedures should be designed to have well-defined long-run frequency properties, such as the confidence interval. 1 Wasserman / 158

6 Introduction to Bayesian statistics Background and concepts in Bayesian methods Two Different Points of View Bayesian Probability describes degree of belief, not limiting frequency. The probability of an event is the degree to which you believe that the event is true. It is subjective. Parameters cannot be determined exactly. They are random variables, and you can make probability statements about them. Inferences about θ are based on the probability distribution for the parameter. 5 / 158

7 Introduction to Bayesian statistics Background and concepts in Bayesian methods The Bayesian Method Given data x = {x 1,..., x n }, Bayesian inference is carried out in the following way: 1 You choose a prior distribution π(θ) for θ. The distribution describes your beliefs about the parameter before you examine the data. 2 Given the observed data x, you select a model (density) f (x θ) to describe the distribution of x given θ. The Likelihood function is any function proportional to f (x θ); that is, L(θ) f (x θ). 3 You update your beliefs about θ by combining information from the prior distribution and the data through the calculation of the posterior distribution π(θ x). The paradigm can be thought as a transformation from the before to the after: π(θ) π(θ x) 6 / 158

8 Introduction to Bayesian statistics Background and concepts in Bayesian methods The Bayesian Method Given data x = {x 1,..., x n }, Bayesian inference is carried out in the following way: 1 You choose a prior distribution π(θ) for θ. The distribution describes your beliefs about the parameter before you examine the data. 2 Given the observed data x, you select a model (density) f (x θ) to describe the distribution of x given θ. The Likelihood function is any function proportional to f (x θ); that is, L(θ) f (x θ). 3 You update your beliefs about θ by combining information from the prior distribution and the data through the calculation of the posterior distribution π(θ x). The paradigm can be thought as a transformation from the before to the after: π(θ) π(θ x) 6 / 158

9 Introduction to Bayesian statistics Background and concepts in Bayesian methods Bayes Theorem The updating of beliefs is carried out by using Bayes theorem, which enables you to combine the prior and the model in the following way: π(θ x) = π(θ, x) π(x) = f (x θ)π(θ) π(x) = f (x θ)π(θ) f (x θ)π(θ)dθ The marginal distribution π(x) is an integral that is often ignored (as long as it is finite). Hence π(θ x) is often written as: π(θ x) f (x θ)π(θ) = L(θ)π(θ) All inferences are based on the posterior distribution. 7 / 158

10 Introduction to Bayesian statistics Background and concepts in Bayesian methods Bayesian Thinking in Real Life You suspect you might have a fever and decide to take your temperature. 1 A possible prior density on your temperature θ: likely normal (centered at 98.6) but possibly sick (centered at 101). 2 Suppose the thermometer says 101 degrees: f (x θ) N(θ, σ 2 ) where σ could be a very small number. 3 You get the posterior distribution. Yes, you are sick. 8 / 158

11 Introduction to Bayesian statistics Background and concepts in Bayesian methods Inference Some basic inferences are point estimation, interval estimation, and hypothesis testing. Classical Estimator: MLE, MOME, least square estimator, and so on. Bayesian All inference about θ is based on π(θ x). Estimator: mean, mode, median, any point from π(θ x). For example, the posterior mean of θ is given by E(θ x) = θ π(θ x)dθ The posterior mode of θ is the value of θ that maximizes π(θ x). Θ 9 / 158

12 Introduction to Bayesian statistics Background and concepts in Bayesian methods Interval Estimation Classical: Estimator: confidence intervals Nice properties: coverage probability, minimize false coverage (uniformly most accurate), unbiasedness, and so on. A CI of 100(1 α)% asserts that, in the long run, 100(1 α)% of the realized confidence intervals cover the true parameter. You cannot say The true parameter is in the CI with probability 95%. The true parameter is either in or outside of a CI, not with any measurable probability. The interpretation reflects the uncertainty in the sampling procedure the parameter is fixed, but the interval is random. 10 / 158

13 Introduction to Bayesian statistics Background and concepts in Bayesian methods Interval Estimation Bayesian: Estimator: credible sets any set A such that P(θ A x) = A π(θ x)dθ Equal tail: 100(α/2)th and 100(1 α/2)th percentiles. Highest posterior density (HPD): 1 Posterior probability is 100(1 α)% 2 For θ 1 A and θ 2 / A, π(θ 1 x) π(θ 2 x). The smallest region can be disjoint. Interpretation: There is a 95% chance that the parameter is in this interval. The parameter is random, not fixed. 11 / 158

14 Introduction to Bayesian statistics Background and concepts in Bayesian methods Interval Estimation Bayesian: Estimator: credible sets any set A such that P(θ A x) = A π(θ x)dθ Equal tail: 100(α/2)th and 100(1 α/2)th percentiles. Highest posterior density (HPD): 1 Posterior probability is 100(1 α)% 2 For θ 1 A and θ 2 / A, π(θ 1 x) π(θ 2 x). The smallest region can be disjoint. Interpretation: There is a 95% chance that the parameter is in this interval. The parameter is random, not fixed. 12 / 158

15 Introduction to Bayesian statistics Background and concepts in Bayesian methods Hypothesis Testing Classical: Methods of finding tests: likelihood ratio test, and so on. Method of evaluation: power, control Type I error, most powerful, and so on. Bayesian: Test: P Θ X (H 0 x)/p Θ X (H 1 x) (posterior odds). Accept H 0 if P Θ X (H 0 x)/p Θ X (H 1 x) > c. Posterior odds can be quite sensitive to the prior distributions. To correct for prior influence: P Θ X (H 0 x)/p Θ X (H 1 x) π Θ (H 0 )/π Θ (H 1 ). This is called the Bayes factor. 13 / 158

16 Introduction to Bayesian statistics Prior distributions Outline 1 Introduction to Bayesian statistics Background and concepts in Bayesian methods Prior distributions Advanced computational methods Convergence diagnostics and summary statistics Discussion and summary 14 / 158

17 Introduction to Bayesian statistics Prior distributions Prior Distributions The prior distribution represents your belief before seeing the data. Bayesian probability measures the degree of belief that you have in a random event. By this definition, probability is highly subjective. It follows that all priors are subjective priors. Not everyone agrees with the preceding. Some people would like to obtain results that are objectively valid, such as, Let the data speak for itself.. This approach advocates noninformative (flat/improper/jeffreys) priors. Subjective approach advocates informative priors, which can be extraordinarily useful, if used correctly. 15 / 158

18 Introduction to Bayesian statistics Prior distributions Noninformative Priors A prior is noninformative if it is flat relative to the likelihood function. Thus, a prior π(θ) is noninformative if it has minimal impact on the posterior of θ. Many people like noninformative priors because they appear to be more objective. However, it is unrealistic to think that noninformative priors represent total ignorance about the parameter of interest. A frequent noninformative prior is π(θ) 1, which assigns equal likelihood to all possible values of the parameter. 16 / 158

19 Introduction to Bayesian statistics Prior distributions A Binomial Example Suppose that you observe 14 heads in 17 tosses. The likelihood is: L(p) p x (1 p) n x with x = 14 and n = 17. A flat prior on p is: π(p) = 1 The posterior distribution is: which is a beta(15, 4). π(p x) p 14 (1 p) 3 17 / 158

20 Introduction to Bayesian statistics Prior distributions Binomial with a Flat Prior In the binomial example, the posterior distribution is identical to the likelihood function if a flat prior is used. 18 / 158

21 Introduction to Bayesian statistics Prior distributions Flat Prior If π(θ x) L(θ) with π(θ) 1, then why not use the flat prior all the time? The short answer is: Using a flat prior does not always guarantee a proper (integrable) posterior distribution; that is, π(θ x)dθ <. The reason is that the likelihood function is only proper w.r.t. the random variable X. But a posterior has to be integrable w.r.t. θ, a condition not required by the likelihood function. In cases where the likelihood function and the posterior distribution are identical, very different approaches are used to carry out inferences. 19 / 158

22 Introduction to Bayesian statistics Prior distributions Two Ways of Making Inferences Classical inference typically uses asymptotic results; Bayesian inference is based on exploring the entire distribution. 20 / 158

23 Introduction to Bayesian statistics Prior distributions Jeffreys Prior Jeffreys prior is defined as π(θ) I(θ) 1/2 where denotes the determinant and I(θ) is the expected Fisher information matrix based on the likelihood function p(x θ): [ 2 ] log p(x θ) I(θ) = E θ 2 21 / 158

24 Introduction to Bayesian statistics Prior distributions Jeffreys Prior, Binomial Example The likelihood and log likelihood functions are: and The two derivatives are: L(p) p x (1 p) n x l(p) = x log(p) + (n x) log(1 p) lp p = x p n x (1 p) and 2 lp p 2 = x p 2 n x (1 p) 2 22 / 158

25 Introduction to Bayesian statistics Prior distributions Jeffreys Prior, Binomial Example The negative expected Fisher information, using E(X ) = np, is I(p) = n p(1 p) Jeffreys prior is π(p) p 1/2 (1 p) 1/2 The posterior distribution is L(p)π(p) p x 1 2 (1 p) n x 1 2 Beta(15.5, 4.5) 23 / 158

26 Introduction to Bayesian statistics Prior distributions Jeffreys Prior 24 / 158

27 Introduction to Bayesian statistics Prior distributions Informative Priors An informative prior is a prior that is not dominated by the likelihood and that has an impact on the posterior distribution. The proper use of prior distributions illustrates the power of the Bayesian method: information gathered from a previous study, past experience, or expert opinion can be combined with current information in a natural way. They are reasonable priors to use if one has real prior information from a previous similar study. Informative priors must be specified with care in actual practice. Otherwise, you can get misleading results. 25 / 158

28 Introduction to Bayesian statistics Prior distributions Priors Can Be Too Informative! 26 / 158

29 Introduction to Bayesian statistics Advanced computational methods Outline 1 Introduction to Bayesian statistics Background and concepts in Bayesian methods Prior distributions Advanced computational methods Convergence diagnostics and summary statistics Discussion and summary 27 / 158

30 Introduction to Bayesian statistics Advanced computational methods Advanced Computational Methods For many models, including GLMs, nonlinear models, random-effects models, survival models, and so on, the posterior distribution does not have a closed form. In these cases, exact inference is not possible. You need to resort to approximation or sampling-based methods: 1 Asymptotic methods, like Laplace approximation 2 Direct simulation, such as inverse CDF 3 Importance sampling and rejection sampling 4 Stochastic simulation methods such as Markov chain Monte Carlo (MCMC) 28 / 158

31 Introduction to Bayesian statistics Advanced computational methods Markov Chain Monte Carlo Markov Chain: a stochastic process that generates conditional independent samples according to some target distribution. Monte Carlo: a numerical integration technique that finds an expectation: E(f (θ)) = f (θ)p(θ)dθ = 1 n with θ 1, θ 2,, θ n being samples from p(θ). n f (θ i ) MCMC is a method that generates a sequence of dependent samples from the target distribution and computes quantities by using Monte Carlo based on these samples. The most well-known algorithms are the Metropolis and Gibbs samplers. i=1 29 / 158

32 Introduction to Bayesian statistics Advanced computational methods Gibbs Sampler Gibbs sampler is an algorithm that sequentially generates samples from a joint distribution of two or more random variables. The sampler is often used when: The joint distribution, π(θ x), is not known explicitly The full conditional distribution of each parameter for example, π(θ i θ j, i j, x) is known 30 / 158

33 Introduction to Bayesian statistics Advanced computational methods Gibbs Sampler 1 Set t = 0, and choose an arbitrary initial value of θ (0) = {θ (0) 1,..., θ(0) k }. 2 Generate each component of θ as follows: Draw θ (t+1) 1 from π(θ 1 θ (t) 2,..., θ(t) k, x) Draw θ (t+1) 2 from π(θ 2 θ (t+1) 1, θ (t) 3,..., θ(t) k, x)... Draw θ (t+1) k from π(θ k θ (t+1) 1,..., θ (t+1) k 1, x) 3 Set t = t + 1. If t < T, the number of desired samples, return to step 2. Otherwise, stop. 31 / 158

34 Introduction to Bayesian statistics Advanced computational methods Gibbs Sampler 32 / 158

35 Introduction to Bayesian statistics Advanced computational methods Gibbs Sampler 33 / 158

36 Introduction to Bayesian statistics Advanced computational methods Gibbs Sampler 34 / 158

37 Introduction to Bayesian statistics Advanced computational methods Gibbs Sampler 35 / 158

38 Introduction to Bayesian statistics Advanced computational methods Gibbs Sampler 36 / 158

39 Introduction to Bayesian statistics Advanced computational methods Gibbs Sampler This works remarkably well in practice because: (θ (t) 1,, θ(t) d m ) [θ 1,, θ m ] as t Under mild conditions (Besag 1974), the one-dimensional conditional distributions uniquely determine the full joint distribution π(θ x) and hence all marginal posterior distributions π(θ i x). You can always find the (proportional) conditional distribution for any parameter: π(θ i θ j, i j, x) p(x θ)π(θ) Rejection sampling is a popular method to generate samples from low-dimensional (one-dimensional) distributions. 37 / 158

40 Introduction to Bayesian statistics Convergence diagnostics and summary statistics Outline 1 Introduction to Bayesian statistics Background and concepts in Bayesian methods Prior distributions Advanced computational methods Convergence diagnostics and summary statistics Discussion and summary 38 / 158

41 Introduction to Bayesian statistics Convergence diagnostics and summary statistics Markov Chain Convergence The importance of convergence diagnostics is obvious. An unconverged Markov chain does not explore the parameter space efficiently and the samples cannot approximate the target distribution well. Inference should not be based upon unconverged Markov chain, or very misleading results could be obtained. It is important to remember: Convergence should be checked for ALL parameters, and not just those of interest. There are no definitive tests of convergence. Diagnostics are often not sufficient for convergence. 39 / 158

42 Introduction to Bayesian statistics Convergence diagnostics and summary statistics Convergence Terminology Convergence: initial drift in the samples towards a stationary (target) distribution Burn-in: samples at start of the chain that are discarded to minimize their impact on the posterior inference Slow mixing: tendency for high autocorrelation in the samples. A slow-mixing chain does not traverse the parameter space efficiently. Thinning: the practice of collecting every kth iteration to reduce autocorrelation. Thinning a Markov chain can be wasteful because you are throwing away a k 1 k fraction of all the posterior samples generated. Trace plot: plot of sampled values of a parameter versus iteration number. 40 / 158

43 Introduction to Bayesian statistics Convergence diagnostics and summary statistics Some Convergence Diagnostics Tests SAS Provides Name Description Interpretation Gelman-Rubin Uses parallel chains with dispersed initial values to test whether they all converge to the same target distribution. One-sided test based on a variance ratio test statistic. Large R c values indicate rejection. Failure could indicate the presence of a multimode posterior distribution or the need to run a longer chain. Geweke Tests whether the mean estimates have converged by comparing means from the early and latter part of the Markov chain. Two-sided test based on a z-score statistic. Large absolute z values indicate rejection. 41 / 158

44 Introduction to Bayesian statistics Convergence diagnostics and summary statistics Convergence Diagnostics Tests (continued) Name Description Interpretation Heidelberger- Tests whether the Markov One-sided test based on a Welch stationarity chain is a covariance Cramer-von Mises statis- (weakly) stationary process. tic. Small p-values indi- test cate rejection. Heidelberger- Reports whether the sample If relative half-width Welch size is adequate to meet statistic is greater than a halfwidth the required accuracy for the predetermined accuracy test mean estimate. measure, this indicates rejection. Raftery-Lewis Evaluates the accuracy of the estimated (desired) percentiles by reporting the number of samples needed to reach the desired accuracy of the percentiles. If the total samples needed are less than the Markov chain sample, this indicates rejection. 42 / 158

45 Introduction to Bayesian statistics Convergence diagnostics and summary statistics Graphical Display 43 / 158

46 Introduction to Bayesian statistics Convergence diagnostics and summary statistics Graphical Display (Burn-In Needed?) 44 / 158

47 Introduction to Bayesian statistics Convergence diagnostics and summary statistics Graphical Display (Thinning Needed?) 45 / 158

48 Introduction to Bayesian statistics Convergence diagnostics and summary statistics Graphical Display (No Convergence) 46 / 158

49 Introduction to Bayesian statistics Convergence diagnostics and summary statistics More on Convergence Diagnosis There are no definitive tests of convergence. With experience, visual inspection of trace plots is often the most useful approach. Geweke and Heidelberger-Welch sometimes reject even when the trace plots look good. Oversensitivity to minor departures from stationarity does not impact inferences. Different convergence diagnostics are designed to protect you against different potential pitfalls. 47 / 158

50 Introduction to Bayesian statistics Convergence diagnostics and summary statistics How to Summarize Results from the MCMC Samples? SAS Bayesian procedures report: Point estimates: mean, standard deviation, percentiles Interval estimates: equal-tail intervals and HPD intervals Posterior covariance and correlation matrices Effective sample sizes, Monte Carlo standard errors, fit statistics Kernel density estimation of the marginal posterior In some cases, summary statistics on functions of parameters, such as the hazard ratios. 48 / 158

51 Introduction to Bayesian statistics Convergence diagnostics and summary statistics Effective Sample Size ESS is commonly used as a measure of how well a Markov chain is mixing. ESS = n (n 1) k=1 ρ k (θ) where n is the total sample size and ρ k (θ) is the autocorrelation of lag k for θ. The closer ESS is to n, the better mixing is in the Markov chain. 49 / 158

52 Introduction to Bayesian statistics Convergence diagnostics and summary statistics Deviance Information Criterion DIC is a Bayesian alternative to AIC and BIC, a model assessment and selection tool. The criterion can be applied to non-nested models and models that have non-iid data. A smaller DIC indicates a better fit to the data. 50 / 158

53 Introduction to Bayesian statistics Convergence diagnostics and summary statistics Deviance Information Criterion (DIC) where DIC = D(θ) + p D = D(θ) + 2p D D(θ) = 2 (log(f (y)) log(p(y θ))) is the deviance where p(y θ) is the likelihood function f (y) is a constant term that is not calculated D(θ) is posterior mean of the deviance, approximated by 1 n n t=1 D(θt ). The expected deviation measures how well the model fits the data. D(θ) is the deviance evaluated at θ, equal to 2 log(p(y θ)). It is the deviance evaluated at your best posterior estimate. p D is the effective number of parameters. 51 / 158

54 Introduction to Bayesian statistics Discussion and summary Strengths of Bayesian Methods Provide a natural and principled way of combining prior information with data, within a solid decision-theoretical framework. All inferences logically follow from Bayes theorem and are based on the posterior distribution. Provide inferences that are conditional on the data and are exact, without reliance on either asymptotic approximation or the plug-in principle. Small sample inference proceeds in the same manner as if you had a large sample. Obey the likelihood principle. 52 / 158

55 Introduction to Bayesian statistics Discussion and summary Strengths of Bayesian Methods Provide interpretable answers, such as the true parameter θ has a probability of 0.95 of falling in a 95% credible interval. Bayesian analysis can answer specific scientific questions directly. Provide a convenient setting for a wide range of models, such as hierarchical models and missing data problems. MCMC, along with other numerical methods, makes computations tractable for virtually all parametric models. 53 / 158

56 Introduction to Bayesian statistics Discussion and summary Weaknesses of Bayesian Methods Do not tell you how to select a prior. Bayesian inferences require skills to translate subjective prior beliefs into a mathematically formulated prior. If you do not proceed with caution, you can generate misleading results. Can produce posterior distributions that are heavily influenced by the priors. Often come with a high computational cost, especially in models with a large number of parameters. In addition, simulations provide slightly different answers unless the same random seed is used. Do not produce credible intervals that are guaranteed to have the right coverage property, as the classical confidence intervals do. 54 / 158

57 Introduction to Bayesian statistics Discussion and summary A Short List of Bayesian Text Books Bolstad, W. M. (2007), Introduction to Bayesian Statistics, 2nd ed. New York: John Wiley & Sons. Lee, P. M. (2004), Bayesian Statistics: An Introduction, 3rd ed. London: Arnold. Gelman, A., Carlin, J. B., Stern, H. S., and Rubin, D. B. (2004), Bayesian Data Analysis, 3rd ed. London: Chapman & Hall. Robert, C. P. and Casella, G. (2004), Monte Carlo Statistical Methods, 2nd ed. New York: Springer-Verlag. Carlin, B. and Louris, T. A. (2000), Bayes and Empirical Bayes Methods for Data Analysis, 2nd ed. London: Chapman & Hall. The Introduction to Bayesian Analysis Procedures section (in the SAS/STAT R User s Guide) contains a Bayesian Reading List with comprehensive references. 55 / 158

58 The GENMOD, LIFEREG, and PHREG procedures Outline 1 Introduction to Bayesian statistics 2 The GENMOD, LIFEREG, and PHREG procedures Overview Prior distributions The BAYES statement GENMOD: linear regression GENMOD: binomial model PHREG: Cox model PHREG: piecewise exponential model LIFEREG: Weibull and exponential models (optional) Summary 56 / 158

59 The GENMOD, LIFEREG, and PHREG procedures Overview The GENMOD, LIFEREG, and PHREG Procedures These three procedures provide: The BAYES statement (which carries out Bayesian analysis) as production in SAS 9.2 The BAYES statement as experimental in SAS (available as a Windows download) A set of frequently used prior distributions, posterior summary statistics, and convergence diagnostics Adaptive rejection (Gilks and Wild 1992; Gilks, Best, and Tan 1995) as a sampling method 57 / 158

60 The GENMOD, LIFEREG, and PHREG procedures Overview GENMOD Procedure PROC GENMOD provides Bayesian analysis for: Distributions: binomial, gamma, inverse-gaussian, negative binomial, normal, and Poisson Links: identity, log, logit, probit, complementary log-log, and power The procedure currently does not provide Bayesian analysis for: Distributions: multinomial Links: CCLL, CLogit, Cprobit Model parameters are the regression coefficients and dispersion (or the precision or scale) parameter, if the model has one. 58 / 158

61 The GENMOD, LIFEREG, and PHREG procedures Overview LIFEREG Procedure PROC LIFEREG provides analyses for parametric lifetime models for: Distributions: exponential, 3-parameter gamma, log-logistic, log-normal, logistic, normal, and Weibull The procedure currently does not provide Bayesian analysis for the binomial distribution. Model parameters are the regression coefficients and dispersion (or the precision or scale) parameter, if the model has one. 59 / 158

62 The GENMOD, LIFEREG, and PHREG procedures Overview PHREG Procedure PROC PHREG provides analysis for Bayesian semiparametric survival models: Cox regression models: use the partial likelihood as the likelihood (Sinha, Ibrahim, and Chen, 2003), time-independent and time-dependent, all TIES= methods Piecewise exponential models The Bayesian functionality in PROC PHREG currently does not fit models with certain data constraints for example, data that include recurrent events. Model parameters are the regression coefficients and hazards (piecewise exponential models). 60 / 158

63 The GENMOD, LIFEREG, and PHREG procedures Prior distributions Outline 2 The GENMOD, LIFEREG, and PHREG procedures Overview Prior distributions The BAYES statement GENMOD: linear regression GENMOD: binomial model PHREG: Cox model PHREG: piecewise exponential model LIFEREG: Weibull and exponential models (optional) Summary 61 / 158

64 The GENMOD, LIFEREG, and PHREG procedures Prior distributions Prior Distributions in SAS Procedures Uniform (or flat )prior is defined as: π(θ) 1 This prior is not integrable, but it does not lead to improper posterior in any of the procedures. Improper prior is defined as: π(θ) 1 θ This prior is often used as a noninformative prior on the scale parameter, and it is uniform on the log-scale. Proper prior distributions include gamma, inverse-gamma, AR(1)-gamma, normal, multivariate normal densities. Jeffreys prior is provided in PROC GENMOD. 62 / 158

65 The GENMOD, LIFEREG, and PHREG procedures Prior distributions GENMOD: Parameters and Priors Priors supported: regression coefficients dispersion scale, precision Jeffreys, normal, and uniform gamma, inverse-gamma, and improper gamma, improper The dispersion and regression parameters are assumed to be independent, except in the linear regression case. 63 / 158

66 The GENMOD, LIFEREG, and PHREG procedures Prior distributions LIFEREG: Parameters and Priors Priors supported: regression coefficients scale 3-parameter gamma shape normal and uniform gamma and improper gamma and improper The dispersion and regression parameters are assumed to be independent. 64 / 158

67 The GENMOD, LIFEREG, and PHREG procedures Prior distributions PHREG: Parameters and Priors Piecewise exponential: Regression coefficients (β): normal and uniform priors Log hazards (α = log(λ)): uniform and normal priors Regression and log hazards: multivariate normal (do not need to be independent) Hazards (λ): improper, uniform, independent gamma, and AR(1) priors Cox: uniform and normal priors on the regression coefficients 65 / 158

68 The GENMOD, LIFEREG, and PHREG procedures The BAYES statement Outline 2 The GENMOD, LIFEREG, and PHREG procedures Overview Prior distributions The BAYES statement GENMOD: linear regression GENMOD: binomial model PHREG: Cox model PHREG: piecewise exponential model LIFEREG: Weibull and exponential models (optional) Summary 66 / 158

69 The GENMOD, LIFEREG, and PHREG procedures The BAYES statement Syntax for the BAYES Statement The BAYES statement is used to request all Bayesian analysis in these procedures. BAYES < options > ; The following options appear in all BAYES statements: INITIAL= NBI= NMC= OUTPOST= SEED= THINNING= DIAGNOSTICS= PLOTS= SUMMARY= COEFFPRIOR= initial values of the chain number of burn-in iterations number of iterations after burn-in output data set for posterior samples random number generator seed thinning of the Markov chain convergence diagnostics diagnostic plots summary statistics prior for the regression coefficients 67 / 158

70 The GENMOD, LIFEREG, and PHREG procedures The BAYES statement The BAYES Statement The following options are specific to PROC GENMOD: DISPERSIONPRIOR= PRECISIONPRIOR= SCALEPRIOR= prior for the dispersion parameter prior for the precision parameter prior for the scale parameter 68 / 158

71 The GENMOD, LIFEREG, and PHREG procedures The BAYES statement The BAYES Statement The following options are specific to PROC LIFEREG: EXPONENTIALSCALEPRIOR= SCALEPRIOR= WEIBULLSCALEPRIOR= WEIBULLSHAPEPRIOR= GAMMASHAPEPRIOR= prior for the exponential scale parm prior for the scale parm prior for the Weibull scale parm prior for the Weibull shape parm prior for the gamma shape parm 69 / 158

72 The GENMOD, LIFEREG, and PHREG procedures The BAYES statement The BAYES Statement The following option is specific to PROC PHREG: PIECEWISE= details of the piecewise exponential model You can specify the number of intervals (number of hazards) or interval partitions and the prior distribution for the hazard parameters. 70 / 158

73 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Outline 2 The GENMOD, LIFEREG, and PHREG procedures Overview Prior distributions The BAYES statement GENMOD: linear regression GENMOD: binomial model PHREG: Cox model PHREG: piecewise exponential model LIFEREG: Weibull and exponential models (optional) Summary 71 / 158

74 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Regression Example Consider the model Y = β 0 + β 1 LogX 1 + ɛ where Y is the survival time, LogX 1 is log(blood-clotting score), and ɛ is a N(0, σ 2 ) error term. The default priors that PROC GENMOD uses are: π(β 0 ) 1 π(β 1 ) 1 π(σ) gamma(shape = 0.001, iscale = 0.001) 72 / 158

75 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Regression Example A subset of the data: data surg; input x1 y = 10**logy; logx1 = log(x1); datalines; ; 73 / 158

76 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Regression Example The following statements fit a Bayesian simple linear regression model: ods graphics on; proc genmod data=surg; model y = logx1 / dist=normal; bayes seed=4 outpost=post diagnostics=all summary=all; run; ods graphics off; The SEED= option specifies a random seed; the OUTPOST= option saves posterior samples to the POST data set; the DIAGNOSTICS= and SUMMARY= options request the calculation for all convergence diagnostics and summary statistics. 74 / 158

77 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Regression Example PROC GENMOD provides some classical inference, such as the MLE. Bayesian Analysis Analysis Of Maximum Likelihood Parameter Estimates Parameter DF Estimate Standard Error Wald 95% Confidence Limits Intercept logx Scale Note: The scale parameter was estimated by maximum likelihood. 75 / 158

78 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Regression Example Bayesian model information: Data Set Bayesian Analysis Model Information WORK.SURG Burn-In Size 2000 MC Sample Size Thinning 1 Distribution Link Function Normal Identity Dependent Variable y Survival Time 76 / 158

79 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Regression Example Priors on the coefficient and scale parameters: Bayesian Analysis Uniform Prior for Regression Coefficients Parameter Prior Intercept logx1 Constant Constant Independent Prior Distributions for Model Parameters Parameter Prior Distribution Hyperparameters Shape Inverse Scale Scale Gamma / 158

80 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Convergence Diagnostics 78 / 158

81 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Convergence Diagnostics 79 / 158

82 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Convergence Diagnostics 80 / 158

83 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Mixing The following are the autocorrelation and effective sample sizes. The mixing appears to be very good, which agrees with the trace plots. Bayesian Analysis Posterior Autocorrelations Parameter Lag 1 Lag 5 Lag 10 Lag 50 Intercept logx Scale Parameter Effective Sample Sizes ESS Correlation Time Efficiency Intercept logx Scale / 158

84 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Convergence The remaining convergence diagnostics tests all look good: Bayesian Analysis Gelman-Rubin Diagnostics Parameter Estimate 97.5% Bound Intercept logx Scale Raftery-Lewis Diagnostics Quantile=0.025 Accuracy=+/ Probability=0.95 Epsilon=0.001 Number of Samples Parameter Burn-in Total Minimum Dependence Factor Intercept logx Scale / 158

85 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Bayesian Analysis Geweke Diagnostics Parameter z Pr > z Intercept logx Scale Parameter Heidelberger-Welch Diagnostics Cramer-von- Mises Stat Stationarity Test p Test Outcome Iterations Discarded Intercept Passed 0 logx Passed 0 Scale Passed 0 Heidelberger-Welch Diagnostics Parameter Half-width Half-width Test Mean Relative Half-width Test Outcome Intercept Passed logx Passed Scale Passed 83 / 158

86 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Summarize Convergence Diagnostics Autocorrelation: shows low dependency among Markov chain samples ESS: values close to the sample size indicate good mixing Gelman-Rubin: values close to 1 suggest convergence from different starting values Geweke: indicates mean estimates are stabilized Raftery-Lewis: shows sufficient samples to estimate percentile within +/ accuracy Heidelberger-Welch: suggests the chain has reached stationarity and there are enough samples to estimate the mean accurately 84 / 158

87 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Posterior Inference Posterior summary and interval estimates: Parameter N Mean Bayesian Analysis Posterior Summaries Percentiles Standard Deviation 25% 50% 75% Intercept logx Scale Parameter Alpha Posterior Intervals Equal-Tail Interval HPD Interval Intercept logx Scale / 158

88 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Fit Statistics PROC GENMOD also calculates various fit statistics (both classical and Bayesian). DIC is recommended for Bayesian analysis. Bayesian Analysis Fit Statistics AIC (smaller is better) AICC (smaller is better) BIC (smaller is better) DIC (smaller is better) pd (effective number of parameters) / 158

89 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Posterior Probabilities Suppose that you are interested in knowing whether LogX 1 has a positive effect on survival time. Quantifying that measurement, you can calculate the probability β 1 > 0, which can be estimated directly from the posterior samples: Pr(β 1 > 0 Y, LogX 1) = 1 N N I (β1 t > 0) where I (β1 t > 0) = 1 if βt 1 > 0 and 0 otherwise. N = 10, 000 is the sample size in this example. t=1 87 / 158

90 The GENMOD, LIFEREG, and PHREG procedures GENMOD: linear regression Posterior Probabilities The following SAS statements calculate the posterior probability: data Prob; set Post; Indicator = (logx1 > 0); label Indicator= log(blood Clotting Score) > 0 ; run; ods select summary; proc means data = Prob(keep=Indicator) n mean; run; The probability is roughly , which strongly suggests that the slope coefficient is greater than / 158

91 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Outline 2 The GENMOD, LIFEREG, and PHREG procedures Overview Prior distributions The BAYES statement GENMOD: linear regression GENMOD: binomial model PHREG: Cox model PHREG: piecewise exponential model LIFEREG: Weibull and exponential models (optional) Summary 89 / 158

92 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Binomial model Researchers are interested in evaluating the performance of a medical procedure in a multicenter study. The following statements create a SAS data set for the treatment arm of the trials: data trials; input event n; datalines; ; event: number of deaths n: number of patients assigned to the treatment procedure 90 / 158

93 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Binomial Example Consider a simple binomial model event i binomial(n i, p) p beta(a, b) where p is the parameter of interest and a and b are hyper-parameters. Consider the following choices for a and b: Jeffreys : beta( 0.5, 0.5). uniform: beta(1, 1) You know the posterior distribution of p in closed-form. 91 / 158

94 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Noninformative Priors in the Binomial Example The uniform and Jeffreys prior distributions, with corresponding posterior distributions, in the binomial example. 92 / 158

95 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Binomial Example: Jeffreys Prior To fit the model in PROC GENMOD, use the following transformation where the parameter of interest is the intercept: p = exp β exp β 0 The prior on p needs to be transformed to the β 0 parameterization. Jeffreys prior is invariant to transformation. You can use the Jeffreys prior on the regression coefficient in PROC GENMOD: proc genmod data=trials; model event/n= / dist=b link=logit; bayes seed=7 outpost=bout1 cprior=jeffreys; run; 93 / 158

96 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Binomial Example: Jeffreys Prior Posterior summary statistics of β 0 : Parameter N Mean Bayesian Analysis Posterior Summaries Percentiles Standard Deviation 25% 50% 75% Intercept Parameter Alpha Posterior Intervals Equal-Tail Interval HPD Interval Intercept / 158

97 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Convergence Diagnostics 95 / 158

98 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Binomial Example: Jeffreys Prior Transforming the posterior samples of β 0 to p is relatively straightforward. Use the logistic function in the DATA step: data b1 (keep=iteration jefp); set bout1; jefp = logistic(b); output; run; 96 / 158

99 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Binomial Example: Uniform Prior Uniform prior on p corresponds to a logistic prior on β 0 : p beta(1, 1) π(β 0 ) = exp ( β 0 ) (1 + exp ( β 0 )) 2 PROC GENMOD does not allow a logistic prior on the regression coefficient, but a normal prior gives a good approximation: proc genmod data=trials; model event/n= / dist=b link=logit; bayes seed=7 outpost=bout2 cprior=normal(var= ); run; 97 / 158

100 The GENMOD, LIFEREG, and PHREG procedures You start with GENMOD: binomial model exp (β 0 ) p = 1 + exp (β 0 ) = exp ( β 0 ) p exp ( β 0 ) = β 0 (1 + exp ( β 0 )) 2 Do the transformation of variables, with the Jacobian: f (p) = 1 I {0 p 1} f (β 0 ) = p β 0 I{ 0 = 1 1+exp( β 0 ) 1} exp ( β 0 ) (1 + exp ( β 0 )) 2 I { β 0 } The pdf for the logistic distribution with location a and scale b is ( exp β ) / ( ( 0 a b 1 + exp β )) 0 a 2 b b with mean a and variance π2 b 2 3. You set a = 0 and b = 1 to get the standard logistic distribution. 98 / 158

101 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Simulation Results Estimated posterior distributions of p using PROC GENMOD. The estimated densities closely resemble the true densities, with minor deviation in the normal approximation prior case. 99 / 158

102 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Some Thoughts It is difficult to be truly noninformative: uniform prior on p and uniform prior on β 0 lead to different posterior distributions. 100 / 158

103 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Some Thoughts Jeffreys prior is locally uniform a prior that does not change much over the region in which the likelihood is significant and does not assume large values outside that range. Hence it is somewhat noninformative. invariant with respect to one-to-one transformations. The prior also violates the likelihood principle can be improper for many models can be difficult to construct Jeffreys priors in PROC GENMOD does not lead to improper posteriors. 101 / 158

104 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Other values of a and b? Empirical Bayes offers one solution: use the data to estimate a and b. It involves optimization w.r.t. the marginal posterior distribution of the hyperparameters, given data (with p integrated out). This distribution is beta-binomial: ( ) n Γ(b + n x)γ(a + x)γ(a + b) π(a, b x, n) = x Γ(a + b + n)γ(a)γ(b) 102 / 158

105 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Empirical Bayes Approach Optimization can be carried out, on its log-scale, using PROC NLMIXED. proc nlmixed data=trials; parms a 40 b 2000; lf = lgamma(b+n-event) + lgamma(a+event) + lgamma(a+b) - lgamma(a+b+n) - lgamma(a) - lgamma(b); model event ~ general(lf); run; It turns out that this objective function is sensitive to initial values, and has a very flat surface on a large support. Nevertheless, all converged estimates result in small a and large b. In this run, we have â = and ˆb = / 158

106 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model This Prior Might Be Too Informative The Empirical Bayes prior, beta(32.6, 2000), dominates the likelihood function. 104 / 158

107 The GENMOD, LIFEREG, and PHREG procedures GENMOD: binomial model Other Options? You can place another layer of prior distribution on the hyperparameters a and b. PROC GENMOD does not have this capability in handling multilevel hierarchical models. You can do that with PROC MCMC. Another possibility is, if a pilot study or historical data is available, construct a more informative prior, such as the power prior, in the analysis. 105 / 158

108 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Outline 2 The GENMOD, LIFEREG, and PHREG procedures Overview Prior distributions The BAYES statement GENMOD: linear regression GENMOD: binomial model PHREG: Cox model PHREG: piecewise exponential model LIFEREG: Weibull and exponential models (optional) Summary 106 / 158

109 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Cox Model Consider the data for the Veterans Administration lung cancer trial presented in Appendix 1 of Kalbfleisch and Prentice (1980). Time Therapy Cell PTherapy Age Duration KPS Status Death in days Type of therapy: standard or test Type of tumor cell: adeno, large, small, or squamous Prior therapy: yes or no Age in years Months from diagnosis to randomization Karnofsky performance scale Censoring indicator (1=censored time, 0=event time) 107 / 158

110 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Cox Model A subset of the data: OBS Therapy Cell Time Kps Duration Age Ptherapy Status 1 standard squamous no 1 2 standard squamous yes 1 3 standard squamous no 1 4 standard squamous yes 1 5 standard squamous yes 1 6 standard squamous no 1 7 standard squamous yes / 158

111 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Cox Model Some parameters are the coefficients of the continuous variables (KPS, Duration, and Age). Other parameters are the coefficients of the design variables for the categorical explanatory variables (PTherapy, Cell, and Therapy). You can use the CLASS statement in PROC PHREG to specify the categorical variables and their reference levels, such as CLASS PTherapy(ref= no ). 109 / 158

112 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Cox Model The model considered here is the Breslow partial likelihood: where L(β) = k [ i=1 t 1 < < t k are distinct event times e β j D Z j (t i ) i ] di e β Zl (ti ) l R i Z j (t i ) is the vector explanatory variables for the jth individual at time t i R i is the risk set at t i, which includes all observations that have survival time greater than or equal to t i d i is the multiplicity of failures at t i. It is the size of the set D i of individuals that fail at t i 110 / 158

113 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Cox Model The following statements fit a Cox regression model with a uniform prior on the regression coefficients: proc phreg data=valung; class PTherapy(ref= no ) Cell(ref= large ) Therapy(ref= standard ); model Time*Status(0) = KPS Duration Age PTherapy Cell Therapy; bayes seed=1 outpost=cout coeffprior=uniform plots=density; run; 111 / 158

114 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Cox Model 112 / 158

115 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Cox Model 113 / 158

116 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Cox Model: Posterior Mean Estimates Parameter N Mean Bayesian Analysis Posterior Summaries Percentiles Standard Deviation 25% 50% 75% Kps Duration Age Ptherapyyes Celladeno Cellsmall Cellsquamous Therapytest / 158

117 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Cox Model: Interval Estimates Parameter Bayesian Analysis Posterior Intervals Alpha Equal-Tail Interval HPD Interval Kps Duration Age Ptherapyyes Celladeno Cellsmall Cellsquamous Therapytest / 158

118 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Cox Model: Plotting Survival Curves Suppose that you are interested in estimating the survival curves for two individuals who have similar characteristics, with one receiving the standard treatment while the other did not. The following is saved in the SAS data set pred: OBS Ptherapy kps duration age cell therapy 1 no large standard 2 no large test 116 / 158

119 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Cox Model You can use the following statements to estimate the survival curves and save the estimates to a SAS data set: proc phreg data=valung plots(cl=hpd overlay)=survival; baseline covariates=pred out=pout; class PTherapy(ref= no ) Cell(ref= large ) Therapy(ref= standard ); model Time*Status(0) = KPS Duration Age PTherapy Cell Therapy; bayes seed=1 outpost=cout coeffprior=uniform plots=density; run; 117 / 158

120 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Cox Model: Posterior Survival Curves Estimated survival curves for the two subjects and their corresponding 95% HPD intervals. 118 / 158

121 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Hazard Ratios Hazard ratio, a ratio of two hazard functions, is a random variable functions of the parameters are random variables themselves. Therefore you can get the posterior distributions for any hazard ratios and make inference by using the distributions. The new HAZARDRATIO statement enables you to obtain customized hazard ratios. HAZARDRATIO < label > variables < / options > ; For a continuous variable: the hazard ratio compares the hazards for a given change (by default, a increase of 1 unit) in the variable. For a CLASS variable, a hazard ratio compares the hazards of two levels of the variable. This is a new statement you can use for both classical and Bayesian analyses. 119 / 158

122 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Hazard Ratios The following SAS statements fit the same Cox regression model and request three kinds of hazard ratios. proc phreg data=valung; class PTherapy(ref= no ) Cell(ref= large ) Therapy(ref= standard ); model Time*Status(0) = KPS Duration Age PTherapy Cell Therapy; bayes seed=1 outpost=vout plots=trace coeffprior=uniform; hazardratio HR 1 Therapy / at(ptherapy= yes KPS=80 duration=12 age=65 cell= small ); hazardratio HR 2 Age / unit=10 at(kps=45); hazardratio HR 3 Cell; run; 120 / 158

123 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Hazard Ratios The following results are the summary statistics of the posterior hazards between the standard therapy and the test therapy. Bayesian Analysis HR 1: Hazard Ratios for Therapy Description N Mean Therapy standard vs test At Prior=yes Kps=80 Duration=12 Age=65 Cell=small HR 1: Hazard Ratios for Therapy Quantiles Standard Deviation 25% 50% 75% % Equal-Tail Interval 95% HPD Interval / 158

124 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Hazard Ratios The following table lists the change of hazards for an increase in Age of 10 years. Description N Mean Age Unit=10 At Kps=45 Bayesian Analysis HR 2: Hazard Ratios for Age Quantiles Standard Deviation 25% 50% 75% 95% Equal-Tail Interval 95% HPD Interval / 158

125 The GENMOD, LIFEREG, and PHREG procedures PHREG: Cox model Hazard Ratios The following table lists posterior hazards between different levels in the Cell variable: Description N Mean Cell adeno vs large Cell adeno vs small Cell adeno vs squamous Cell large vs small Cell large vs squamous Cell small vs squamous Bayesian Analysis HR 3: Hazard Ratios for Cell Quantiles Standard Deviation 25% 50% 75% 95% Equal-Tail Interval 95% HPD Interval / 158

126 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Outline 2 The GENMOD, LIFEREG, and PHREG procedures Overview Prior distributions The BAYES statement GENMOD: linear regression GENMOD: binomial model PHREG: Cox model PHREG: piecewise exponential model LIFEREG: Weibull and exponential models (optional) Summary 124 / 158

127 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model Let {(t i, x i, δ i ), i = 1, 2,..., n} be the observed data. Let a 0 = 0 < a 1 <... < a J 1 < a J = be a partition of the time axis. The hazard for subject i is where h(t x i ; θ) = h 0 (t) exp(β x i ) h 0 (t) = λ j a j 1 t < a j (j = 1,..., J) The hazard for subject i in the jth time interval is h(t) = λ j exp(β x i ) a j 1 < t < a j 125 / 158

128 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model From the hazard function, first define the baseline cumulative hazard function: where H 0 (t) = J λ j j (t) j=1 0 t < a j 1 j (t) = t a j 1 a j 1 t < a j a j a j 1 t a j 126 / 158

129 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model The log likelihood is: l(λ, β) = n [ J ] δ i I (a j 1 t i < a j ) log λ j + β x i j=1 i=1 n [ J ] j (t i )λ j exp(β x i ) i=1 j=1 where δ i is the event status: { 0 if ti is a censored time δ i = 1 if t i is an event time This model has two parameter vectors: λ and β. 127 / 158

130 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model PROC PHREG supports the following priors for the piecewise exponential model: Regression coefficients (β): normal and uniform priors Hazards (λ): improper, uniform, independent gamma, and AR(1) priors Log hazards (α = log(λ)): uniform and normal priors Regression coefficients and log hazards: multivariate normal (do not need to be independent) 128 / 158

131 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model For the hazard parameter λ, you can specify the following priors: Improper: Uniform: J 1 π(λ) λ j j=1 π(λ) 1 Independent gamma: π(λ) J j=1 { } λ a j 1 j exp( λ j b j ) 129 / 158

132 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model The AR(1) gamma prior for λ 1,..., λ J is given by: λ 1 G(a 1, b 1 ) ( λ 2 λ 1 G a 2, b ) (. λ J λ J 1 G a J, The joint prior density is given by: p(λ 1,..., λ J ) λ a exp( b 1 λ 1 ) J j=2 ( bj λ 1 λ j 1 b J λ J 1 ) ) aj λ a j 1 j ( exp b ) j λ j λ j / 158

133 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model For the logarithm of hazard, α = log(λ), you can specify: Uniform: Multivariate normal: π(α) exp π(α) 1 [ 1 ] 2 (α α 0) Φ 1 0 (α α 0) You can specify a joint multivariate normal prior for (α, β): [ π(α, β) exp 1 ] 2 [(α α 0), (β β 0 ) ]Σ 1 0 [(α α 0), (β β 0 ) ] 131 / 158

134 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model Consider a randomized trial of 40 rats exposed to carcinogen: Drug X and Placebo are the treatment groups. Event of interest is death. Response is time until death. What are the effects of treatment and gender on survival? 132 / 158

135 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model A subset of the data: proc format; value Rx 1= X 0= Placebo ; data Exposed; input Days Status Trt Gender format Trt Rx.; datalines; F M F M M M F M M F ; 133 / 158

136 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model An appropriate model is the piecewise exponential. In the model: Each time interval has a constant hazard There are a total of eight intervals (PROC PHREG default) Intervals are determined by placing roughly equal number of uncensored observations in each interval The log hazard is used. It is generally more computationally stable. There are 8 λ i s and two regression coefficients. 134 / 158

137 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model The following programming statements fit a Bayesian piecewise exponential model with noninformative priors on both β and log(λ): proc phreg data=exposed; class Trt(ref= Placebo ) Gender(ref= F ); model Days*Status(0)=Trt Gender; bayes seed=1 outpost=eout piecewise=loghazard(n=8); run; The PIECEWISE= option requests the estimating of a piecewise exponential model with 8 intervals. 135 / 158

138 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model Suppose that you have some prior information w.r.t. both β and log(λ) that can be approximated well with a multivariate normal distribution. You can construct the following data set: data pinfo; input _TYPE_ $ alpha1-alpha8 trtx GenderM; datalines; Mean cov cov cov cov cov cov cov cov cov cov ; 136 / 158

139 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model The following programming statements fit a Bayesian piecewise exponential model with informative prior on both β and log(λ): proc phreg data=exposed; class Trt(ref= Placebo ) Gender(ref= F ); model Days*Status(0)=Trt Gender; bayes seed=1 outpost=eout piecewise=loghazard(n=8 prior=normal(input=pinfo)) cprior=normal(input=pinfo); run; 137 / 158

140 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model (Noninformative Analysis) Data Set Bayesian Analysis Model Information Dependent Variable Days Censoring Variable Status Censoring Value(s) 0 Model Burn-In Size 2000 MC Sample Size Thinning 1 WORK.EXPOSED Piecewise Exponential Summary of the Number of Event and Censored Values Total Event Censored Percent Censored / 158

141 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model The partition of the time intervals: Bayesian Analysis Constant Hazard Time Intervals Interval [Lower, Upper) N Event Log Hazard Parameter Alpha Alpha Alpha Alpha Alpha Alpha Alpha7 321 Infty 5 4 Alpha8 139 / 158

142 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model Posterior summary statistics: Parameter N Mean Bayesian Analysis Posterior Summaries Percentiles Standard Deviation 25% 50% 75% Alpha Alpha Alpha Alpha Alpha Alpha Alpha Alpha TrtX GenderM / 158

143 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model Interval estimates: Parameter Alpha Bayesian Analysis Posterior Intervals Equal-Tail Interval HPD Interval Alpha Alpha Alpha Alpha Alpha Alpha Alpha Alpha TrtX GenderM / 158

144 The GENMOD, LIFEREG, and PHREG procedures PHREG: piecewise exponential model Piecewise Exponential Model Hazard ratios of Treatment and Gender: hazardratio Hazard Ratio Statement 1 Trt; hazardratio Hazard Ratio Statement 2 Gender; Description N Mean Bayesian Analysis Hazard Ratio Statement 1: Hazard Ratios for Trt Quantiles Standard Deviation 25% 50% 75% 95% Equal-Tail Interval 95% HPD Interval Trt Placebo vs X Description N Mean Gender F vs M Hazard Ratio Statement 2: Hazard Ratios for Gender Quantiles Standard Deviation 25% 50% 75% 95% Equal-Tail Interval 95% HPD Interval / 158

145 The GENMOD, LIFEREG, and PHREG procedures LIFEREG: Weibull and exponential models (optional) Outline 2 The GENMOD, LIFEREG, and PHREG procedures Overview Prior distributions The BAYES statement GENMOD: linear regression GENMOD: binomial model PHREG: Cox model PHREG: piecewise exponential model LIFEREG: Weibull and exponential models (optional) Summary 143 / 158

146 The GENMOD, LIFEREG, and PHREG procedures LIFEREG: Weibull and exponential models (optional) PROC LIFEREG PROC LIFEREG formulates the survival models through an accelerated failure time (AFT) approach: y = X β + σɛ The response variable y is usually taken to be the logarithm of the survival time vector T; that is y = log(t). T can be left-, right-, or interval-censored. β is a regression parameter vector, X is a covariates matrix, σ is a dispersion parameter. The ɛ parameter represents an error distribution, which leads to different models. Model parameters are (β, σ). 144 / 158

147 The GENMOD, LIFEREG, and PHREG procedures LIFEREG: Weibull and exponential models (optional) PROC LIFEREG Suppose that y = log(t) and ɛ is an extreme value distribution. The resulting model for y is a Weibull distribution. For the Weibull regression model, the density for t i is where f (t i ) = 1 ( σ t 1 σ 1 i exp µ i σ ) exp µ i = x iβ { ( t 1 σ i exp µ i σ The exponential regression model is a special case of the Weibull model, with σ = 1. Hence the density for the survival time is f (t i ) = exp( x iβ) exp { t i exp( x iβ) } ) } 145 / 158

148 The GENMOD, LIFEREG, and PHREG procedures LIFEREG: Weibull and exponential models (optional) PROC LIFEREG Suppose that all the responses are observed. The log likelihood is L = ( ) f (ui ) log σ where u i = (y i x i β) σ and f (u i ) is the density for ɛ i. 146 / 158

149 The GENMOD, LIFEREG, and PHREG procedures LIFEREG: Weibull and exponential models (optional) PROC LIFEREG If some of the responses are left-, right-, or interval-censored, the log likelihood can be written as L = ( ) f (ui ) log + log (S(u i )) σ + log (F (u i )) + log (F (u i ) F (v i )) with sums over uncensored, right-censored, left-censored, and interval-censored observations, respectively. F (u i ) is the cdf of ɛ i, S(u i ) = 1 F (u i ), the corresponding survival function. And v i is defined as v i = (z i x i β) σ where z i is the lower end of a censoring interval. 147 / 158

150 The GENMOD, LIFEREG, and PHREG procedures LIFEREG: Weibull and exponential models (optional) PROC LIFEREG Consider the E1690 melanoma clinical trial with n = 427 subjects. Fit a parametric survival model with three covariates: Treatment (trt), age, and sex. Both trt and sex are class variables. The variable rfstime is the failure time, and rfscens is the censored time. Two models are considered: Weibull model and exponential model. A noninformative prior is used on β, and a gamma prior is used on the scale parameter. 148 / 158

151 The GENMOD, LIFEREG, and PHREG procedures LIFEREG: Weibull and exponential models (optional) PROC LIFEREG Fit Weibull and exponential models to the data proc lifereg data=e1690; class trt sex; model rfstime*rfscens(0) = trt age sex / dist=weibull; bayes seed=1 outpost=wout; run; proc lifereg data=e1690; class trt sex; model rfstime*rfscens(0) = trt age sex / dist=exponential; bayes seed=1 outpost=eout; run; 149 / 158

152 The GENMOD, LIFEREG, and PHREG procedures LIFEREG: Weibull and exponential models (optional) PROC LIFEREG Parts of PROC LIFEREG output: Bayesian Analysis Uniform Prior for Regression Coefficients Parameter Prior Intercept trt1 age sex1 Constant Constant Constant Constant Independent Prior Distributions for Model Parameters Parameter Prior Distribution Hyperparameters Scale Gamma Shape Inverse Scale / 158

153 The GENMOD, LIFEREG, and PHREG procedures LIFEREG: Weibull and exponential models (optional) Posterior Statistics from the Weibull Model Parameter N Mean Bayesian Analysis Posterior Summaries Percentiles Standard Deviation 25% 50% 75% Intercept trt age sex Scale Parameter Alpha Posterior Intervals Equal-Tail Interval HPD Interval Intercept trt age sex Scale / 158

154 The GENMOD, LIFEREG, and PHREG procedures LIFEREG: Weibull and exponential models (optional) Posterior Statistics from the Exponential Model Parameter N Mean Bayesian Analysis Posterior Summaries Percentiles Standard Deviation 25% 50% 75% Intercept trt age sex Parameter Alpha Posterior Intervals Equal-Tail Interval HPD Interval Intercept trt age sex / 158

155 The GENMOD, LIFEREG, and PHREG procedures LIFEREG: Weibull and exponential models (optional) Kernel Density Comparison Plots of the Parameters 153 / 158

156 The GENMOD, LIFEREG, and PHREG procedures LIFEREG: Weibull and exponential models (optional) PROC LIFEREG Which model fits the data better? You can use the DIC as a model selection criterion. In this case, the Weibull model (top table) gives a much smaller DIC, and it gives the better fit to the data than the exponential model. Bayesian Analysis Fit Statistics DIC (smaller is better) pd (effective number of parameters) Bayesian Analysis Fit Statistics DIC (smaller is better) pd (effective number of parameters) / 158

157 The GENMOD, LIFEREG, and PHREG procedures Summary Summary SAS has developed capabilities for Bayesian analysis in its existing generalized linear models and survival analysis software. SAS is in the process of adding more features to these procedures. Currently, the following procedure statements are ignored when the BAYES statement is specified: GENMOD LIFEREG PHREG REPEATED, ASSESS, CONTRAST, ESTIMATE, OUTPUT, LSMEANS OUTPUT, PROBPLOT ACCESS, CONTRAST, OUTPUT, TEST See the SAS/STAT R User s Guide for more information. 155 / 158

158 The GENMOD, LIFEREG, and PHREG procedures Summary Experimental Downloads for SAS R In SAS 9.1.3, you can download BGENMOD, BLIFEREG, and BPHREG procedures that have the Bayesian capabilities. In SAS 9.1.3, No BY-group processing No OUTPOST= option. To save the posterior samples, use the ODS statement: ODS OUTPUT PosteriorSample = SAS-data-set; DIC available only in PROC BPHREG BPHREG does not support the BASELINE statement, and does not have the HAZARDRATIO statement. 156 / 158

159 The GENMOD, LIFEREG, and PHREG procedures Summary References Besag, J. (1974), Spatial Interaction and the Statistical Analysis of Lattice Systems, Journal of the Royal Statistical Society, Series B, 36, Gilks, W. R. and Wild, P. (1992), Adaptive Rejection Sampling for Gibbs Sampling, Applied Statistics, 41, Gilks, W. R., Best, N. G., and Tan, K. K. C. (1995), Adaptive Rejection Metropolis Sampling, Applied Statistics, 44, Kalbfleisch, J. D. and Prentice, R. L. (1980), The Statistical Analysis of Failure Time Data, New York: John Wiley & Sons. Sinha, D., Ibrahim, J. G., and Chen, M. (2003), A Bayesian Justification of Cox s Partial Likelihood, Biometrika, 90, Wasserman, L. (2004), All of Statistics: A Concise Course in Statistical Inference, New York: Springer-Verlag. 157 / 158

160 The GENMOD, LIFEREG, and PHREG procedures Summary 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. R indicates USA registration. Other brand and product names are registered trademarks or trademarks of their respective companies. 158 / 158

161 Bayesian Modeling Using the MCMC Procedure Joseph G. Ibrahim Department of Biostatistics University of North Carolina 1 / 128

162 Outline 1 Overview 2 Getting started: linear regression 3 How does PROC MCMC work? 4 Essential statements 5 Distributions 6 More examples 7 Closing remarks 2 / 128

163 Overview Comparison Bayesian Computation in SAS R Software The GENMOD, LIFEREG, and PHREG procedures: use well defined models provide some choices of prior distributions require a minimal amount of programming became production in SAS 9.2 (the BAYES statement) The MCMC procedure is: flexible and capable of handling more general models programming-oriented experimental in SAS 9.2 and will become production during / 128

164 Overview The MCMC procedure The MCMC Procedure The MCMC procedure is a general-purpose simulation procedure that uses Markov chain Monte Carlo (MCMC) techniques to fit a range of Bayesian models: single-level or multilevel (hierarchical) models linear or nonlinear models, such as regression, mixture, survival, ordinal multinomial, and so on. 4 / 128

165 Overview The MCMC procedure The MCMC Procedure The MCMC procedure has the following characteristics: Ease-of-use: You have to specify only parameters, prior distributions, and a likelihood function. Generality: You can analyze data that have standard distribution (normal, gamma, binomial) or general likelihood or prior distribution, as long as they are programmable using the SAS DATA step functions. 5 / 128

166 Overview The MCMC procedure Posterior Statistics In addition to samples from the desired posterior distribution, PROC MCMC produces: posterior statistics: posterior mean, standard deviation, percentiles equal-tail and highest posterior density (HPD) intervals covariance/correlation matrices deviance information criterion (DIC) Markov chain convergence diagnostics: Geweke test Heidelberger-Welch stationarity and half-width tests Raftery-Lewis test posterior sample autocorrelations effective sample size (ESS) Monte Carlo standard error (MCSE) 6 / 128

167 Overview The MCMC procedure Visualization Graphical display of the posterior samples: trace plot (with optional smoothed mean curve) autocorrelation plot kernel density plot (with optional fringe plot) 7 / 128

168 Getting started: linear regression Outline 1 Overview 2 Getting started: linear regression 3 How does PROC MCMC work? 4 Essential statements 5 Distributions 6 More examples 7 Closing remarks 8 / 128

169 Getting started: linear regression Linear Regression Consider the model Weight i = β 0 + β 1 Height i + ɛ i for the observations i = 1,, n and ɛ is a N(0, σ 2 ) error term. The following DATA step creates data set Class with variables Height and Weight: data Class; input Name $ Height datalines; Alfred Alice Barbara Carol Henry James Jane Janet Jeffrey John Joyce Judy Louise Mary Philip Robert Ronald Thomas William ; 9 / 128

170 Getting started: linear regression Linear Regression The likelihood function is a normal density: Weight i normal(β 0 + β 1 Height i, σ 2 ) Suppose that you want to consider the following prior distributions: π(β 0 ) = φ(0, var = 1e6) π(β 1 ) = φ(0, var = 1e6) π(σ 2 ) = f iγ (shape = 3/10, scale = 10/3) 10 / 128

171 Getting started: linear regression Linear Regression The following statements fit a simple linear regression: proc mcmc data=class outpost=classout nmc=50000 thin=5 seed=246810; parms beta0 0 beta1 0; parms sigma2 1; prior beta0 beta1 ~ normal(mean=0, var=1e6); prior sigma2 ~ igamma(shape=3/10, scale=10/3); mu = beta0 + beta1*height; model weight ~ normal(mu, var=sigma2); run; 11 / 128

172 Getting started: linear regression Diagnostics Plots for β 0 12 / 128

173 Getting started: linear regression Diagnostics Plots for β 1 13 / 128

174 Getting started: linear regression Diagnostics Plots for σ 2 14 / 128

175 Getting started: linear regression Observation and Prior Information Tables Number of Observations Read Number of Observations Used Block Parameter Sampling Method Parameters Initial Value Prior Distribution 1 beta0 N-Metropolis 0 normal(mean = 0, var = 1e6) 1 beta1 N-Metropolis 0 normal(mean = 0, var = 1e6) 2 sigma2 N-Metropolis igamma(shape = 3/10, scale = 10/3) 15 / 128

176 Getting started: linear regression Tuning History Table Monitors the Tuning of the Metropolis Sampler Phase Block Tuning History Scale Acceptance Rate / 128

177 Getting started: linear regression Burn-In and Sampling History Block Burn-In History Scale Acceptance Rate Block Sampling History Scale Acceptance Rate / 128

178 Getting started: linear regression Summary Statistics and Posterior Intervals Tables Parameter N Mean Posterior Summaries Percentiles Standard Deviation 25% 50% 75% beta beta sigma Parameter Alpha Posterior Intervals Equal-Tail Interval HPD Interval beta beta sigma / 128

179 Getting started: linear regression MCSE and Autocorrelation Tables Monte Carlo Standard Errors Parameter MCSE Standard Deviation MCSE/SD beta beta sigma Posterior Autocorrelations Parameter Lag 1 Lag 5 Lag 10 Lag 50 beta beta sigma / 128

180 Getting started: linear regression Geweke Diagnostics and ESS Tables Geweke Diagnostics Parameter z Pr > z beta beta sigma Parameter Effective Sample Sizes ESS Correlation Time Efficiency beta beta sigma / 128

181 How does PROC MCMC work? Outline 1 Overview 2 Getting started: linear regression 3 How does PROC MCMC work? 4 Essential statements 5 Distributions 6 More examples 7 Closing remarks 21 / 128

182 How does PROC MCMC work? Sampling in PROC MCMC The basic sampling algorithm that drives PROC MCMC is a normal-kernel-based random walk Metropolis Metropolis. The proposal distribution is q(θnew θ (t) ) = MVN(θnew θ (t), c 2 Σ). Two crucial components in the Metropolis algorithm: construction of the proposal distribution automatically done by PROC MCMC evaluation of log(π(θ (t) y)) at each iteration you specify the prior and likelihood function, and PROC MCMC does the rest 22 / 128

183 How does PROC MCMC work? Computations in PROC MCMC At each Markov chain iteration, PROC MCMC calculates log(π(θ (t) y)) by stepping through the input data set. When you use the procedure, keep this equation in mind: log(π(θ y)) = log(π(θ)) + n log(f (y i θ)) + C where θ are model parameters, π(θ) is the prior, f (y i θ) is the sampling distribution for a single observation in the data set, and C is a constant that can be ignored. To calculate log(π(θ (t) y)), PROC MCMC steps through the data set, performs the computations for each y i, and cumulatively adds the log-likelihood values. i=1 23 / 128

184 How does PROC MCMC work? Computations in PROC MCMC You are not restricted to models that have the same likelihood function for each observation. PROC MCMC enables you to model data that have the following likelihood function: n 1 log(f (y θ)) = log(f 1 (y i θ)) + i=1 log(f (y θ)) = n i=n 1 +1 n log(f (y i y j i, θ)) i=1 log(f 2 (y i θ)) At each simulation step, PROC MCMC processes the data set, evaluates the program, and calculates the log of the posterior density. 24 / 128

185 Essential statements Outline 4 Essential statements Basic statements PROC statement and options PARMS statement PRIOR statement MODEL statement Programming statements 25 / 128

186 Essential statements Basic statements PROC MCMC options; } PARMS; define parameters. PARMS; BEGINCNST; Programming statements; ENDCNST; BEGINPRIOR; Programming statements; ENDPRIOR; PRIOR PRIOR } set up statements, evaluated before but not during the simulation calculate log(π(θ)) or g(θ) (statements should not contain data set variables) declare prior distributions } log(f (yi θ)), evaluated n-times Programming statements; MODEL Run; per iteration 26 / 128

187 Essential statements PROC statement and options PROC MCMC options The PROC MCMC statement invokes the procedure. Some useful options are: DATA= OUTPOST= NBI= NMC= THIN= SEED= STATISTICS= DIAGNOSTICS= PLOTS= MONITOR= name of the input data set name of the output data set for posterior samples number of burn-in iterations number of MCMC iterations thinning of the Markov chain random number generator seed posterior statistics convergence diagnostics diagnostics plotting analysis for selected symbols of interest, (for example, functions of parameters) 27 / 128

188 Essential statements PARMS statement PARMS Statement PARMS name (name-list) <=> number; lists the names of the parameters and specifies optional initial values. PROC MCMC generates values for unintialized parameters from the corresponding prior distributions. For example: PARMS alpha 0 beta 1; declares α and β to be model parameters and assigns 0 to α and 1 to β. PARMS alpha 0 beta; assigns 0 to α and leaves β uninitialized. PARMS (alpha beta) 1; assigns 1 to both α and β. 28 / 128

189 Essential statements PARMS statement Initial Values You can use the PARMS statement to assign initial values to model parameters. If the initial values lead to an invalid prior or likelihood calculation, PROC MCMC prints an error message and stops. For example, parm sigma2-1; prior sigma2 ~ igamma(shape = 3/10, scale = 10/3); leads to the following error message: ERROR: The initial value -1 for parameter sigma2 is outside of the prior distribution support set. NOTE: The prior of sigma2 is GAMMA with SHAPE=0.01. It has a support set of (0, Infinity). In some cases, PROC MCMC provides additional information. 29 / 128

190 Essential statements PARMS statement PARMS Statement When multiple PARMS statements are used, each statement defines a block of parameters. PROC MCMC updates parameters in each block sequentially, conditional on the current values of other parameters in other blocks. For example, in the linear regression example, the following PARMS statements are used: PARMS beta0 beta1; PARMS sigma2; At each iteration t, PROC MCMC updates β 0 and β 1 together, alternatively with σ 2, each with a Metropolis sampler: β (t) 0, β(t) 1 σ 2 (t 1) σ(t) 2 β (t) 0, β(t) 1 30 / 128

191 Essential statements PARMS statement Prior Information Table Blocking information is included in the table. Block Parameter Sampling Method Parameters Initial Value Prior Distribution 1 beta0 N-Metropolis 0 normal(mean = 0, var = 1e6) 1 beta1 N-Metropolis 0 normal(mean = 0, var = 1e6) 2 sigma2 N-Metropolis igamma(shape = 3/10, scale = 10/3) 31 / 128

192 Essential statements PRIOR statement PRIOR Statement PRIOR parameter-list distribution; specifies the prior distributions. The parameter-list can be a single parameter or a list of parameters. Multiple PRIOR statements are allowed and you can have as many hierarchical levels as desired. For example: PRIOR alpha ~ normal(0, var=10); PRIOR sigma2 ~ igamma(0.001, iscale=0.001); PRIOR beta gamma ~ normal(alpha, var=sigma2); specifies the following joint prior distribution: π(α, β, γ, σ 2 ) = π(β α, σ 2 ) π(γ α, σ 2 ) π(α) π(σ 2 ) PROC MCMC includes a HYPER statement, which is treated the same as the PRIOR statement. It is a notational convenience for specifying a multilevel hierarchical model. 32 / 128

193 Essential statements MODEL statement MODEL Statement MODEL dependent-variable-list distribution; specifies the conditional distribution of the data given the parameters (the likelihood function). The dependent variables can be either variables from the data set or functions of variables in the program. If y is a variable in the data set, MODEL y ~ normal(alpha, var=1); specifies π(y i α) = φ(y i α, 1) w = log(y); MODEL w ~ normal(alpha, var=1); specifies π(log(y i ) α) = φ(log(y i ) α, 1) Multiple MODEL statements are allowed. 33 / 128

194 Essential statements Programming statements Programming Statements Most DATA step operators, functions, and statements can be used in PROC MCMC: assignment and operators: +, -, *, /, <>, <,... mathematical functions: PDF, CDF, SDF, LOGPDF, ABS, LOG, LOGISTIC, FACT, BETA, GAMMA, RAND,... statements: CALL, DO, IF, PUT, WHEN,... The functions enable you to: construct log of density functions (both priors and likelihood functions) compute functions of parameters generate samples from the predictive distribution debug your program PROC MCMC also supports matrix-based functions. 34 / 128

195 Essential statements Programming statements Programming Statements The programming order matters. For example, the following linear regression statements will not work correctly because mu is defined after the MODEL statement: proc mcmc data=class outpost=classout nmc=50000 thin=5 seed=246810; parms beta0 0 beta1 0; parms sigma2 1; prior beta0 beta1 ~ normal(mean=0, var=1e6); prior sigma2 ~ igamma(shape=3/10, scale=10/3); model weight ~ normal(mu, var=sigma2); mu = beta0 + beta1*height; run; 35 / 128

196 Distributions A list of standard distributions Outline 5 Distributions Standard distributions A list of standard distributions Binomial model Nonlinear Poisson regression Change point model Nonstandard distributions The GENERAL function Linear regression with improper prior Zero-inflated Poisson regression 36 / 128

197 Distributions A list of standard distributions Standard Distributions PROC MCMC supports the following standard distributions that can be used in both the PRIOR and MODEL statements: beta binary binomial cauchy chisq expon gamma geo ichisq igamma laplace negbin normal pareto poisson sichisq t uniform wald weibull Distribution argument can be constants, expressions, or model parameters. For example: prior alpha ~ cauchy(0, 2); prior p ~ beta(abs(alpha), constant( pi )); model y ~ binomial(n, p); 37 / 128

198 Distributions A list of standard distributions Standard Distributions Some distributions can be parameterized in different ways: expon(scale s = λ) expon(iscale is = λ) gamma(a, scale sc = λ) gamma(a, iscale is = λ) igamma(a, scale sc = λ) igamma(a, iscale is = λ) laplace(l, scale sc = λ) laplace(l, iscale is = λ) normal(µ, var=σ 2 ) normal(µ, sd=σ) normal(µ, prec=τ) lognormal(µ, var=σ 2 ) lognormal(µ, sd=σ) lognormal(µ, prec=τ) t(µ, var=σ 2, df) t(µ, sd=σ, df) t(µ, prec=τ, df) For these distributions, you must explicitly name the ambiguous parameter. For example: prior beta ~ normal(0, var=sigma2); prior sigma2 ~ igamma(0.001, is=0.001); 38 / 128

199 Distributions Binomial model Binomial Model Researchers are interested in evaluating the performance of a medical procedure in a multicenter study. One of the study goals is to compare the survival benefit of the medical procedure. The following statements create a SAS data set for the treatment arm of the trials: data trials; input event n center; datalines; ; event: number of deaths n: number of patients assigned to the treatment procedure center: center index 39 / 128

200 Distributions Binomial model Binomial Model The simplest model ignores any center difference and treats the data as the realization of a shared model, with the same death probability p applied to all centers: event i binomial(n i, p) π(p) = uniform(0, 1) 40 / 128

201 Distributions Binomial model Binomial Model Fitting a binomial model in PROC MCMC with a uniform prior on p is straightforward: proc mcmc data=trials seed=17; parm p; prior p ~ beta(1,1); model event ~ binomial(n,p); run; 41 / 128

202 Distributions Binomial model Summary Statistics and Posterior Intervals Tables Compare Parameter N Mean Posterior Summaries Percentiles Standard Deviation 25% 50% 75% p Parameter Alpha Posterior Intervals Equal-Tail Interval HPD Interval p / 128

203 Distributions Binomial model Binomial Model Suppose that you do not want to have fixed hyperparameter values and want to consider hyperprior distributions on these parameters: π(a) exponential(scale = 100) π(b) exponential(scale = 100) This prior has mean of 100 and variance 10,000. The following SAS statements fit a hierarchical binomial model: proc mcmc data=trials seed=17 nmc=10000 outpost=bmc; parms p; parms a b; hyper a b ~ expon(scale=100); prior p ~ beta(a,b); model event ~ binomial(n,p); run; 43 / 128

204 Distributions Binomial model Posterior Density Comparison Having hyperprior distributions is essentially equivalent to using a uniform prior on p there is no information in the data that can help with estimating the hyperparameters. 44 / 128

205 Distributions Binomial model Truncated Distributions Most standard distributions, with the exception of the binary and uniform, allow for optional LOWER= and UPPER= arguments. For example, in the binomial model, if you believe that the success probability cannot be above a certain threshold, in addition to restrictions on the beta parameters, you can use the following statements: proc mcmc data=trials seed=17 nmc=10000 outpost=bmc; parms p; parms a b; hyper a ~ expon(scale=100, lower=45); hyper b ~ expon(scale=100, lower=100, upper=2000); prior p ~ beta(a, b, upper=0.1); model event ~ binomial(n,p); run; 45 / 128

206 Distributions Nonlinear Poisson regression Nonlinear Poisson Regression This example analyzes calls to a technical center after a product release. The information can be used to determine the allocation of technical support resources for future products. data calls; input weeks datalines; ; The variable weeks is the number of weeks. The variable calls counts the number of calls. 46 / 128

207 Distributions Nonlinear Poisson regression Nonlinear Poisson Regression You can model calls as a Poisson random variable, with the mean modeled as a nonlinear function of weeks: The mean function λ i is modeled as: λ i = The prior distributions are: calls i Poisson (λ i ) γ 1 + exp [ (α + βweeks i )] π(α) normal( 5, sd =.25) π(β) normal(0.75, sd =.5) π(γ) gamma(3.5, scale = 12) 47 / 128

208 Distributions Nonlinear Poisson regression Nonlinear Poisson Regression The following statements fit a nonlinear Poisson regression to the calls data. proc mcmc data=calls nmc=20000 propcov=quanew; parms alpha beta gamma; prior alpha ~ normal(-5, sd=0.25); prior beta ~ normal(0.75, sd=0.5); prior gamma ~ gamma(3.5, scale=12); lambda = gamma*logistic(alpha+beta*weeks); model calls ~ poisson(lambda); run; The PROPCOV= option obtains optimal starting values and constructs the proposal distribution via numerical optimization. 48 / 128

209 Distributions Nonlinear Poisson regression Nonlinear Poisson Regression 49 / 128

210 Distributions Change point model Change Point Model Consider the following data: OBS y x / 128

211 Distributions Change point model Change Point Model Let the change point be cp. You can use the regression model { normal(α + β1 (x y i i cp), σ 2 ) if x i < cp normal(α + β 2 (x i cp), σ 2 ) if x i cp with the following prior distributions: π(cp) uniform( 1.3, 1.1) π(α, β 1, β 2 ) normal(0, var = 1e6) π(σ) uniform(0, 10) 51 / 128

212 Distributions Change point model IF/ELSE Logical Control proc mcmc data=stagnant outpost=outc propcov=quanew seed=23 nmc=20000; parms alpha cp beta1 beta2; parms s2; prior cp ~ unif(-1.3, 1.1); prior alpha beta: ~ normal(0, v = 1e6); prior s2 ~ uniform(0, 10); if(x < cp) then mu = alpha + beta1 * (x - cp); else mu = alpha + beta2 * (x - cp); model y ~ normal(mu, sig=s2); run; 52 / 128

213 Distributions Change point model Change Point Model Posterior estimates of the regression fit and the posterior marginal distribution of the change point location: 53 / 128

214 Distributions Change point model But Wait! Does it have to be a change point model? How about a quadratic regression? 54 / 128

215 Distributions Change point model Quadratic Regression Fitting a quadratic regression is straightforward: proc mcmc data=stagnant outpost=outc propcov=quanew seed=23 nmc=20000; parms alpha beta1 beta2; parms s2; prior alpha beta: ~ normal(0, v = 1e6); prior s2 ~ uniform(0, 10); mu = alpha + beta1 * x + beta2 * x * x; model y ~ normal(mu, var=s2); run; 55 / 128

216 Distributions Change point model The Fit Doesn t Look Bad! Posterior estimates of the quadratic regression fit: How can you decide which model to use? 56 / 128

217 Distributions Change point model Use Deviance Information Criterion! To request DIC: proc mcmc data=stagnant outpost=outq propcov=quanew seed=23 nmc=20000 dic;... Change Point Model Deviance Information Criterion Dbar (posterior mean of deviance) Dmean (deviance evaluated at posterior mean) pd (effective number of parameters) DIC (smaller is better) Quadratic Regression Deviance Information Criterion Dbar (posterior mean of deviance) Dmean (deviance evaluated at posterior mean) pd (effective number of parameters) DIC (smaller is better) / 128

218 Distributions The GENERAL function Outline 5 Distributions Standard distributions A list of standard distributions Binomial model Nonlinear Poisson regression Change point model Nonstandard distributions The GENERAL function Linear regression with improper prior Zero-inflated Poisson regression 58 / 128

219 Distributions The GENERAL function Specifying a New Distribution The GENERAL and DGENERAL functions enable you to analyze data that have any prior or likelihood functions, as long as these functions are programmable using the SAS DATA step functions. The D stands for discrete. PRIOR alpha dgeneral(lp); MODEL y general(llike); The expressions lp and llike must take the values of the logarithm of the prior density or likelihood function that you construct using SAS programming statements. The normalizing constant of the distribution can be ignored, as long as it is independent of other parameters in the model. 59 / 128

220 Distributions The GENERAL function More on the GENERAL Functions The function argument can be an expression or a constant. For example, to specify an improper flat prior on the real axis, π(α) 1, you use the following statement: prior alpha ~ general(0); You should be careful using these functions because PROC MCMC cannot verify that the priors you specify are valid (integrable) distributions, and you can easily construct prior and log-likelihood functions that lead to improper posterior distributions. Use the DGENERAL function if the parameters take only discrete values. PROC MCMC returns continuous values otherwise. 60 / 128

221 Distributions Linear regression with improper prior Linear Regression Suppose that in the Getting Started linear regression example, you want to use a noninformative prior on the variance parameter π(σ 2 ) 1 σ 2 which is a nonstandard distribution (nonintegrable prior). The logarithm of this prior is log(π(σ 2 )) = log(σ 2 ) + C Note that the normalizing constant can be ignored in PROC MCMC. 61 / 128

222 Distributions Linear regression with improper prior Linear Regression The following statements fit a simple linear regression with noninformative prior on σ 2 : proc mcmc data=class outpost=classout nmc=50000 thin=5 seed=246810; parms beta0 0 beta1 0; parms sigma2 1; prior beta0 beta1 ~ normal(mean=0, var=1e6); prior sigma2 ~ general(-log(sigma2)); mu = beta0 + beta1*height; model weight ~ normal(mu, var=sigma2); run; 62 / 128

223 Distributions Linear regression with improper prior Linear Regression The argument to the GENERAL function can be any expression: proc mcmc data=class outpost=classout nmc=50000 thin=5 seed=246810; parms beta0 0 beta1 0; parms sigma2 1; prior beta0 beta1 ~ normal(mean=0, var=1e6); lp = -log(sigma2); prior sigma2 ~ general(lp); mu = beta0 + beta1*height; model weight ~ normal(mu, var=sigma2); run; 63 / 128

224 Distributions Zero-inflated Poisson regression Zero-Inflated Poisson (ZIP) Regression You can use the ZIP models when you observe data that have a large number of zeros. A large number of zeros suggests that you might have two populations in the data set, and you typically use a mixture of two distributions to model the data: where Pr(Y = y) = ηp 1 + (1 η)p 2 (y µ) p 1 = { 1 if y = 0 0 if y 0 p 2 (y µ) = Poisson(µ) 0 η 1 64 / 128

225 Distributions Zero-inflated Poisson regression ZIP Model The following data are part of a hypothetical data set (n = 52), which represents the number of fish caught by visitors at a state park. Variables are the visitor s age and gender. OBS age count female male / 128

226 Distributions Zero-inflated Poisson regression Visualize the Data The top three panels are the histograms for fish caught by all, females, and males. The bottom plots are scatter plots of age versus fish caught (all, females, and males). The curves are penalized B-spline fit. 66 / 128

227 Distributions Zero-inflated Poisson regression ZIP Model To model a mixture of two populations in the data, consider the model with priors count i ηp 1i + (1 η)poisson(µ i ) log(µ i ) = β 0 + β 1 female i age i + β 2 male i age i π(β 0, β 1, β 2 ) = normal(0, σ 2 = 1000) π(η) = uniform(0, 1) You can use the DGENERAL function to specify the mixture likelihood function. 67 / 128

228 Distributions Zero-inflated Poisson regression ZIP Model The following SAS statements fit a ZIP model: proc mcmc data=catch seed=17 nmc=10000 propcov=quanew plots=density; parms beta0 0 beta1 0 beta2 0; parms eta.3; prior beta: ~ normal(0,var=1000); prior eta ~ uniform(0,1); mu = exp(beta0 + beta1*female*age + beta2*male*age); llike=log(eta*(count eq 0) + (1-eta)*pdf("poisson",count,mu)); model dgeneral(llike); run; This type of mixture prior is similar to the spike-and-slab (or lump-and-smear) prior. 68 / 128

229 Distributions Zero-inflated Poisson regression Posterior Estimates of the ZIP Model Parameter N Mean Posterior Summaries Percentiles Standard Deviation 25% 50% 75% beta beta beta eta Parameter Alpha Posterior Intervals Equal-Tail Interval HPD Interval beta beta beta eta / 128

230 Distributions Zero-inflated Poisson regression Posterior Marginal Density Plots 70 / 128

231 Distributions Zero-inflated Poisson regression ZIP Model Fit Bayesian fit (dotted lines) of the ZIP model. The other two lines are penalized B-spline fit. 71 / 128

232 More examples Outline 6 More examples Functions of parameters Posterior predictive distribution Incorporation of historical data (power prior) Sensitivity analysis Random-effects model 72 / 128

233 More examples Functions of parameters Inference on Functions of Parameters One advantage of Bayesian inference is its ability to estimate functions of the model parameters, such as any f (θ). In PROC MCMC, it is convenient to obtain samples from the posterior marginal distributions of the unknown of interest. You use: programming statements to calculate functions of parameters MONITOR= option to select a list of symbols to make inference on 73 / 128

234 More examples Functions of parameters ZIP Model In the ZIP model, suppose that you want to ask: Is the difference between β 1 and β 2 significant? That is, how strong a claim can you make that females tend to catch more fish than males, when controlled by age? How many more fish is a female expected to catch than a male with an increase of 10 years in age? These questions can be answered through the examinations of functions of the model parameters, which are random variables and hence have their own posterior distributions: π(β 1 β 2 > 0 Data) π (exp ((β 1 β 2 ) 10) Data) 74 / 128

235 More examples Functions of parameters Monitoring Functions of Parameters The MONITOR= options enables you to monitor any expression you created in the program (in addition to the model parameters): proc mcmc data=catch seed=17 nmc=10000 propcov=quanew plots=density monitor=(bdif mdif); parms beta0 0 beta1 0 beta2 0; parms eta.3; prior beta: ~ normal(0,var=1000); prior eta ~ uniform(0,1); bdif = beta1 - beta2; mdif = exp(bdif * 10); mu = exp(beta0 + beta1*female*age + beta2*male*age); llike=log(eta*(count eq 0) + (1-eta)*pdf("poisson",count,mu)); model dgeneral(llike); run; 75 / 128

236 More examples Functions of parameters Posterior Estimates of the ZIP Model The estimated π(β 1 β 2 > 0 Data) is 100%, and on average, a female is expected to catch 1+ more fish than a male, with an increase of 10 years in age. Parameter N Mean Posterior Summaries Percentiles Standard Deviation 25% 50% 75% bdif mdif Parameter Alpha Posterior Intervals Equal-Tail Interval HPD Interval bdif mdif / 128

237 More examples Functions of parameters Posterior Marginal Density Plots 77 / 128

238 More examples Functions of parameters More on Calculating Functions of Parameters In each Markov chain iteration, PROC MCMC executes all programming statements once per observation in the input data set. Therefore, calculations that do not involve any data set variables are redundant and computationally inefficient. Example: bdif = beta1 - beta2; mdif = exp(bdif * 10); 78 / 128

239 More examples Functions of parameters PROC MCMC options; } PARMS; define parameters. PARMS; BEGINCNST; Programming statements; ENDCNST; BEGINPRIOR; Programming statements; ENDPRIOR; PRIOR PRIOR } set up statements, evaluated before but not during the simulation calculate log(π(θ)) or g(θ) (statements should not contain data set variables) declare prior distributions } log(f (yi θ)), evaluated n-times Programming statements; MODEL Run; per iteration 79 / 128

240 More examples Functions of parameters BEGINCNST/ENDCNST Statements These statements jointly define a block, and the enclosed programming statements are processed only during the setup stage of a PROC MCMC run. These programming statements are not executed during the simulation and should be used to define constants or read data from a different data set. Example that defines a constant τ: begincnst; tau = 27; endcnst; 80 / 128

241 More examples Functions of parameters BEGINPRIOR/ENDPRIOR Statements These statements are designed to reduce unnecessary observation-level computations. They jointly define a block, and the enclosed programming statements are not executed for every data set observation. They are best reserved for calculations that relate to parameters only. Suppose that you parameterize your model on σ but want to sample on the σ 2 scale: parm s2; beginprior; s = sqrt(s2); endprior; model y ~ normal(0, sd=s); The calculation of σ is identical for each observation. BEGINPRIOR/ENDPRIOR BEGINNODATA/ENDNODATA 81 / 128

242 More examples Functions of parameters BEGINPRIOR/ENDPRIOR Statements You should not place data set variables within these segments. Suppose that y is a data set variable. The following calculation of σ will be incorrect because PROC MCMC does not know which value y should take while executing this statement. beginprior; s = sqrt(y); endprior; You can include multiple PRIOR statements within the BEGINPRIOR/ENDPRIOR statements: beginprior; prior alpha ~ n(0, var=10); prior beta ~ n(0, var=1); endprior; This does not change the way PROC MCMC understands your model. 82 / 128

243 More examples Functions of parameters Monitoring Functions of Parameters The following program runs more efficiently: proc mcmc data=catch seed=17 nmc=10000 propcov=quanew plots=density monitor=(bdif mdif); parms beta0 0 beta1 0 beta2 0; parms eta.3; prior beta: ~ normal(0,var=1000); prior eta ~ uniform(0,1); beginprior; bdif = beta1 - beta2; mdif = exp(bdif * 10); endprior; mu = exp(beta0 + beta1*female*age + beta2*male*age); llike=log(eta*(count eq 0) + (1-eta)*pdf("poisson",count,mu)); model dgeneral(llike); run; 83 / 128

244 More examples Posterior predictive distribution Posterior Predictive Distribution The posterior predictive distribution is the distribution of unobserved observations (prediction), conditional on the observed data. It is defined as: π(y pred y) = = = π(y pred, θ y)dθ π(y pred θ, y)π(θ y)dθ π(y pred θ)π(θ y)dθ The posterior predictive distribution can be seen as an integral of the likelihood function π(y pred θ) with respect to the posterior π(θ y). 84 / 128

245 More examples Posterior predictive distribution Posterior Predictive Distribution You can use the posterior predictive distribution to: do prediction, using new covariates. check whether the model is consistent with the data. You generate samples from π(y pred y) and see whether they differ systematically from the observed data (Gelman et al. 2004). To generate a sample from the posterior predictive distribution, you draw a sample from the likelihood, conditional on the posterior samples of the parameters. In PROC MCMC, you do so by using the RAND function. 85 / 128

246 More examples Posterior predictive distribution Binomial Model: Prediction Suppose that in the binomial example, you want to know the following: predicted number of successes in a future trials of 242: event pred binomial(242, p) probability that the number of successes exceeds a critical threshold: ( ) Pr event pred 4 86 / 128

247 More examples Posterior predictive distribution Binomial Model: Prediction The following program fits a binomial model and makes prediction: proc mcmc data=trials seed=17 nmc=10000 monitor=(_parms_ xpred pcrit); parm p; prior p ~ beta(1,1); beginprior; xpred = rand("binomial", p, 242); pcrit = (xpred > 4); endprior; model event ~ binomial(n,p); run; The parms symbol in the MONITOR= option is shorthand for all model parameters in the program. 87 / 128

248 More examples Posterior predictive distribution Prediction Based on the Binomial Model Parameter N Mean Posterior Summaries Percentiles Standard Deviation 25% 50% 75% p xpred pcrit Parameter Alpha Posterior Intervals Equal-Tail Interval HPD Interval p xpred pcrit / 128

249 More examples Incorporation of historical data (power prior) Outline 6 More examples Functions of parameters Posterior predictive distribution Incorporation of historical data (power prior) Sensitivity analysis Random-effects model 89 / 128

250 More examples Incorporation of historical data (power prior) Incorporation of Historical Data Suppose that, in addition to the data set trials in the binomial example, you have a data set from a pilot clinical trial: data pilot; input event n; datalines; ; + noninformative analysis prior p0 ~ beta(1,1); model event ~ binomial(n,p0); How would you capture the information contained in this trial on p 0 and incorporate it in the analysis using the current data set on p? 90 / 128

251 More examples Incorporation of historical data (power prior) Power Prior Power prior (Ibrahim and Chen 2000) enables you to retain information from a historical data set and use it as a prior distribution in the current analysis. To construct a power prior distribution, you can use the formula where p(θ D 0, a 0 ) L(θ; D 0 ) a0 π 0 (θ) D 0 = (n 0, y 0, X 0 ) is the historical (or pilot) data L(θ; D 0 ) is the likelihood of θ based on the historical data π 0 (θ) is the initial prior for θ, the prior for θ before the historical data D 0 is observed a 0 is a discounting parameter constrained to 0 a 0 1: a 0 = 0 corresponds to no incorporation of the historical data; a 0 = 1 corresponds to the Bayesian update of π(a 0 ). 91 / 128

252 More examples Incorporation of historical data (power prior) Power Prior The posterior distribution of θ is where p(θ D, D 0, a 0 ) L(θ; D) L(θ; D 0 ) a0 π 0 (θ) n n 0 f (y i θ, x i ) f (y 0,j θ, x 0,j ) a0 π 0 (θ) i=1 j=1 D = (n, y, X) are the data from the current study y = {y i } and x = {x i } for i = 1 n y 0 = {y 0,j } and x 0 = {x 0,j } for j = 1 n 0 are the historical data f ( ) is the likelihood function for a single observation in either the historical or the current data 92 / 128

253 More examples Incorporation of historical data (power prior) Power Prior Combining the two data sets, you can form a new data set D and rewrite the posterior distribution: p(θ D, a 0 ) where f i = n+n 0 i=1 f i (y i θ, x i ) π 0 (θ) { f (yi θ, x i ) for each i in the current data set f (y 0,i θ, x 0,i ) a 0 for each i in the historical data set You can use the IF statement to assign the appropriate likelihood function to different observations in the data set. 93 / 128

254 More examples Incorporation of historical data (power prior) Binomial Model Using Power Prior To fit a binomial model with power prior in PROC MCMC, you first want to combine both data sets and create a new group indicator variable: OBS event n group data alldata; set trials(in=i) pilot; if i then group="current"; else group="pilot"; run; current current current current current pilot 94 / 128

255 More examples Incorporation of historical data (power prior) Binomial Model: Power Prior For each observation in the new data set alldata, the likelihood function is either a binomial (if group == current ) or a weighted binomial (if group == pilot ). The following SAS statements fit a power prior model: proc mcmc data=alldata seed=17 nmc=50000 thin=5 outpost=aout; parm p 0.2; begincnst; a0 = 0.2; endcnst; prior p ~ beta(1,1); llike = logpdf("binomial", event, p, n); if (group = "pilot") then llike = a0 * llike; model general(llike); run; 95 / 128

256 More examples Incorporation of historical data (power prior) Posterior Statistics of p Using Power Prior Posterior summary statistics reported here (with a 0 = 0.2) are quite similar to analysis of the current data set without any information from the pilot study Compare. Maybe a sensitivity analysis? Parameter N Mean Posterior Summaries Percentiles Standard Deviation 25% 50% 75% p Parameter Alpha Posterior Intervals Equal-Tail Interval HPD Interval p / 128

257 More examples Sensitivity analysis Outline 6 More examples Functions of parameters Posterior predictive distribution Incorporation of historical data (power prior) Sensitivity analysis Random-effects model 97 / 128

258 More examples Sensitivity analysis Sensitivity Analysis Sensitivity analysis is the practice of understanding the variation and uncertainty of the posterior inferences as a result of a different prior or model (likelihood function) used in the analysis. For example, you might want to compare power prior analyses of the binomial model with different weight values of a 0. You can run PROC MCMC several times, each time with a different value of a 0, and compare the results. The BY statement makes it easy to carry out the analysis in one simple procedure call. 98 / 128

259 More examples Sensitivity analysis Sensitivity Analysis Suppose that you want to compare three power prior models with values of a 0 : a 0 = 0: an analysis that completely discards the pilot study a 0 = 0.5 a 0 = 1: an analysis that combines the pilot with the current study and assumes that they both come from the same population. 99 / 128

260 More examples Sensitivity analysis Sensitivity Analysis The following statements generate a new data set with a BY-group indicator a0: data sendata; set alldata; do a0 = 0, 0.5, 1; output; end; proc sort; by a0; run; 100 / 128

261 More examples Sensitivity analysis Sensitivity Analysis The BY statement enables you to obtain separate analyses on data in groups defined by the BY variable. The following statements run three analyses, each with a different weight a 0 : proc mcmc data=sendata seed=17 nmc=10000 outpost=bout diagnostics=none; by a0; parm p; prior p ~ uniform(0, 1); llike = logpdf("binomial", event, p, n); if (group = pilot ) then llike = a0 * llike; model general(llike); run; 101 / 128

262 More examples Sensitivity analysis Posterior Distributions of p with Different Values of a / 128

263 More examples Random-effects model Outline 6 More examples Functions of parameters Posterior predictive distribution Incorporation of historical data (power prior) Sensitivity analysis Random-effects model 103 / 128

264 More examples Random-effects model Random-Effects Model Suppose that you no longer believe that all the trials share the same p and you want to fit a random-effects model: event i binomial(n i, p i ) where i indexes the group. Two common choices for modeling p i : p i beta(a, b) logit(p i ) normal(µ, σ 2 ) 104 / 128

265 More examples Random-effects model Hyperparameters If you choose constant values for a, b, µ, or σ 2, you decide a priori the amount of shrinkage you want on the p i. For example: Choosing a = 1 and b = 1, or σ 2 =, implies no shrinkage on the p i. The random-effects model becomes an independent model (separate analysis). Choosing σ 2 = 0 imposes no variation amongst p i. This reduces the random-effects model to the pooled model. You can also use empirical Bayes estimates on the hyperparameters. This often gives posterior estimates that are similar to a full Bayes approach, if there are enough units or groups in the data to estimate the variance. But this plug-in method ignores uncertainty that your data indicates about the amount of shrinkage that should be used in the analysis. 105 / 128

266 More examples Random-effects model Hyperprior Distributions You can let the data decide what is the proper amount of shrinkage that should be used in estimating p i the right amount of strength you want to borrow from different groups to reduce variances. This amounts to placing hyperprior distributions on the hyperparameters. The hyperprior distributions could potentially become very influential (to the posterior) in cases where the data contain little information to estimate the hyperparameters accurately. For example, see Spiegelhalter, Abramas, and Myles (2004), and Gelman et al. (2003) for discussions. Strategies include: noninformative elicitation summary of evidence 106 / 128

267 More examples Random-effects model Hyperprior Distributions To illustrate the software, use proper but diffuse prior distributions on a and b: event i binomial(n i, p i ) p i beta(a, b) a, b exponential(scale = 100) 107 / 128

268 More examples Random-effects model Binomial Model: Random-Effects Model Here is the data again, and the pilot study is also included: data trials; input event n center; datalines; ; 108 / 128

269 More examples Random-effects model Binomial Model: Random-Effects Model The following SAS statements fit a hierarchical random-effects model, with a diffuse prior on the beta distribution: proc mcmc data=trials nmc= thin=10 outpost=outm; array p[6]; parm p:; parm a b; prior a b ~ expon(scale=100); prior p: ~ beta(a, b); model event ~ binomial(n, p[center]); run; The ARRAY statement allocates an array of size 6 for the p i s. In the MODEL statement, p[center] is used to indicate the appropriate probability parameter for each of the observed responses. 109 / 128

270 More examples Random-effects model Posterior Estimates of Probabilities 95% HPD credible intervals and posterior point estimates for each of the six p i. The solid line is the random-effects model; the dashed line is the independence model (individual analysis); the bottom line is the overall (pooled) estimates. 110 / 128

271 More examples Random-effects model In Case You Are Interested: If you wish to fit the following model: x i binomial(n i, p i ) γ i = logit(p i ) normal(µ, σ 2 ) µ normal(0, precision = 10 6 ) σ 2 igamma(0.001, scale = 0.001) You can use the following statements in PROC MCMC: array gamma[6]; parm gamma: parm mu s2; prior mu ~ normal(0, prec=1e-6); prior s2 ~ igamma(0.001, s=0.001); prior gamma: ~ n(mu, sd=s2); p = logistic(gamma[center]); model event ~ binomial(n, p); 111 / 128

272 More examples Random-effects model Case Control Study Suppose that the binomial data come from the control group and the question of interest is on the treatment effect θ. The complete data follow: OBS ctrl ctrln trt trtn center / 128

273 More examples Random-effects model Random-Effects Model: Odds Ratio The random-effects model can be expressed as trt i binomial(trtn i, p i ) ctrl i binomial(ctrln i, q i ) logit(p i ) = θ + φ i logit(q i ) = φ i θ normal(0, sd = 10) φ i uniform( 10, 10) where φ i is the baseline rate for the control group of trial i and θ is the treatment effect or the log(odds ratio). 113 / 128

274 More examples Random-effects model Random-Effects Model The following SAS statements fit the desired random-effects model: proc mcmc data=or monitor=(_parms_ OR); array phi[6]; parm theta 0 phi: -5; prior theta ~ n(0, sd=10); prior phi: ~ uniform(-10, 10); p = logistic(theta + phi[center]); model trt ~ binomial(trtn, p); q = logistic(phi[center]); model ctrl ~ binomial(ctrln, q); or = exp(theta); run; Multiple MODEL statements are allowed. 114 / 128

275 More examples Random-effects model Posterior Estimates of Odds Ratio 115 / 128

276 Closing remarks Procedure Capability and Limitations The MCMC procedure carries the entire input data set (not the posterior draws) in memory. This largely dictates the maximum scope of the problem that the procedure can handle. The running time of a particular problem is approximately linear to the number of samples (nsamples), the number of simulations (nsim), and the number of parameters blocks in the program (number of PARMS statements, nblocks): run time nsamples nsim nblocks The faster a computer evaluates a single log-likelihood function, the faster the program runs: , per sec 1 min 116 / 128

277 Closing remarks Closing Remarks PROC MCMC is a flexible procedure designed to fit a rich variety of linear and nonlinear, single-level and multilevel Bayesian models. The syntax is intuitive, and you can work with models that have standard or nonstandard distributions. The flexibility of the procedure shifts certain responsibilities to the user. For example, you have to be careful about not constructing models that have improper posterior distributions. Besides producing posterior estimates and convergence diagnostics, you can use PROC MCMC to compute functions of parameters, make predictions, compare models, and even incorporate user-defined sampling algorithms. Bayesian computation is an active area of development, and we are interested in your feedback. 117 / 128

278 Closing remarks For More Information See for: E-newsletter subscription News on updates and enhancements Examples library (Resources) See for: Online SAS/STAT R documentation Downloadable chapter PDFs 118 / 128

279 Closing remarks References Ibrahim, J. G. and Chen, M.-H. (2000), Power Prior Distributions for Regression Models, Statistical Science, 15(1), Gelman, A., Carlin, J., Stern, H., and Rubin, D. B. (2003), Bayesian Data Analysis, Second Edition, Boca Raton, FL: Chapman and Hall/CRC Press. Spiegelhalter, D., Abrams, K. R., and Myles, J. P. (2004), Bayesian Approaches to Clinical Trials and Health-Care Evaluation, West Sussex, England: John Wiley & Sons. 119 / 128

280 Appendix Appendix 120 / 128

281 Appendix Metropolis Algorithm The Metropolis Algorithm 1 Let t = 0. Choose a starting point θ (t). This can be an arbitrary point as long as π(θ (t) y) > 0. 2 Generate a new sample, θ, from a proposal distribution q(θ θ (t) ). 3 Calculate the following quantity: { π(θ } y) r = min π(θ (t) y), 1 4 Sample u from the uniform distribution U(0, 1). 5 Set θ (t+1) = θ if u < r; θ (t+1) = θ (t) otherwise. 6 Set t = t + 1. If t < T, the number of desired samples, go back to Step 2; otherwise, stop. 121 / 128

282 Appendix Metropolis Algorithm The Metropolis Algorithm 122 / 128

283 Appendix Metropolis Algorithm The Metropolis Algorithm 123 / 128

284 Appendix Metropolis Algorithm The Metropolis Algorithm 124 / 128

285 Appendix Metropolis Algorithm The Metropolis Algorithm 125 / 128

286 Appendix Metropolis Algorithm The Metropolis Algorithm 126 / 128

287 Appendix Metropolis Algorithm The Metropolis Algorithm Return 127 / 128

288 Appendix Metropolis Algorithm 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. R indicates USA registration. Other brand and product names are registered trademarks or trademarks of their respective companies. 128 / 128

289 Bayesian Survival Analysis Procedures in SAS Joseph G. Ibrahim Department of Biostatistics University of North Carolina

290 LIFEREG PROC LIFEREG provides Bayesian analysis methods for parametric survival models. Distributions include Exponential Weibull Log-normal Normal 3-parameter gamma Logistic Log-logistic

291 LIFEREG The model parameters are the regression coefficients and a dispersion (precision, scale) parameter if the model has one. The priors for the regression coefficients β are allowed to be normal or uniform (improper). The priors for the dispersion parameter σ are either gamma, inverse gamma, or improper and of the form p(σ) σ 1. The dispersion and regression parameters are assumed to be independent a priori.

292 LIFEREG LIFEREG formulates the survival models through an Accelerated Failure Time (AFT) approach in which the model is written as a linear model of the form y = Xβ + σɛ (1) The response vector, y, can be untransformed implying y = T, or transformed, leading to y = log(t ), where T is the survival time vector, which can be right censored, left censored, or interval censored. β is a p 1 vector of regression coefficients. σ is a dispersion parameter.

293 LIFEREG X is an n p full-rank matrix of covariates. By default, SAS takes y = log(t ). Different error distributions lead to the different models. For example, if we model y = log(t ) via (1), and ɛ has an extreme value distribution, then the resulting model for y is a Weibull model. This is the default. SAS allows you to pick the distribution for y with a LOG or NOLOG option. The LOG option is the default.

294 LIFEREG Distribution NOLOG Specified? Resulting Distribution for y EXPONENTIAL No Exponential EXPONENTIAL Yes One-parameter extreme value GAMMA No Generalized Gamma GAMMA Yes Generalized gamma with untransformed responses LOGISTIC No Logistic LOGISTIC Yes Logistic (NOLOG has no effect) LLOGISTIC No Log-logistic LLOGISTIC Yes Logistic LNORMAL No Lognormal LNORMAL Yes Normal NORMAL No Normal NORMAL Yes Normal (NOLOG has no effect) WEIBULL No Weibull WEIBULL Yes Extreme value

295 LIFEREG The log-likelihood function of (β, σ) for a set of right censored survival data is given by l = log(l) = where n ( ) f(ui ) δ i log + σ i=1 n (1 δ i ) log(s(u i )), i=1 u i = (y i x i β), σ and δ i = 1 if the ith subject failed and δ i = 0 if the ith subject was right censored. f(u i ) is the density of ɛ i, S(u i ) is the corresponding survival function, S(u i ) = 1 F (u i ), where, F (u i ) is the cdf of ɛ i.

296 The BAYES Statement Bayesian analyses in GENMOD, LIFEREG, and PHREG are all facilitated through the BAYES statement. These are shared options across all of the procedures: INITIAL = NBI = NMC = SEED = THINNING = DIAGNOSTICS = PLOTS = SUMMARY = COEFFPRIOR = initial values of the chain number of burn-in iterations number of iterations after burn-in random number generator seed thinning of the Markov chain convergence diagnostics diagnostic plots summary statistics prior for the regression coefficients

297 LIFEREG The LIFEREG specific options are: EXPONENTIALSCALEPRIOR = SCALEPRIOR = WEIBULLSCALEPRIOR = WEIBULLSHAPEPRIOR = prior for the exponential scale parameter prior for the scale parameter prior for the Weibull scale parameter prior for the Weibull shape parameter The Weibull shape parameter is γ σ 1.

298 LIFEREG For the Weibull regression model model, the likelihood function of (β, σ 1 ) is constructed by letting µ = x β according to the LIFEREG manual. The Weibull survival density for T i is given by { } f(t i ) = σ 1 exp( x iβ/σ) t 1/σ 1 i exp t 1/σ i exp( x iβ/σ). The Weibull survival function is given by { } S(t i ) = exp exp( x iβ/σ) t 1/σ i.

299 LIFEREG The log-likelihood for the Weibull regression model with right censored data is thus given by l(β, σ 1 ) = n n δ i log(f(t i )) + (1 δ i ) log(s(t i )), (2) i=1 i=1 where δ i = 1 if the ith subject failed and δ i = 0 if the ith subject was right censored. The joint posterior distribution of (β, σ 1 ) is thus given by p(β, σ 1 Data) L(β, σ 1 )π(β)π(σ 1 ), (3) where π(β) can be chosen as normal or uniform and π(σ 1 ) can be chosen as gamma or improper.

300 LIFEREG The exponential model is a special case of the Weibull model obtained by setting σ = 1. The lognormal survival density for T i is given by ( 1 f(t i ) = exp 1 ( log(ti ) x i β ) ) 2. 2πσti 2 σ The lognormal survival function is given by ( log(ti ) x i S(t i ) = 1 Φ β ). σ

301 LIFEREG The log-likelihood for the lognormal regression model with right censored data is thus given by l(β, σ 1 ) = n n δ i log(f(t i )) + (1 δ i ) log(s(t i )), (4) i=1 i=1 where δ i = 1 if the ith subject failed and δ i = 0 if the ith subject was right censored.

302 LIFEREG We consider the E1684 melanoma clinical trial with n = 286 subjects. We consider fitting a parametric survival model with three covariates: Treatment (trt) (High-dose IFN and Observation), age, and sex. We consider the Weibull model, exponential model, and lognormal model.

303 SAS Code for LIFEREG: E1684 Data data melanoma; infile H:/e1684ws.dat ; input case study age trt sex perform nodes breslow failtime rfscens survtime scens; run; proc lifereg; model failtime*rfscens(0) = trt age sex /dist=weibull; bayes seed = 5432 nbi=3000 nmc = WeibullShapePrior=gamma coeffprior = uniform diagnostics = all plots=all; proc lifereg; model failtime*rfscens(0) = trt age sex /dist=exponential; bayes seed = 5432 nbi=3000 nmc = coeffprior = uniform diagnostics = all plots=all; run;

304 SAS Code for LIFEREG: E1684 Data proc lifereg; model failtime*rfscens(0) = trt age sex /dist=weibull; bayes seed = 5432 nbi=3000 nmc = WeibullShapePrior=gamma(shape=0.01,iscale=.01) coeffprior = normal diagnostics = all plots = all; proc lifereg; model failtime*rfscens(0) = trt age sex /dist=lognormal; bayes seed = 5432 nbi=3000 nmc = coeffprior = uniform diagnostics = all plots = all; run;

305 Weibull Model for E1684 Data: Default Priors Bayesian Analysis Model Information Data Set WORK.MELANOMA Dependent Variable Log(failtime) Censoring Variable rfscens Censoring Value(s) 0 Number of Observations 284 Noncensored Values 196 Right Censored Values 88 Left Censored Values 0 Interval Censored Values 0 Zero or Negative Response 1 Burn-In Size 3000 MC Sample Size Thinning 1 Name of Distribution Weibull Log Likelihood Number of Observations Read 286 Number of Observations Used 284 Missing Values 1

306 Weibull Model for E1684 Data: Default Priors Algorithm converged. Analysis of Maximum Likelihood Parameter Estimates Standard 95% Confidence Parameter DF Estimate Error Limits Intercept trt age sex Scale Weibull Shape

307 Weibull Model for E1684 Data: Default Priors The LIFEREG Procedure Bayesian Analysis Uniform Prior for Regression Coefficients Parameter Prior Intercept Constant trt Constant age Constant sex Constant Independent Prior Distributions for Model Parameters Prior Parameter Distribution Hyperparameters Weibull Shape Gamma Shape Inverse Scale Initial Values of the Chain Weib Chain Seed Intercept trt age sex Shape Fit Statistics AIC (smaller is better) AICC (smaller is better) BIC (smaller is better) DIC (smaller is better) pd (effective number of parameters) 4.988

308 Weibull Model for E1684 Data: Default Priors The LIFEREG Procedure Bayesian Analysis Posterior Summaries Standard Percentiles Parameter N Mean Deviation 25% 50% 75% Intercept trt age sex WeibShape Posterior Intervals Parameter Alpha Equal-Tail Interval HPD Interval Intercept trt age sex WeibShape

309 Weibull Model for E1684 Data: Default Priors The LIFEREG Procedure Bayesian Analysis Posterior Autocorrelations Parameter Lag 1 Lag 5 Lag 10 Lag 50 Intercept trt age sex WeibShape

310 Weibull Model for E1684 Data: Default Priors Gelman-Rubin Diagnostics 97.5% Parameter Estimate Bound Intercept trt age sex WeibShape Geweke Diagnostics Parameter z Pr > z Intercept trt age sex WeibShape

311 Weibull Model for E1684 Data: Default Priors Raftery-Lewis Diagnostics Quantile=0.025 Accuracy=+/ Probability=0.95 Epsilon=0.001 Number of Samples Dependence Parameter Burn-in Total Minimum Factor Intercept trt age sex WeibShape

312 E1684 Data: Exponential Model with Default Priors The LIFEREG Procedure Bayesian Analysis Posterior Summaries Standard Percentiles Parameter N Mean Deviation 25% 50% 75% Intercept trt age sex Posterior Intervals Parameter Alpha Equal-Tail Interval HPD Interval Intercept trt age sex

313 Weibull Model with Normal and Gamma Priors The LIFEREG Procedure Bayesian Analysis Posterior Summaries Standard Percentiles Parameter N Mean Deviation 25% 50% 75% Intercept trt age sex WeibShape

314 Weibull Model with Normal and Gamma Priors Posterior Intervals Parameter Alpha Equal-Tail Interval HPD Interval Intercept trt age sex WeibShape

315 E1684 Data: Lognormal Model with Uniform Prior Posterior Intervals Parameter Alpha Equal-Tail Interval HPD Interval Intercept trt age sex WeibShape

316 E1684 Data: Lognormal Model with Uniform Prior The LIFEREG Procedure Bayesian Analysis Posterior Summaries Standard Percentiles Parameter N Mean Deviation 25% 50% 75% Intercept trt age sex Scale

317 E1684 Data: Lognormal Model with Uniform Prior Posterior Intervals Parameter Alpha Equal-Tail Interval HPD Interval Intercept trt age sex Scale

318 LIFEREG There are many other options in LIFEREG: proc lifereg; model failtime*rfscens(0) = trt age sex /dist=exponential; bayes seed = 5432 nbi=3000 nmc = coeffprior = uniform diagnostics = all summaries = corr thinning =10 plots=all; WeibullShapePrior=gamma(relshape=c) results in a gamma(cˆβ, c) prior for σ 1 in the Weibull model. WeibullShapePrior=gamma(shape=c) results in a gamma(c, c) prior.

319 LIFEREG data NormalPrior1; input _type_ $ Intercept trt age sex; datalines; Var Mean ; run; proc lifereg data=melanoma; model failtime*rfscens(0) = trt age sex /dist=exponential; bayes seed = 5432 nbi=3000 nmc = coeffprior = normal(input=normalprior1); run;

320 LIFEREG data NormalPrior2; input _type_ $ _name_:$9. Intercept trt age sex; cards; Mean Cov Intercept Cov trt Cov age Cov sex ; run;

321 PHREG PHREG fits semiparametric survival models using Cox regression models based on partial likelihood: exact/breslow/efron/discrete logistic likelihood, time independent, time dependent, with/without ties in time. Thus, the partial likelihood itself is treated as the likelihood. Piecewise exponential models: on both the baseline hazard and logarithm of the baseline hazard. It does not fit models with certain data constraints, as for example, data with recurrent events.

322 Bayesian Inference Based on Partial Likelihood The Breslow partial likelihood is given by ( k exp β ) j D d x j (t i ) L P (β) = [ l R i exp(β x l (t i )) ], d i i=1 where x l (t) is the vector of covariates for the lth individual at time t, t 1 < t 2 <... < t k denote the k distinct failure (event) times, and d i denotes the multiplicity of failure times at t i. Let the data be denoted by D = {(t i, x i, δ i ), i = 1,..., n}. The posterior distribution of β based on L P (β) is given by p(β D) L P (β)π(β). For the partial likelihood model, π(β) is allowed to be multivariate normal or uniform.

323 Piecewise Constant Baseline Hazard Model We first partition the time axis. Let a 0 = 0 < a 1 < a 2 <... a J 1 < a J = be a partition of the time axis. The hazard for subject i is where h(t x i, β) = h 0 (t) exp(x iβ), h 0 (t) = λ j, a j 1 < t < a j (j = 1,..., J). Thus, the hazard function for subject i in the jth time interval is h(t x i ) = λ j exp(x iβ), a j 1 < t < a j. (5)

324 Piecewise Constant Baseline Hazard Model From the hazard function, we can define the baseline cumulative hazard function, which is given by H 0 (t) = J λ j j (t), j=1 where 0 t < a j 1 j (t) = t a j 1 a j 1 t < a j. a j a j 1 t a j

325 Piecewise Constant Baseline Hazard Model Let λ = (λ 1,..., λ J ). The log-likelihood of (λ, β) is given by = = l(β, λ) n J n J δ i I(a j 1 t i < a j ) log(λ j ) + x i β j (t i )λ j exp(x i β) i=1 j=1 i=1 j=1 J n J [ d j log(λ j ) + δ i x i β n ] λ j j (t i ) exp(x i β), j=1 i=1 j=1 i=1 where d j = n i=1 δ ii(a j 1 t i < a j ).

326 Piecewise Constant Baseline Hazard Model We note that for 1 j J, the full conditional distribution for λ j is log-concave only when d j > 0, but the full conditionals of the β k s are always log-concave. The MLE of β can be obtained via Newton-Raphson methods. The MLE of λ has a closed form depending on β. Specifically, for a given β, l λ = 0 gives λ j (β) = d j n i=1 j(t i ) exp(x j = 1,..., J. iβ),

327 Piecewise Constant Baseline Hazard Model Substituting these values into l(λ, β) gives the profile log-likelihood of β: l p (β) = [ n J n δ i x iβ d j log j (t l ) exp(x l ]+c, β) (6) i=1 j=1 l=1 where c = J j=1 (d j log(d j ) d j ). Since the constant c does not depend on β, it can be discarded from l p (β) in the optimization. The MLE of β is thus found by maximizing [ n J n ] l p (β) = δ i x iβ d j log j (t l ) exp(x l β) i=1 with respect to β. j=1 l=1

328 Piecewise Constant Baseline Hazard Model The MLE of λ is given by Let x 0 l S (r) j (β) = ˆλ = λ(ˆβ). n l=1 j (t l ) exp(x l β)x r l, for r = 0, 1, 2, and j = 1,..., J. = 1, x 1 l = x l, and x 2 l = x l x l. Also, let E j (β) = S(1) j (β) S (0) j (β).

329 Piecewise Constant Baseline Hazard Model The partial derivatives of l p (β) are l p (β) n β = δ i x i 2 l p (β) β 2 = i=1 J j=1 J d j E j (β) j=1 { (2) } S j (β) d j S (0) j (β) [E j(β)] [E j (β)]

330 Piecewise Constant Baseline Hazard Model The asymptotic covariance matrix for (ˆλ, ˆβ) is obtained as the inverse of the information matrix given by 2 l(ˆλ, ˆβ) ( ) d 1 λ 2 = diag,..., d J ˆλ 2 1 ˆλ 2 J J 2 l(ˆλ, ˆβ) β 2 = 2 l(ˆλ, ˆβ) λβ j=1 ˆλ j S (2) j (ˆβ) = (S (1) 1 (ˆβ),..., S (1) (ˆβ)). J

331 Piecewise Constant Baseline Hazard Model By letting α j = log(λ j ), j = 1,..., J, we can build prior correlation between the λ j s by specifying a multivariate normal prior for α = (α 1,..., α J ), that is, α N(α 0, Σ α ). In this case, the log-likelihood of (α, β) is given by l(α, β) = J d j α j + j=1 n δ i x iβ i=1 The MLE of λ j is given by exp(ˆα j ) = ˆλ j = J j=1 d j S (0) j (ˆβ). exp(α j )S (0) j (β).

332 Piecewise Constant Baseline Hazard Model We note that the full conditionals for the α j s and β k s are always log-concave. The asymptotic covariance matrix of ( ˆα, ˆβ) is obtained as the inverse of the information matrix formed by 2 l( ˆα, ˆβ) α 2 2 l( ˆα, ˆβ) β 2 = 2 l( ˆα, ˆβ) αβ ( = diag exp(ˆα 1 )S (0) = J j=1 exp(ˆα j )S (2) j (ˆβ) ( exp(ˆα 1 )S (1) 1 (ˆβ),..., exp(ˆα J )S (0) 1 (ˆβ),..., exp(ˆα J )S (1) J J ) (ˆβ). ) (ˆβ)

333 Summary of PHREG Partial Likelihood Model (Cox): Uniform improper prior and normal priors on the regression coefficients are allowed. Piecewise Exponential: Regression coefficients β: uniform improper and normal priors. log hazard parameters α = log(λ): uniform improper and normal priors. Regression parameters and log hazard parameters: (β, α) can be taken jointly as multivariate normal and need not be independent a priori. hazard parameters λ: Jeffreys s (improper), uniform improper, product of independent gamma densities, and AR(1) gamma priors.

334 Priors for PHREG The Jeffreys s prior for λ is π(λ) J j=1 1 λ j. The uniform improper prior for λ is π(λ) 1. For the independent gamma priors, we assume λ j gamma(a j, b j ), and independent for j = 1,..., J. The prior for λ is then given by π(λ) J j=1 { } λ a j 1 j exp( λ j b j ).

335 Priors for PHREG The AR(1) gamma prior for λ is given by λ 1 gamma(a 1, b 1 ) ( λ 2 λ 1 gamma a 2, b ) λ J λ J 1 gamma λ 1 ( a J, b J λ J 1 ). The prior density for λ is then given by π(λ) λ a exp( b 1 λ 1 ) J j=2 ( bj λ j 1 ) aj λ a j 1 j ( exp b ) jλ j. λ j 1

336 Priors for PHREG For α, we can take π(α) 1, [ π(α) exp 1 ] 2 (α α 0) Φ 1 0 (α α 0). We can also take a joint multivariate normal prior for (α, β), given by ( π(α, β) exp 1 2 [ (α α0), (β β 0 ) ] Φ 1 [ 0 (α α0), (β β 0 ) ] ).

337 Priors for PHREG For the piecewise exponential model, the joint posterior of (λ, β) is now given by p(λ, β D) L(λ, β)π(β)π(λ). For the loghazard model, the joint posterior of (α, β) is given by { L(α, β)π(α, β) if (α, β) MV N p(α, β D) L(α, β)π(α)π(β) otherwise.

338 Piecewise Exponential Model The key command for the piecewise exponential model is piecewise = details of the piecewise exponential model The user can specify the number of intervals (hazard parameters λ j ), or interval partitions, and the prior distribution for the hazard functions. The default number of intervals is J = 8.

339 PHREG for E1684 Data data melanoma; infile H:/e1684ws.dat ; input case study age trt sex perform nodes breslow failtime rfscens survtime scens; run; proc phreg; model failtime*rfscens(0) = trt age sex; bayes seed = 532 nbi=3000 nmc = coeffprior = uniform diagnostics = none; run; proc phreg; model failtime*rfscens(0) = trt age sex; bayes seed = 5432 nbi=3000 nmc = coeffprior = normal diagnostics = none; run;

340 PHREG for E1684 Data proc phreg; model failtime*rfscens(0) = trt age sex; bayes seed = 5432 nbi=3000 nmc = coeffprior = normal piecewise = hazard(n=15 prior=gamma) diagnostics = none; run; proc phreg; model failtime*rfscens(0) = trt age sex; bayes seed = 5432 nbi=3000 nmc = coeffprior = normal piecewise = hazard(n=15 prior=improper) diagnostics = none; run;

341 PHREG for E1684 Data proc phreg; model failtime*rfscens(0) = trt age sex; bayes seed = 5432 nbi=3000 nmc = coeffprior = normal piecewise = loghazard(n=15 prior=normal) diagnostics = none; run;

342 Cox Model for E1684 Data: Uniform Priors The PHREG Procedure Bayesian Analysis Model Information Data Set WORK.MELANOMA Dependent Variable failtime Censoring Variable rfscens Censoring Value(s) 0 Model Cox Ties Handling BRESLOW Burn-In Size 3000 MC Sample Size Thinning 1 Number of Observations Read 286 Number of Observations Used 285

343 Cox Model for E1684 Data: Uniform Priors Summary of the Number of Event and Censored Values Percent Total Event Censored Censored Maximum Likelihood Estimates Standard Parameter DF Estimate Error 95% Confidence Limits trt age sex Uniform Prior for Regression Coefficients Parameter trt age sex Prior Constant Constant Constant

344 Cox Model for E1684 Data: Uniform Priors The PHREG Procedure Bayesian Analysis Initial Values of the Chains Chain Seed trt age sex Fit Statistics AIC (smaller is better) BIC (smaller is better) DIC (smaller is better) pd (Effective Number of Parameters) 3.012

345 Cox Model for E1684 Data: Uniform Priors The PHREG Procedure Bayesian Analysis Posterior Summaries Standard Percentiles Parameter N Mean Deviation 25% 50% 75% trt age sex Posterior Intervals Parameter Alpha Equal-Tail Interval HPD Interval trt age sex

346 Cox Model with Normal Prior The PHREG Procedure Bayesian Analysis Model Information Data Set WORK.MELANOMA Maximum Likelihood Estimates Standard Parameter DF Estimate Error 95% Confidence Limits trt age sex Independent Normal Prior for Regression Coefficients Parameter Mean Precision trt 0 1E-6 age 0 1E-6 sex 0 1E-6

347 Cox Model with Normal Prior The PHREG Procedure Bayesian Analysis Initial Values of the Chains Chain Seed trt age sex Fit Statistics AIC (smaller is better) BIC (smaller is better) DIC (smaller is better) pd (Effective Number of Parameters) 3.016

348 Cox Model with Normal Prior The PHREG Procedure Bayesian Analysis Posterior Summaries Standard Percentiles Parameter N Mean Deviation 25% 50% 75% trt age sex Posterior Intervals Parameter Alpha Equal-Tail Interval HPD Interval trt age sex

349 Piecewise Constant Hazards Model Constant Hazard Time Intervals Interval Hazard [Lower, Upper) N Event Parameter Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Infty Lambda15

350 Piecewise Constant Hazards Model The PHREG Procedure Bayesian Analysis Maximum Likelihood Estimates Standard Parameter DF Estimate Error 95% Confidence Limits Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda trt age sex

351 Piecewise Constant Hazards Model Independent Gamma Prior for Hazards Hyperparameters Inverse Parameter Shape Scale Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda

352 Piecewise Constant Hazards Model The PHREG Procedure Bayesian Analysis Independent Normal Prior for Regression Coefficients Parameter Mean Precision trt 0 1E-6 age 0 1E-6 sex 0 1E-6 Initial Values of the Chains Chain Seed Lambda1 Lambda2 Lambda3 Lambda4 Lambda5 Lambda Initial Values of the Chains Chain Lambda7 Lambda8 Lambda9 Lambda10 Lambda11 Lambda12 Lambda Initial Values of the Chains Chain Lambda14 Lambda15 trt age sex

353 Piecewise Constant Hazards Model Bayesian Analysis Posterior Summaries Standard Percentiles Parameter N Mean Deviation 25% 50% 75% Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda trt age sex

354 Piecewise Constant Hazards Model Posterior Intervals Parameter Alpha Equal-Tail Interval HPD Interval Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda Lambda trt age sex

355 Further Prior Constructions in PHREG data NormalPrior2; input _type_ $ _name_:$9. trt age sex; cards; Mean Cov trt Cov age Cov sex ; run; proc phreg data=melanoma; model failtime*rfscens(0) = trt age sex; bayes seed = 5432 nbi=3000 nmc = coeffprior = normal(input=normalprior2) run;

356 Further Prior Constructions in PHREG data lambdaprior1; input _type_ $ lambda1-lambda5; cards; shape a1 a2 a3 a4 a5 iscale b1 b2 b3 b4 b5; run; proc phreg data=melanoma; model failtime*rfscens(0) = trt age sex; bayes seed = 5432 nbi=3000 nmc = coeffprior = normal(input=normalprior1) piecewise = hazard(prior=gamma(input=lambdaprior1)); run;

357 PHREG: Posterior Hazard Ratios PHREG enables the user to compute hazard ratios for class variables for the Cox or piecewise exponential models using the hazardratio statement. If A is a class variable, then we can use the statement hazardratio A; If X is a continuous variable, the following specification displays a table of hazard ratios comparing the hazards of each pair of levels of A at X=3. hazardratio A/ at (X = 3) diff = ALL;

358 E1690 Data E1690 was a follow-up confirmatory study to E1684 using the exact same patient population and same treatment arms. There were a total of n = 427 subjects on the observation and treatment arms combined for E1690. The primary endpoint was RFS.

359 E1690 Bayesian Analysis Here, we can do a Bayesian analysis of E1690 in one of several ways: analyze the E1690 data alone with a noninformative prior on β. analyze the E1690 data and treat E1684 as historical data and construct a prior from the E1684 data using power prior ideas. We specify a prior of the form β N( β, a 1 Σ), 0 where β is the posterior mean of β based on a Bayesian analysis of E1684 using the Cox model with a uniform improper prior and Σ is the posterior covariance matrix. We took a 0 = 1 in the analysis below. Combine both data sets into one big data set and introduce a binary covariate for study, and then do a Bayesian analysis on the combined data set using noninformative priors for β.

360 SAS Code for E1690 Bayesian Analysis data melanoma; infile H:/e1690ws.dat ; input case study age trt sex perform nodes breslow failtime rfscens survtime scens; run; proc phreg; model failtime*rfscens(0) = trt age sex; bayes seed = 532 nbi=3000 nmc = coeffprior = uniform summary = all diagnostics = none plots=none; run;

361 SAS Code for E1690 Bayesian Analysis data Normalprior2; input _type_ $ _name_:$3. trt age sex; cards; Mean Cov trt e e e-03 Cov age e e e-05 Cov sex e e e-02 ; run; proc phreg ; model failtime*rfscens(0) = trt age sex; bayes seed = 5432 nbi=3000 nmc = coeffprior = normal(input=normalprior2) summary = all diagnostics = none plots=none; run;

362 E1690: Cox model and Uniform prior for β Bayesian Analysis Posterior Summaries Standard Percentiles Parameter N Mean Deviation 25% 50% 75% trt age sex Posterior Intervals Parameter Alpha Equal-Tail Interval HPD Interval trt age sex

363 E1690: Cox model and Informative Normal Prior for β Normal Prior for Regression Coefficients Covariance Matrix Parameter Mean trt age sex trt E age E sex Posterior Summaries Standard Percentiles Parameter N Mean Deviation 25% 50% 75% trt age sex

364 E1690: Cox model and Informative Normal Prior for β Posterior Intervals Parameter Alpha Equal-Tail Interval HPD Interval trt age sex

365 E1690: Cox model Based on Combined Datasets Bayesian Analysis Posterior Summaries Standard Percentiles Parameter N Mean Deviation 25% 50% 75% trt age sex

366 E1690: Cox model Based on Combined Datasets Posterior Intervals Parameter Alpha Equal-Tail Interval HPD Interval trt age sex

367 Hazard Ratios for E1690 proc phreg; class trt; model failtime*rfscens(0) = trt age sex; bayes seed = 532 nbi=3000 nmc = coeffprior = uniform summary = all diagnostics = none plots=none; hazardratio trt; run;

368 Hazard Ratios for E1690 Hazard Ratios for trt Standard Quantiles Description N Mean Deviation 25% 50% 75% trt 0 vs Hazard Ratios for trt 95% Equal-Tail Interval 95% HPD Interval

369 Closing Remarks SAS has developed some excellent software for carrying out Bayesian analyses of generalized linear models and survival models. The software can handle large data sets and has a large suite of models and priors to choose from. The survival models are discussed in more detail in the book by Ibrahim, Chen, and Sinha (2001), titled Bayesian Survival Analysis, Springer-Verlag. There will be plenty of enhancements to come in future editions. Thanks to SAS for taking on this very important project!

370 References Ibrahim, JG, Chen, MH, and Sinha, D (2001), Bayesian Survival Analysis, Springer-Verlag.

SAS Software to Fit the Generalized Linear Model

SAS Software to Fit the Generalized Linear Model SAS Software to Fit the Generalized Linear Model Gordon Johnston, SAS Institute Inc., Cary, NC Abstract In recent years, the class of generalized linear models has gained popularity as a statistical modeling

More information

More details on the inputs, functionality, and output can be found below.

More details on the inputs, functionality, and output can be found below. Overview: The SMEEACT (Software for More Efficient, Ethical, and Affordable Clinical Trials) web interface (http://research.mdacc.tmc.edu/smeeactweb) implements a single analysis of a two-armed trial comparing

More information

STATISTICA Formula Guide: Logistic Regression. Table of Contents

STATISTICA Formula Guide: Logistic Regression. Table of Contents : Table of Contents... 1 Overview of Model... 1 Dispersion... 2 Parameterization... 3 Sigma-Restricted Model... 3 Overparameterized Model... 4 Reference Coding... 4 Model Summary (Summary Tab)... 5 Summary

More information

Basics of Statistical Machine Learning

Basics of Statistical Machine Learning CS761 Spring 2013 Advanced Machine Learning Basics of Statistical Machine Learning Lecturer: Xiaojin Zhu [email protected] Modern machine learning is rooted in statistics. You will find many familiar

More information

VI. Introduction to Logistic Regression

VI. Introduction to Logistic Regression VI. Introduction to Logistic Regression We turn our attention now to the topic of modeling a categorical outcome as a function of (possibly) several factors. The framework of generalized linear models

More information

Part 2: One-parameter models

Part 2: One-parameter models Part 2: One-parameter models Bernoilli/binomial models Return to iid Y 1,...,Y n Bin(1, θ). The sampling model/likelihood is p(y 1,...,y n θ) =θ P y i (1 θ) n P y i When combined with a prior p(θ), Bayes

More information

BayesX - Software for Bayesian Inference in Structured Additive Regression

BayesX - Software for Bayesian Inference in Structured Additive Regression BayesX - Software for Bayesian Inference in Structured Additive Regression Thomas Kneib Faculty of Mathematics and Economics, University of Ulm Department of Statistics, Ludwig-Maximilians-University Munich

More information

Statistics in Retail Finance. Chapter 6: Behavioural models

Statistics in Retail Finance. Chapter 6: Behavioural models Statistics in Retail Finance 1 Overview > So far we have focussed mainly on application scorecards. In this chapter we shall look at behavioural models. We shall cover the following topics:- Behavioural

More information

Bayesian Statistics in One Hour. Patrick Lam

Bayesian Statistics in One Hour. Patrick Lam Bayesian Statistics in One Hour Patrick Lam Outline Introduction Bayesian Models Applications Missing Data Hierarchical Models Outline Introduction Bayesian Models Applications Missing Data Hierarchical

More information

Modeling and Analysis of Call Center Arrival Data: A Bayesian Approach

Modeling and Analysis of Call Center Arrival Data: A Bayesian Approach Modeling and Analysis of Call Center Arrival Data: A Bayesian Approach Refik Soyer * Department of Management Science The George Washington University M. Murat Tarimcilar Department of Management Science

More information

Basic Bayesian Methods

Basic Bayesian Methods 6 Basic Bayesian Methods Mark E. Glickman and David A. van Dyk Summary In this chapter, we introduce the basics of Bayesian data analysis. The key ingredients to a Bayesian analysis are the likelihood

More information

Tutorial on Markov Chain Monte Carlo

Tutorial on Markov Chain Monte Carlo Tutorial on Markov Chain Monte Carlo Kenneth M. Hanson Los Alamos National Laboratory Presented at the 29 th International Workshop on Bayesian Inference and Maximum Entropy Methods in Science and Technology,

More information

Applications of R Software in Bayesian Data Analysis

Applications of R Software in Bayesian Data Analysis Article International Journal of Information Science and System, 2012, 1(1): 7-23 International Journal of Information Science and System Journal homepage: www.modernscientificpress.com/journals/ijinfosci.aspx

More information

Statistics Graduate Courses

Statistics Graduate Courses Statistics Graduate Courses STAT 7002--Topics in Statistics-Biological/Physical/Mathematics (cr.arr.).organized study of selected topics. Subjects and earnable credit may vary from semester to semester.

More information

Using SAS PROC MCMC to Estimate and Evaluate Item Response Theory Models

Using SAS PROC MCMC to Estimate and Evaluate Item Response Theory Models Using SAS PROC MCMC to Estimate and Evaluate Item Response Theory Models Clement A Stone Abstract Interest in estimating item response theory (IRT) models using Bayesian methods has grown tremendously

More information

MATH4427 Notebook 2 Spring 2016. 2 MATH4427 Notebook 2 3. 2.1 Definitions and Examples... 3. 2.2 Performance Measures for Estimators...

MATH4427 Notebook 2 Spring 2016. 2 MATH4427 Notebook 2 3. 2.1 Definitions and Examples... 3. 2.2 Performance Measures for Estimators... MATH4427 Notebook 2 Spring 2016 prepared by Professor Jenny Baglivo c Copyright 2009-2016 by Jenny A. Baglivo. All Rights Reserved. Contents 2 MATH4427 Notebook 2 3 2.1 Definitions and Examples...................................

More information

Adequacy of Biomath. Models. Empirical Modeling Tools. Bayesian Modeling. Model Uncertainty / Selection

Adequacy of Biomath. Models. Empirical Modeling Tools. Bayesian Modeling. Model Uncertainty / Selection Directions in Statistical Methodology for Multivariable Predictive Modeling Frank E Harrell Jr University of Virginia Seattle WA 19May98 Overview of Modeling Process Model selection Regression shape Diagnostics

More information

Gamma Distribution Fitting

Gamma Distribution Fitting Chapter 552 Gamma Distribution Fitting Introduction This module fits the gamma probability distributions to a complete or censored set of individual or grouped data values. It outputs various statistics

More information

Likelihood Approaches for Trial Designs in Early Phase Oncology

Likelihood Approaches for Trial Designs in Early Phase Oncology Likelihood Approaches for Trial Designs in Early Phase Oncology Clinical Trials Elizabeth Garrett-Mayer, PhD Cody Chiuzan, PhD Hollings Cancer Center Department of Public Health Sciences Medical University

More information

Example: Credit card default, we may be more interested in predicting the probabilty of a default than classifying individuals as default or not.

Example: Credit card default, we may be more interested in predicting the probabilty of a default than classifying individuals as default or not. Statistical Learning: Chapter 4 Classification 4.1 Introduction Supervised learning with a categorical (Qualitative) response Notation: - Feature vector X, - qualitative response Y, taking values in C

More information

Generalized Linear Models

Generalized Linear Models Generalized Linear Models We have previously worked with regression models where the response variable is quantitative and normally distributed. Now we turn our attention to two types of models where the

More information

Probabilistic Models for Big Data. Alex Davies and Roger Frigola University of Cambridge 13th February 2014

Probabilistic Models for Big Data. Alex Davies and Roger Frigola University of Cambridge 13th February 2014 Probabilistic Models for Big Data Alex Davies and Roger Frigola University of Cambridge 13th February 2014 The State of Big Data Why probabilistic models for Big Data? 1. If you don t have to worry about

More information

CHAPTER 3 EXAMPLES: REGRESSION AND PATH ANALYSIS

CHAPTER 3 EXAMPLES: REGRESSION AND PATH ANALYSIS Examples: Regression And Path Analysis CHAPTER 3 EXAMPLES: REGRESSION AND PATH ANALYSIS Regression analysis with univariate or multivariate dependent variables is a standard procedure for modeling relationships

More information

An Introduction to Using WinBUGS for Cost-Effectiveness Analyses in Health Economics

An Introduction to Using WinBUGS for Cost-Effectiveness Analyses in Health Economics Slide 1 An Introduction to Using WinBUGS for Cost-Effectiveness Analyses in Health Economics Dr. Christian Asseburg Centre for Health Economics Part 1 Slide 2 Talk overview Foundations of Bayesian statistics

More information

Reliability estimators for the components of series and parallel systems: The Weibull model

Reliability estimators for the components of series and parallel systems: The Weibull model Reliability estimators for the components of series and parallel systems: The Weibull model Felipe L. Bhering 1, Carlos Alberto de Bragança Pereira 1, Adriano Polpo 2 1 Department of Statistics, University

More information

Lecture 3: Linear methods for classification

Lecture 3: Linear methods for classification Lecture 3: Linear methods for classification Rafael A. Irizarry and Hector Corrada Bravo February, 2010 Today we describe four specific algorithms useful for classification problems: linear regression,

More information

BAYESIAN ANALYSIS OF AN AGGREGATE CLAIM MODEL USING VARIOUS LOSS DISTRIBUTIONS. by Claire Dudley

BAYESIAN ANALYSIS OF AN AGGREGATE CLAIM MODEL USING VARIOUS LOSS DISTRIBUTIONS. by Claire Dudley BAYESIAN ANALYSIS OF AN AGGREGATE CLAIM MODEL USING VARIOUS LOSS DISTRIBUTIONS by Claire Dudley A dissertation submitted for the award of the degree of Master of Science in Actuarial Management School

More information

Multivariate Logistic Regression

Multivariate Logistic Regression 1 Multivariate Logistic Regression As in univariate logistic regression, let π(x) represent the probability of an event that depends on p covariates or independent variables. Then, using an inv.logit formulation

More information

Nonparametric adaptive age replacement with a one-cycle criterion

Nonparametric adaptive age replacement with a one-cycle criterion Nonparametric adaptive age replacement with a one-cycle criterion P. Coolen-Schrijner, F.P.A. Coolen Department of Mathematical Sciences University of Durham, Durham, DH1 3LE, UK e-mail: [email protected]

More information

Statistical Machine Learning

Statistical Machine Learning Statistical Machine Learning UoC Stats 37700, Winter quarter Lecture 4: classical linear and quadratic discriminants. 1 / 25 Linear separation For two classes in R d : simple idea: separate the classes

More information

Spatial Statistics Chapter 3 Basics of areal data and areal data modeling

Spatial Statistics Chapter 3 Basics of areal data and areal data modeling Spatial Statistics Chapter 3 Basics of areal data and areal data modeling Recall areal data also known as lattice data are data Y (s), s D where D is a discrete index set. This usually corresponds to data

More information

Examples. David Ruppert. April 25, 2009. Cornell University. Statistics for Financial Engineering: Some R. Examples. David Ruppert.

Examples. David Ruppert. April 25, 2009. Cornell University. Statistics for Financial Engineering: Some R. Examples. David Ruppert. Cornell University April 25, 2009 Outline 1 2 3 4 A little about myself BA and MA in mathematics PhD in statistics in 1977 taught in the statistics department at North Carolina for 10 years have been in

More information

Auxiliary Variables in Mixture Modeling: 3-Step Approaches Using Mplus

Auxiliary Variables in Mixture Modeling: 3-Step Approaches Using Mplus Auxiliary Variables in Mixture Modeling: 3-Step Approaches Using Mplus Tihomir Asparouhov and Bengt Muthén Mplus Web Notes: No. 15 Version 8, August 5, 2014 1 Abstract This paper discusses alternatives

More information

Service courses for graduate students in degree programs other than the MS or PhD programs in Biostatistics.

Service courses for graduate students in degree programs other than the MS or PhD programs in Biostatistics. Course Catalog In order to be assured that all prerequisites are met, students must acquire a permission number from the education coordinator prior to enrolling in any Biostatistics course. Courses are

More information

Parallelization Strategies for Multicore Data Analysis

Parallelization Strategies for Multicore Data Analysis Parallelization Strategies for Multicore Data Analysis Wei-Chen Chen 1 Russell Zaretzki 2 1 University of Tennessee, Dept of EEB 2 University of Tennessee, Dept. Statistics, Operations, and Management

More information

Basic Statistical and Modeling Procedures Using SAS

Basic Statistical and Modeling Procedures Using SAS Basic Statistical and Modeling Procedures Using SAS One-Sample Tests The statistical procedures illustrated in this handout use two datasets. The first, Pulse, has information collected in a classroom

More information

Logistic Regression (a type of Generalized Linear Model)

Logistic Regression (a type of Generalized Linear Model) Logistic Regression (a type of Generalized Linear Model) 1/36 Today Review of GLMs Logistic Regression 2/36 How do we find patterns in data? We begin with a model of how the world works We use our knowledge

More information

STA 4273H: Statistical Machine Learning

STA 4273H: Statistical Machine Learning STA 4273H: Statistical Machine Learning Russ Salakhutdinov Department of Statistics! [email protected]! http://www.cs.toronto.edu/~rsalakhu/ Lecture 6 Three Approaches to Classification Construct

More information

Journal of Statistical Software

Journal of Statistical Software JSS Journal of Statistical Software October 2014, Volume 61, Issue 7. http://www.jstatsoft.org/ WebBUGS: Conducting Bayesian Statistical Analysis Online Zhiyong Zhang University of Notre Dame Abstract

More information

SUMAN DUVVURU STAT 567 PROJECT REPORT

SUMAN DUVVURU STAT 567 PROJECT REPORT SUMAN DUVVURU STAT 567 PROJECT REPORT SURVIVAL ANALYSIS OF HEROIN ADDICTS Background and introduction: Current illicit drug use among teens is continuing to increase in many countries around the world.

More information

Supplement to Call Centers with Delay Information: Models and Insights

Supplement to Call Centers with Delay Information: Models and Insights Supplement to Call Centers with Delay Information: Models and Insights Oualid Jouini 1 Zeynep Akşin 2 Yves Dallery 1 1 Laboratoire Genie Industriel, Ecole Centrale Paris, Grande Voie des Vignes, 92290

More information

Institute of Actuaries of India Subject CT3 Probability and Mathematical Statistics

Institute of Actuaries of India Subject CT3 Probability and Mathematical Statistics Institute of Actuaries of India Subject CT3 Probability and Mathematical Statistics For 2015 Examinations Aim The aim of the Probability and Mathematical Statistics subject is to provide a grounding in

More information

SAS Certificate Applied Statistics and SAS Programming

SAS Certificate Applied Statistics and SAS Programming SAS Certificate Applied Statistics and SAS Programming SAS Certificate Applied Statistics and Advanced SAS Programming Brigham Young University Department of Statistics offers an Applied Statistics and

More information

Simple Linear Regression Inference

Simple Linear Regression Inference Simple Linear Regression Inference 1 Inference requirements The Normality assumption of the stochastic term e is needed for inference even if it is not a OLS requirement. Therefore we have: Interpretation

More information

Bayesian Analysis for the Social Sciences

Bayesian Analysis for the Social Sciences Bayesian Analysis for the Social Sciences Simon Jackman Stanford University http://jackman.stanford.edu/bass November 9, 2012 Simon Jackman (Stanford) Bayesian Analysis for the Social Sciences November

More information

LOGISTIC REGRESSION. Nitin R Patel. where the dependent variable, y, is binary (for convenience we often code these values as

LOGISTIC REGRESSION. Nitin R Patel. where the dependent variable, y, is binary (for convenience we often code these values as LOGISTIC REGRESSION Nitin R Patel Logistic regression extends the ideas of multiple linear regression to the situation where the dependent variable, y, is binary (for convenience we often code these values

More information

Poisson Models for Count Data

Poisson Models for Count Data Chapter 4 Poisson Models for Count Data In this chapter we study log-linear models for count data under the assumption of a Poisson error structure. These models have many applications, not only to the

More information

THE USE OF STATISTICAL DISTRIBUTIONS TO MODEL CLAIMS IN MOTOR INSURANCE

THE USE OF STATISTICAL DISTRIBUTIONS TO MODEL CLAIMS IN MOTOR INSURANCE THE USE OF STATISTICAL DISTRIBUTIONS TO MODEL CLAIMS IN MOTOR INSURANCE Batsirai Winmore Mazviona 1 Tafadzwa Chiduza 2 ABSTRACT In general insurance, companies need to use data on claims gathered from

More information

E3: PROBABILITY AND STATISTICS lecture notes

E3: PROBABILITY AND STATISTICS lecture notes E3: PROBABILITY AND STATISTICS lecture notes 2 Contents 1 PROBABILITY THEORY 7 1.1 Experiments and random events............................ 7 1.2 Certain event. Impossible event............................

More information

Dongfeng Li. Autumn 2010

Dongfeng Li. Autumn 2010 Autumn 2010 Chapter Contents Some statistics background; ; Comparing means and proportions; variance. Students should master the basic concepts, descriptive statistics measures and graphs, basic hypothesis

More information

200609 - ATV - Lifetime Data Analysis

200609 - ATV - Lifetime Data Analysis Coordinating unit: Teaching unit: Academic year: Degree: ECTS credits: 2015 200 - FME - School of Mathematics and Statistics 715 - EIO - Department of Statistics and Operations Research 1004 - UB - (ENG)Universitat

More information

Imputing Missing Data using SAS

Imputing Missing Data using SAS ABSTRACT Paper 3295-2015 Imputing Missing Data using SAS Christopher Yim, California Polytechnic State University, San Luis Obispo Missing data is an unfortunate reality of statistics. However, there are

More information

A Latent Variable Approach to Validate Credit Rating Systems using R

A Latent Variable Approach to Validate Credit Rating Systems using R A Latent Variable Approach to Validate Credit Rating Systems using R Chicago, April 24, 2009 Bettina Grün a, Paul Hofmarcher a, Kurt Hornik a, Christoph Leitner a, Stefan Pichler a a WU Wien Grün/Hofmarcher/Hornik/Leitner/Pichler

More information

Validation of Software for Bayesian Models using Posterior Quantiles. Samantha R. Cook Andrew Gelman Donald B. Rubin DRAFT

Validation of Software for Bayesian Models using Posterior Quantiles. Samantha R. Cook Andrew Gelman Donald B. Rubin DRAFT Validation of Software for Bayesian Models using Posterior Quantiles Samantha R. Cook Andrew Gelman Donald B. Rubin DRAFT Abstract We present a simulation-based method designed to establish that software

More information

How To Check For Differences In The One Way Anova

How To Check For Differences In The One Way Anova MINITAB ASSISTANT WHITE PAPER This paper explains the research conducted by Minitab statisticians to develop the methods and data checks used in the Assistant in Minitab 17 Statistical Software. One-Way

More information

Principle of Data Reduction

Principle of Data Reduction Chapter 6 Principle of Data Reduction 6.1 Introduction An experimenter uses the information in a sample X 1,..., X n to make inferences about an unknown parameter θ. If the sample size n is large, then

More information

A Bayesian hierarchical surrogate outcome model for multiple sclerosis

A Bayesian hierarchical surrogate outcome model for multiple sclerosis A Bayesian hierarchical surrogate outcome model for multiple sclerosis 3 rd Annual ASA New Jersey Chapter / Bayer Statistics Workshop David Ohlssen (Novartis), Luca Pozzi and Heinz Schmidli (Novartis)

More information

The Variability of P-Values. Summary

The Variability of P-Values. Summary The Variability of P-Values Dennis D. Boos Department of Statistics North Carolina State University Raleigh, NC 27695-8203 [email protected] August 15, 2009 NC State Statistics Departement Tech Report

More information

Comparison of resampling method applied to censored data

Comparison of resampling method applied to censored data International Journal of Advanced Statistics and Probability, 2 (2) (2014) 48-55 c Science Publishing Corporation www.sciencepubco.com/index.php/ijasp doi: 10.14419/ijasp.v2i2.2291 Research Paper Comparison

More information

Least Squares Estimation

Least Squares Estimation Least Squares Estimation SARA A VAN DE GEER Volume 2, pp 1041 1045 in Encyclopedia of Statistics in Behavioral Science ISBN-13: 978-0-470-86080-9 ISBN-10: 0-470-86080-4 Editors Brian S Everitt & David

More information

Bayesian Statistics: Indian Buffet Process

Bayesian Statistics: Indian Buffet Process Bayesian Statistics: Indian Buffet Process Ilker Yildirim Department of Brain and Cognitive Sciences University of Rochester Rochester, NY 14627 August 2012 Reference: Most of the material in this note

More information

Distribution (Weibull) Fitting

Distribution (Weibull) Fitting Chapter 550 Distribution (Weibull) Fitting Introduction This procedure estimates the parameters of the exponential, extreme value, logistic, log-logistic, lognormal, normal, and Weibull probability distributions

More information

PS 271B: Quantitative Methods II. Lecture Notes

PS 271B: Quantitative Methods II. Lecture Notes PS 271B: Quantitative Methods II Lecture Notes Langche Zeng [email protected] The Empirical Research Process; Fundamental Methodological Issues 2 Theory; Data; Models/model selection; Estimation; Inference.

More information

How To Understand The Theory Of Probability

How To Understand The Theory Of Probability Graduate Programs in Statistics Course Titles STAT 100 CALCULUS AND MATR IX ALGEBRA FOR STATISTICS. Differential and integral calculus; infinite series; matrix algebra STAT 195 INTRODUCTION TO MATHEMATICAL

More information

Markov Chain Monte Carlo Simulation Made Simple

Markov Chain Monte Carlo Simulation Made Simple Markov Chain Monte Carlo Simulation Made Simple Alastair Smith Department of Politics New York University April2,2003 1 Markov Chain Monte Carlo (MCMC) simualtion is a powerful technique to perform numerical

More information

Bootstrapping Big Data

Bootstrapping Big Data Bootstrapping Big Data Ariel Kleiner Ameet Talwalkar Purnamrita Sarkar Michael I. Jordan Computer Science Division University of California, Berkeley {akleiner, ameet, psarkar, jordan}@eecs.berkeley.edu

More information

11. Time series and dynamic linear models

11. Time series and dynamic linear models 11. Time series and dynamic linear models Objective To introduce the Bayesian approach to the modeling and forecasting of time series. Recommended reading West, M. and Harrison, J. (1997). models, (2 nd

More information

PREDICTIVE DISTRIBUTIONS OF OUTSTANDING LIABILITIES IN GENERAL INSURANCE

PREDICTIVE DISTRIBUTIONS OF OUTSTANDING LIABILITIES IN GENERAL INSURANCE PREDICTIVE DISTRIBUTIONS OF OUTSTANDING LIABILITIES IN GENERAL INSURANCE BY P.D. ENGLAND AND R.J. VERRALL ABSTRACT This paper extends the methods introduced in England & Verrall (00), and shows how predictive

More information

Chicago Booth BUSINESS STATISTICS 41000 Final Exam Fall 2011

Chicago Booth BUSINESS STATISTICS 41000 Final Exam Fall 2011 Chicago Booth BUSINESS STATISTICS 41000 Final Exam Fall 2011 Name: Section: I pledge my honor that I have not violated the Honor Code Signature: This exam has 34 pages. You have 3 hours to complete this

More information

11. Analysis of Case-control Studies Logistic Regression

11. Analysis of Case-control Studies Logistic Regression Research methods II 113 11. Analysis of Case-control Studies Logistic Regression This chapter builds upon and further develops the concepts and strategies described in Ch.6 of Mother and Child Health:

More information

Overview Classes. 12-3 Logistic regression (5) 19-3 Building and applying logistic regression (6) 26-3 Generalizations of logistic regression (7)

Overview Classes. 12-3 Logistic regression (5) 19-3 Building and applying logistic regression (6) 26-3 Generalizations of logistic regression (7) Overview Classes 12-3 Logistic regression (5) 19-3 Building and applying logistic regression (6) 26-3 Generalizations of logistic regression (7) 2-4 Loglinear models (8) 5-4 15-17 hrs; 5B02 Building and

More information

A Basic Introduction to Missing Data

A Basic Introduction to Missing Data John Fox Sociology 740 Winter 2014 Outline Why Missing Data Arise Why Missing Data Arise Global or unit non-response. In a survey, certain respondents may be unreachable or may refuse to participate. Item

More information

Probability Calculator

Probability Calculator Chapter 95 Introduction Most statisticians have a set of probability tables that they refer to in doing their statistical wor. This procedure provides you with a set of electronic statistical tables that

More information

Logistic Regression (1/24/13)

Logistic Regression (1/24/13) STA63/CBB540: Statistical methods in computational biology Logistic Regression (/24/3) Lecturer: Barbara Engelhardt Scribe: Dinesh Manandhar Introduction Logistic regression is model for regression used

More information

Tests for Two Survival Curves Using Cox s Proportional Hazards Model

Tests for Two Survival Curves Using Cox s Proportional Hazards Model Chapter 730 Tests for Two Survival Curves Using Cox s Proportional Hazards Model Introduction A clinical trial is often employed to test the equality of survival distributions of two treatment groups.

More information

SOCIETY OF ACTUARIES/CASUALTY ACTUARIAL SOCIETY EXAM C CONSTRUCTION AND EVALUATION OF ACTUARIAL MODELS EXAM C SAMPLE QUESTIONS

SOCIETY OF ACTUARIES/CASUALTY ACTUARIAL SOCIETY EXAM C CONSTRUCTION AND EVALUATION OF ACTUARIAL MODELS EXAM C SAMPLE QUESTIONS SOCIETY OF ACTUARIES/CASUALTY ACTUARIAL SOCIETY EXAM C CONSTRUCTION AND EVALUATION OF ACTUARIAL MODELS EXAM C SAMPLE QUESTIONS Copyright 005 by the Society of Actuaries and the Casualty Actuarial Society

More information

A Bootstrap Metropolis-Hastings Algorithm for Bayesian Analysis of Big Data

A Bootstrap Metropolis-Hastings Algorithm for Bayesian Analysis of Big Data A Bootstrap Metropolis-Hastings Algorithm for Bayesian Analysis of Big Data Faming Liang University of Florida August 9, 2015 Abstract MCMC methods have proven to be a very powerful tool for analyzing

More information

Introduction to Event History Analysis DUSTIN BROWN POPULATION RESEARCH CENTER

Introduction to Event History Analysis DUSTIN BROWN POPULATION RESEARCH CENTER Introduction to Event History Analysis DUSTIN BROWN POPULATION RESEARCH CENTER Objectives Introduce event history analysis Describe some common survival (hazard) distributions Introduce some useful Stata

More information

Reject Inference in Credit Scoring. Jie-Men Mok

Reject Inference in Credit Scoring. Jie-Men Mok Reject Inference in Credit Scoring Jie-Men Mok BMI paper January 2009 ii Preface In the Master programme of Business Mathematics and Informatics (BMI), it is required to perform research on a business

More information

Permutation Tests for Comparing Two Populations

Permutation Tests for Comparing Two Populations Permutation Tests for Comparing Two Populations Ferry Butar Butar, Ph.D. Jae-Wan Park Abstract Permutation tests for comparing two populations could be widely used in practice because of flexibility of

More information

Maximum Likelihood Estimation

Maximum Likelihood Estimation Math 541: Statistical Theory II Lecturer: Songfeng Zheng Maximum Likelihood Estimation 1 Maximum Likelihood Estimation Maximum likelihood is a relatively simple method of constructing an estimator for

More information

Why Taking This Course? Course Introduction, Descriptive Statistics and Data Visualization. Learning Goals. GENOME 560, Spring 2012

Why Taking This Course? Course Introduction, Descriptive Statistics and Data Visualization. Learning Goals. GENOME 560, Spring 2012 Why Taking This Course? Course Introduction, Descriptive Statistics and Data Visualization GENOME 560, Spring 2012 Data are interesting because they help us understand the world Genomics: Massive Amounts

More information

Centre for Central Banking Studies

Centre for Central Banking Studies Centre for Central Banking Studies Technical Handbook No. 4 Applied Bayesian econometrics for central bankers Andrew Blake and Haroon Mumtaz CCBS Technical Handbook No. 4 Applied Bayesian econometrics

More information

Statistical Functions in Excel

Statistical Functions in Excel Statistical Functions in Excel There are many statistical functions in Excel. Moreover, there are other functions that are not specified as statistical functions that are helpful in some statistical analyses.

More information

Ordinal Regression. Chapter

Ordinal Regression. Chapter Ordinal Regression Chapter 4 Many variables of interest are ordinal. That is, you can rank the values, but the real distance between categories is unknown. Diseases are graded on scales from least severe

More information

1 Prior Probability and Posterior Probability

1 Prior Probability and Posterior Probability Math 541: Statistical Theory II Bayesian Approach to Parameter Estimation Lecturer: Songfeng Zheng 1 Prior Probability and Posterior Probability Consider now a problem of statistical inference in which

More information

Exploratory Data Analysis

Exploratory Data Analysis Exploratory Data Analysis Johannes Schauer [email protected] Institute of Statistics Graz University of Technology Steyrergasse 17/IV, 8010 Graz www.statistics.tugraz.at February 12, 2008 Introduction

More information

Time Series Analysis

Time Series Analysis Time Series Analysis [email protected] Informatics and Mathematical Modelling Technical University of Denmark DK-2800 Kgs. Lyngby 1 Outline of the lecture Identification of univariate time series models, cont.:

More information

Curriculum Map Statistics and Probability Honors (348) Saugus High School Saugus Public Schools 2009-2010

Curriculum Map Statistics and Probability Honors (348) Saugus High School Saugus Public Schools 2009-2010 Curriculum Map Statistics and Probability Honors (348) Saugus High School Saugus Public Schools 2009-2010 Week 1 Week 2 14.0 Students organize and describe distributions of data by using a number of different

More information

Summary of Formulas and Concepts. Descriptive Statistics (Ch. 1-4)

Summary of Formulas and Concepts. Descriptive Statistics (Ch. 1-4) Summary of Formulas and Concepts Descriptive Statistics (Ch. 1-4) Definitions Population: The complete set of numerical information on a particular quantity in which an investigator is interested. We assume

More information

Gaussian Processes to Speed up Hamiltonian Monte Carlo

Gaussian Processes to Speed up Hamiltonian Monte Carlo Gaussian Processes to Speed up Hamiltonian Monte Carlo Matthieu Lê Murray, Iain http://videolectures.net/mlss09uk_murray_mcmc/ Rasmussen, Carl Edward. "Gaussian processes to speed up hybrid Monte Carlo

More information

Modeling Customer Lifetime Value Using Survival Analysis An Application in the Telecommunications Industry

Modeling Customer Lifetime Value Using Survival Analysis An Application in the Telecommunications Industry Paper 12028 Modeling Customer Lifetime Value Using Survival Analysis An Application in the Telecommunications Industry Junxiang Lu, Ph.D. Overland Park, Kansas ABSTRACT Increasingly, companies are viewing

More information

Parametric Survival Models

Parametric Survival Models Parametric Survival Models Germán Rodríguez [email protected] Spring, 2001; revised Spring 2005, Summer 2010 We consider briefly the analysis of survival data when one is willing to assume a parametric

More information

Bayesian logistic betting strategy against probability forecasting. Akimichi Takemura, Univ. Tokyo. November 12, 2012

Bayesian logistic betting strategy against probability forecasting. Akimichi Takemura, Univ. Tokyo. November 12, 2012 Bayesian logistic betting strategy against probability forecasting Akimichi Takemura, Univ. Tokyo (joint with Masayuki Kumon, Jing Li and Kei Takeuchi) November 12, 2012 arxiv:1204.3496. To appear in Stochastic

More information

Handling attrition and non-response in longitudinal data

Handling attrition and non-response in longitudinal data Longitudinal and Life Course Studies 2009 Volume 1 Issue 1 Pp 63-72 Handling attrition and non-response in longitudinal data Harvey Goldstein University of Bristol Correspondence. Professor H. Goldstein

More information

Regression Modeling Strategies

Regression Modeling Strategies Frank E. Harrell, Jr. Regression Modeling Strategies With Applications to Linear Models, Logistic Regression, and Survival Analysis With 141 Figures Springer Contents Preface Typographical Conventions

More information

Monte Carlo Simulation

Monte Carlo Simulation 1 Monte Carlo Simulation Stefan Weber Leibniz Universität Hannover email: [email protected] web: www.stochastik.uni-hannover.de/ sweber Monte Carlo Simulation 2 Quantifying and Hedging

More information