46
Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm Supported by the Institute of Translational Health Sciences, Grant NIH 3 UL1 RR 025014-04S2 and the UW CHASE Alliance

Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Embed Size (px)

Citation preview

Page 1: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Introduction to Bayesian Statistical Software:

WinBUGS 1.4.3

Beth Devine, PharmD, MBA, PhDRafael Alfonso, MD, PhC

Evidence Synthesis9/22/2011

2:30 pm

Supported by the Institute of Translational Health Sciences, Grant NIH 3 UL1 RR 025014-04S2 and the UW CHASE Alliance

Page 2: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Comparative Effectiveness of Biologic Therapies in Rheumatoid Arthritis (RA): An Indirect Treatment Comparisons Approach

Beth Devine, PharmD, MBA, PhDRafael Alfonso-Cristancho, MD, MSSean Sullivan, BSPharm, PhDPharmaceutical Outcomes Research & Policy Program University of Washington

Pharmacotherapy 2011;31:39–51

Page 3: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

WinBUGS – Model Syntax

Page 4: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

WinBUGS – Load Data

Page 5: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

WinBUGS – Model Compiled

Page 6: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

WinBUGS – Model Initialized

Page 7: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

WinBUGS – Update (Burn-in)

Page 8: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

WinBUGS – Check Convergence

Page 9: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

WinBUGS – Obtaining Posterior Inference

Page 10: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

WinBUGS – Viewing Summary Statistics

Page 11: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

WinBUGS – Interpreting Summary Statistics

•Check start and sample columns – 10,000 to 30,000•Rename your parameters•Assess accuracy of posterior estimates by calculating Monte Carlo error for each parameter:

•Rule of thumb: MC error should be < 5% of sample standard deviation•Exponentiate median log odds to odds ratios

Page 12: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Now Introducing our Practice Dataset

Page 13: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Advantage of Bayesian analysis in ITC/ MTC is that it allows calculation of the probability of which treatment is best

http://www.mrc-bsu.cam.ac.uk/bugs/ orLunn, Thomas, Best, Speigelhalter. Stat Comput 2000;10:325-37

Page 14: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Outcome Measures• How is your outcome of interest

measured?– Binary (e.g. dead or alive)– Continuous (e.g blood pressure)– Categorical/ordinal (e.g. severity

scale)• Binary outcomes most common

– We will consider here• Continuous

– Similar approach to binary• Ordinal

– More complex and more rare

Page 15: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Binary Outcome Measures

• Binary outcome data from a comparative study can be expressed in a 2 x 2 table

• Three common outcome measures:– Odds ratios, risk ratios, risk

differences

Failure/Dead Success/Alive

New Treatment A B

Control C D

RCT

Page 16: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Fixed Effects Model

• Statistical homogeneity• Formally assume:

Yi = Normal(d,Vi)

• We estimate the commontrue effect, d

True effect=d

Point estimate=Yi

Random error=Vi

Page 17: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Generic Fixed Effect• Yi ~ Normal(d,Vi) where i= 1…….N

studies

• Yi is the observed effect in study i with Variance Vi

• All studies assumed to be measuring the same underlying effect size, d

• For a Bayesian analysis, a prior distribution must be specified for d

Page 18: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Choice of Prior for d

• Often, amount of information in studies is large enough to render any prior of little importance – therefore choice not critical

• Often specified as “vague” or “flat”• E.g. If meta-analysis is on ln(OR)

scale, could specify d~Normal (0, 105)

• This states a priori we would be 95% certain that true value of d is between [0±1.96( 105)]

Page 19: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Fixed Effect with Prior• Yi ~ Normal(d,Vi) where i=

1…….N studies• d ~ Normal(0, 105)• Models are specified in WinBUGS

using formulas similar to this algebra

• Note: Normal distributions are specified by mean and ‘precision’– where precision = 1/variance

• Estimate model parameter using MCMC, rather than inverse weighting of variance

Page 20: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Example: Meta-analysis, RCTs of effect of aspirin preventing death after acute MIsStudy Aspirin Group Placebo Group

Deaths Total Deaths Total

MRC-1 49 615 67 624

CDP 44 758 64 771

MRC-2 102 832 126 850

GASP 32 317 38 309

PARIS 85 810 52 406

AMIS 246 2267 219 2257

ISIS-2 1570 8587 1720 8600

Fleiss. Statistical Methods in Medical Research 1993

Page 21: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Example: Calculation: Log(OR) & Variance

• For MCR-1

• OR=(566*67)/ (557*49) = 1.389• Log(ln)OR = 0.3289• VariancelnOR = 1/566 + 1/49 + 1/557 +

1/67 = 0.0389• Note- this is OR for Survival• If 2x2 table contains any zeros,

common to add 0.5 to those cells before calculations

Survive Die

Aspirin 566 49

Placebo 557 67

Page 22: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Example: Aspirin Data to be Combined

Study OR LnOR (Yi) Var(lnOR) (Vi) Weight (1/Vi)

MRC-1 1.39 0.33 0.04 25.71

CDP 1.47 0.39 0.04 24.29

MRC-2 1.25 0.22 0.02 48.77

GASP 1.25 0.22 0.06 15.44

