Teaching Simulation -Based Inference

48
Dr. Kari Lock Morgan Department of Statistics Penn State University Teaching Simulation-Based Inference Washington Statistical Society 4/1/16

Transcript of Teaching Simulation -Based Inference

Page 1: Teaching Simulation -Based Inference

Dr. Kari Lock MorganDepartment of StatisticsPenn State University

Teaching Simulation-Based Inference

Washington Statistical Society4/1/16

Page 2: Teaching Simulation -Based Inference

Central Limit Theorem� Xj independent random variables with

mean μj and variance σj2.

� Liapunov’s Central Limit Theorem:

If ∃𝛿 > 0 such that ∑ & |()|*+,

∑ -)*.

)/0

*+,*

1234 → 0,

then ∑ ()67).)/0

∑ -)*.

)/0

8→N(0,1).

APRILFOOL’S!

Page 3: Teaching Simulation -Based Inference

Use data from a sample survey to estimate a population mean or proportion; develop a margin of

error through the use of simulation methods for random sampling

Use data from a randomized experiment to compare two

treatments; use simulation to decide if differences between

parameters are significant

Page 4: Teaching Simulation -Based Inference

Question #1

Whatistheaveragemercuryleveloffish(LargeMouthBass)inFloridalakes?

Page 5: Teaching Simulation -Based Inference

Mercury Levels in Fish

!!n=53!!x =0.527!ppm

Lange, T.,Royals,H.andConnor,L.(2004). Mercuryaccumulation inlargemouthbass(Micropterus salmoides)inaFloridaLake.ArchivesofEnvironmentalContaminationandToxicology,27(4), 466-471.

!µ = ???

Page 6: Teaching Simulation -Based Inference

Mercury in Fish� The sample mean is 0.527 ppm

� In the US, the FDA action level is 1 ppm¡ Is this safely below the US limit?

� In Canada, the safety limit is 0.5 ppm¡ Is this clearly above the Canadian limit?

� We need a margin of error…

Page 7: Teaching Simulation -Based Inference

Getting a Margin of Error

Population Sample

Sample

Sample

SampleSampleSample

...

Calculatestatisticforeachsample

SamplingDistribution

StandardError(SE):standarddeviationofsamplingdistribution

MarginofError(ME)(95%CI:ME=2×SE)

statistic±ME

Page 8: Teaching Simulation -Based Inference

• Key idea: how much do statistics vary from sample to sample?• Wouldn’t it be nice if we could take lots of samples and directly see the variability?!?• Problem?

• We can’t take lots of samples from the population!

Assessing Uncertainty

Page 9: Teaching Simulation -Based Inference

Getting a Margin of ErrorPopulation

(???)

statistic±ME

Sample

BestGuessatPopulation

Sample

Sample

Sample

SampleSampleSample

...

Distributionofthestatistic

Calculatestatisticforeachsample

StandardError(SE):standarddeviationofthestatistic

MarginofError(ME)(95%CI:ME=2×SE)

Page 10: Teaching Simulation -Based Inference

Simulating Samples� What is our best guess at the population,

given sample data?¡The sample itself!

� Draw samples repeatedly from the sample data (of size n = 53)…¡… with replacement!

� This is known as bootstrapping¡Simulate many bootstrap samples¡Calculate statistic for each¡Find SE as standard deviation of these statistics

Page 11: Teaching Simulation -Based Inference

1. Bootstrap Sample: Sample with replacement from the original sample, using the same sample size.

Original Sample Bootstrap Sample

Remember: sample size matters!

2. Calculate statistic 3. Repeat…

Page 12: Teaching Simulation -Based Inference

We need technology!

StatKeywww.lock5stat.com/statkey

¡ Free¡ Easy to use¡ Online (or offline as chrome app)

Page 13: Teaching Simulation -Based Inference

SE=0.047

statistic±2xSE0.527± 2x0.047(0.433,0.621)

MercuryLevelsinFish

Weare95%confidentthataveragemercurylevelinfishinFloridalakesisbetween0.433and0.621ppm.

Page 14: Teaching Simulation -Based Inference

Same process for every parameter!Estimatethemarginoferrorand/oraconfidenceintervalfor...• proportion(𝑝)• differenceinmeans(µ1 − µ2)• differenceinproportions(𝑝1 − 𝑝2)• standarddeviation(𝜎)• correlation(𝜌)• ... Generatesampleswithreplacement

CalculatesamplestatisticRepeat...

Page 15: Teaching Simulation -Based Inference

MercuryandpHinLakes

Lange,Royals,andConnor,TransactionsoftheAmericanFisheriesSociety(1993)

• ForFloridalakes,whatisthecorrelationbetweenaveragemercurylevel(ppm)infishtakenfromalakeandacidity(pH)ofthelake?

Givea95%CIforρ

r =-0.575

Page 16: Teaching Simulation -Based Inference

Mercury and pH in Lakes

r =-0.575-0.575± 2× 0.085(-0.745,-0.405)