PARIS 1.25 0.23 0.02 28.41

AMIS 0.88 -0.12 0.01 103.92

ISIS-2 1.12 0.11 0.002 664.26

Note: ISIS-2 with small variance and large weight (1/0.002)

Page 23: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Now It’s Your Turn: Practice using WinBUGS!

Page 24: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Launch WinBUGS

• Click on WinBUGS14.exe• Click File-Open• Load aspirin FE.odc

Page 25: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Components of WinBUGS .odc file

Model {< Likelihood><Prior distributions>

}#Data<List or column format>#Starting Values<List or mixture of list and column

format>

Page 26: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Steps for Running a Model in WinBUGS

1. Make model active. • Doodles:

• If in own window, click title bar.• If in compound document, double-click the doodle (should have “hairy”

border).• Text: Simply highlight the word “model” at the beginning of your model.

2. Bring up Model Specification Tool (menu: Model -> Specification)3. Click “check model”

• Should see “model is syntactically correct” in lower left corner of window.

4. Highlight first row of data containing variable labels (if in rectangular format)

5. Click “load data”• Should see “data is loaded” in lower left corner of window.

6. If using multiple chains, enter number in “num of chains” box. Otherwise, proceed.

7. Click “compile”• Should see “model is compiled” in lower left corner of window.

8. Highlight line containing initial values: list(…)9. Click “load inits”

• If using multiple chains, you will need to repeat steps 8-9 for each chain.

• Should see “model is initialized.”10. Bring up Sample Monitor Tool (menu: Inference -> Samples)

• Enter name of each node you wish to monitor and click “set”11. Bring up Update Tool (menu: Model -> Update)12. Enter a number of samples to take and click “update.”

• Should see “model is updating.”

Page 27: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm
Page 28: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Load and Check Model

Page 29: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Load and Check Data

Page 30: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Compile ModelCompile

Model

Page 31: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Load Initials

Page 32: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm
Page 33: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Pooled OR: median 1.12 (1.05 to 1.19)

Page 34: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm
Page 35: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Random Effects Model• Model

– Within studies• Yi ~Normal(i,Vi)

– Across studies• I ~Normal(d,2)

• d=solid line• =dotted lines• 2 = variability between studies• (heterogeneity)

True Mean Effect=d solid line

Trial-specific effects=dotted lines

Y5

5

Vi

Page 36: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Generic Random Effect

• Yi ~ Normal(,Vi) where i= 1…….N studies

• i~ Normal(d, 2 )• As for fixed effect, Yi is observed effect in

study i with variance Vi

• Now study specific effects, I are allowed to be different from each other and are assumed to be sampled from a Normal distribution with mean d and variance 2

• For a Bayesian analysis, a prior distribution is required for 2 as well as for d

Page 37: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Choice of Prior for 2 • This is a little trickier than for d• Variances cannot be negative so

Normal distribution is not a good choice

• Examples in WinBUGS Manual use Uniform distribution. E.g. ~ Uniform (0,10)

• of 10 is massive, because we are working with ORs; even of 1 or 2 is large

• Specification of vague priors on variance components is complex and is an active area of research

Page 38: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Generic Random Effects Model• Load aspirin RE.odc

Page 39: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm
Page 40: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm
Page 41: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Results of Aspirin RE model

• Pooled OR: median 1.149 (0.976-1.434)– OR now contains 1

• Bayesian CrI wider than classical CI– 2 is random variable and uncertainty

is included in pooled result

Page 42: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Compare our Two Odds Ratios and CrIs

• Fixed effects Normal Distribution– OR=1.12 (95% CrI: 1.05, 1.19)

• Random Effects Normal Distribution – OR=1.15 (95% CrI: 0.97, 1.44)

Page 43: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

MCMC Basics

• Now that we’ve run a few models consider sensitivity analyses

• Sensitivity to prior distributions – esp. important for distributions of

variance/precision parameters• Sensitivity to initial values

– Multiple chains using very different starting values & comparing using Brooks Gelman-Rubin Statistics

• Length of “burn in”: examine history/trace plots

Page 44: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Interpreting Random Effects• A single parameter cannot

adequately summarize heterogeneous effects

• Therefore estimation and reporting of 2 is important

• This tells us how much variability there is between estimates from the population of studies

• In some instances studies contain both beneficial and harmful effects, so important!

Page 45: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

Looking to the Future (The Future is Here!)

Data Sources

RCT1 RCT2 Obs 1 Routine Care

Meta-Analysis

General Synthesis

Bayes Theorem Combination

Evidence Synthesis

Clinical Effects

AdverseEffects Utility Costs

Model Inputs (w/ uncertainty)

DecisionModel

Utility

Utility

Utility

Utility

Utility

Utility

Utility Cost

Cost

Cost

Cost

Cost

Cost

Cost

Tx A Fib

Warfarin

NoWarfarin

No Strk

Stroke

Stroke

No Strk

Bleed

NoBld

Bleed

NoBld

NoBld

NoBld

Bleed

Bleed

Utility

Cost

Page 46: Introduction to Bayesian Statistical Software: WinBUGS 1.4.3 Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm

[email protected]@uw.edu

Attribution for Fleiss example to Keith Abrams, University of Leicester, UK