Weare95%confidentthatthetruecorrelationbetweenmercuryandpHlevelinFloridalakesisbetween-0.745and-0.405.

Page 17: Teaching Simulation -Based Inference

Bootstrap Interval: Summary� Sample with replacement from data

� Calculate statistic

� Repeat many times

� SE = standard deviation of statistics

� Margin of error = 2 x SE

� Interval: statistic ± 2 x SE

Page 18: Teaching Simulation -Based Inference

Use data from a sample survey to estimate a population mean or proportion; develop a margin of

error through the use of simulation methods for random sampling

Use data from a randomized experiment to compare two

treatments; use simulation to decide if differences between

parameters are significant

Page 19: Teaching Simulation -Based Inference

Question #2

Doesdrinkingteaboostyourimmunesystem?

Page 20: Teaching Simulation -Based Inference

Tea and Immune Response

Antigensintea-BeveragePrimeHumanVγ2Vδ2TCellsinvitroandinvivoforMemoryandNon-memoryAntibacterialCytokineResponses,Kamath et.al.,ProceedingsoftheNationalAcademyofSciences,May13,2003.

• Participants were randomized to drink five or six cups of either tea (black) or coffee every day for two weeks (both drinks have caffeine but only tea has L-theanine)

• After two weeks, blood samples were exposed to an antigen, and production of interferon gamma (immune system response) was measured

• Explanatory variable: tea or coffee • Response variable: measure of interferon gamma

Page 21: Teaching Simulation -Based Inference

Tea and Immune System

�̅�G − �̅�H = 34.82 − 17.70 = 17.12

Page 22: Teaching Simulation -Based Inference

1. Checkconditions

2. Computestatistic:chooseformula,plugandchug

3. Usetheoreticaldistribution(whichone?df?)

4. 0.025<p-value<0.05

Getting the p-value: Option 1

𝑡 =𝑥4 − 𝑥P

𝑠4P𝑛4+ 𝑠PP𝑛P

= 2.07

𝑛4 = 11𝑛P = 10

Page 23: Teaching Simulation -Based Inference

p-value: The chance of obtaining a statistic as extreme as that observed, just by random chance, if the null hypothesis is true

Say What???We need a better way…

Page 24: Teaching Simulation -Based Inference

Actual ExperimentR R R R R

R R R R R

R R R R RR R R R R

Tea Coffee

R R RR R R R R

R R R

R R R R R

R

R

Page 25: Teaching Simulation -Based Inference

Actual Experiment

R R RR R R R R

R R R

R R R R R

R R R R13 18 205 1152 55 5647 48 R58

3 11 150 0

21 38 5216 21

Tea Coffee

Page 26: Teaching Simulation -Based Inference

Actual Experiment

R R RR R R R R

R R R

R R R R R

R R R R13 18 205 1152 55 5647 48 R58

3 11 150 0

21 38 5216 21

Tea Coffee

!!xT − xC =17.12

� Twoplausibleexplanations:¡Teaboostsimmunity

¡Randomchance Whatmighthappenjustbyrandomchance???

Page 27: Teaching Simulation -Based Inference

R R RR R R R R

R R R

R R R R R

R R R R13 18 205 1152 55 5647 48 R58

3 11 150 0

21 38 5216 21

Tea Coffee

R R RR R R R RR R 13 18 205 11

52 55 5647 48 R58

R R R

R R R R R

R R 3 11 150 0

21 38 5216 21

Simulation

Page 28: Teaching Simulation -Based Inference

Simulation

R R RR R R R R

R R R

R R R R R15 16 21

18 20 4721 13 R55

38 52 5

52 56 5811 48

Tea Coffee

R R RR R R R RR R 13 18 205 11

52 55 5647 48 R58

R

R R R R R

3 11 150 0

21 38 5216 21

Page 29: Teaching Simulation -Based Inference

Simulation

R R RR R R R R

R R R

R R R R R15 16 21

18 20 4721 13 R55

38 52 5

52 56 5811 48

Tea Coffee

0 3 R R0 11

!!xT − xC = −12.3

RepeatManyTimes!

Data

Page 30: Teaching Simulation -Based Inference

p-valueProportionasextremeasobservedstatistic

observedstatistic

RandomizationTest

DistributionofstatisticifH0 true

If there were no difference between tea and coffee regarding immune system response, we would see results this extreme about 2.6% of the time

Page 31: Teaching Simulation -Based Inference

p-value: The chance of obtaining a statistic as extreme as that observed, just by random chance, if the null hypothesis is true

Page 32: Teaching Simulation -Based Inference

• Simulate as if the null hypothesis were true

• Calculate the statistic of interest

• Repeat

• p-value = proportion of these simulated statistics that are as extreme as your observed statistic

• Same procedure for every parameter!

Randomization Test

Page 33: Teaching Simulation -Based Inference

Question #3

Doeshormonereplacementtherapycauseincreasedrisk

ofbreastcancer?

Page 34: Teaching Simulation -Based Inference

Hormone Replacement Therapy� Until 2002, hormone replacement therapy (HRT) was

commonly prescribed to post-menopausal women. This changed in 2002, when the results of a large clinical trial were published

� 8506 women were randomized to take HRT, 8102 were randomized to placebo. 166 HRT and 124 placebo women developed invasive breast cancer

� Does hormone replacement therapy cause increased risk of breast cancer?

� How unlikely would this be, just by random chance, if there were no difference between HRT and placebo regarding invasive breast cancer?

Page 35: Teaching Simulation -Based Inference

HRT and Invasive Breast Cancer

� If there were no difference between HRT and placebo regarding invasive breast cancer, we would only see results this extreme 2 out of 100 times.

� We have evidence that HRT increases risk of invasive breast cancer.

Page 36: Teaching Simulation -Based Inference

Hormone Replacement Therapy� Same trial, different variable of interest.� 8506 women were randomized to take HRT,

8102 were randomized to placebo. 502 HRT and 458 placebo women developed any kind of cancer.

� Does hormone replacement therapy cause increased risk of cancer in general?

� How unlikely would this be, just by random chance, if there were no difference between HRT and placebo regarding cancer?

Page 37: Teaching Simulation -Based Inference

HRT and All Cancer

� If there were no difference between HRT and placebo regarding cancer, we would see results this extreme about 24 out of 100 times, or about a quarter of the time.

� We do not have evidence that HRT increases risk of cancer in general.

Page 38: Teaching Simulation -Based Inference

Use data from a sample survey to estimate a population mean or proportion; develop a margin of

error through the use of simulation methods for random sampling

Use data from a randomized experiment to compare two

treatments; use simulation to decide if differences between

parameters are significant

Page 39: Teaching Simulation -Based Inference

Malevolent Uniforms

SampleCorrelation=0.43

Doteamswithmoremalevolentuniformscommit/getmorepenalties,oristherelationshipjustduetorandomchance?

Page 40: Teaching Simulation -Based Inference

Good Technology Options� StatKey: lock5stat.com/statkey� Rossman/Chance: rossmanchance.com/applets� InZight: stat.auckland.ac.nz/~wild/iNZight� R: cran.r-project.org� RStudio: rstudio.com� Fathom: fathom.concord.org� Tinkerplots: tinkerplots.com� JMP: jmp.com� StatCrunch: statcrunch.com

Red = Free

Page 41: Teaching Simulation -Based Inference

Simulation Methods• Intrinsically connected to concepts

• Minimal background knowledge needed

• More visual, less mathematical

• Same procedure applies to all statistics

• More generalizable

• Fewer conditions; conditions transparent

Page 42: Teaching Simulation -Based Inference

Fall '14 Spring '15 Fall '15

2040

6080

100

Pos

t Tes

t Sco

re

Scores on a National Assessment

Averages:

p-value:0.00002

43% 60% 63%National:47%

Page 43: Teaching Simulation -Based Inference

National Assessment ResultsMost improvement on p-value questions!

T-test Simulation National

Abletoreasonthatasmallerp-valueprovidesstrongerevidenceagainstthenullhypothesisthanalargerp-value.

29%

Abletoreasonaboutaconclusionbasedonastatisticallysignificantp-valueinthecontextofaresearchstudythatcomparestwogroups.

43%

45%

48%

68%

80%

Page 44: Teaching Simulation -Based Inference

Student Behavior• Studentsweregivendataonthesecondmidtermandaskedtocomputeaconfidenceintervalforthemean

• Howtheycreatedtheinterval:

Bootstrapping t.test inR Formula

94 9 984% 8% 8%

Page 45: Teaching Simulation -Based Inference

Itisthewayofthepast…

"Actually,thestatisticiandoesnotcarryoutthisverysimpleandverytediousprocess[therandomizationtest],buthisconclusionshavenojustificationbeyondthefactthattheyagreewiththosewhichcouldhavebeenarrivedatbythiselementarymethod."

-- SirR.A.Fisher,1936

Page 46: Teaching Simulation -Based Inference

…andthewayofthefuture“...theconsensuscurriculumisstillanunwittingprisonerofhistory.Whatweteachislargelythetechnicalmachineryofnumericalapproximationsbasedonthenormaldistributionanditsmanysubsidiarycogs.Thismachinerywasoncenecessary,becausetheconceptuallysimpleralternativebasedonpermutationswascomputationallybeyondourreach.Beforecomputersstatisticianshadnochoice.Thesedayswehavenoexcuse.Randomization-basedinferencemakesadirectconnectionbetweendataproductionandthelogicofinferencethatdeservestobeatthecoreofeveryintroductorycourse.”

-- ProfessorGeorgeCobb,2007

Page 47: Teaching Simulation -Based Inference

Want More?� Sessions, panel, and discussion on teaching

with simulation-based inference during the Electronic Conference on Teaching Statistics (eCOTS), May 16 – 20th, 2016: causeweb.org/cause/ecots/ecots16

� Contact me ([email protected]) if interested in a potential NSF-sponsored experience for high school teachers

� Simulation-based inference blog: causeweb.org/sbi