129
Inference Chapter 10

Inference Chapter 10 - VUMC

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Inference Chapter 10 - VUMC

InferenceChapter 10

Page 2: Inference Chapter 10 - VUMC

What is a population?

Page 3: Inference Chapter 10 - VUMC

What is a population?

A population is the complete set of patients (or subjects or observations) that we hope to learn about.

Examples: Mother-infant pairs, patients with a previous hernia repair, black or white patients on dialysis

Page 4: Inference Chapter 10 - VUMC

Why not collect data from an entire population?

Page 5: Inference Chapter 10 - VUMC

Why not collect data from an entire population?

• $$$$• Impossible

Page 6: Inference Chapter 10 - VUMC

In order to learn about a population, we collect data on a subset of the population. The subset is a sample.

Selecting and collecting data from a subset of the population is sampling.

Page 7: Inference Chapter 10 - VUMC

A few ways one may sample a population+ Random sample+ Systematic sample+ Stratified sample+ Convenience sample

Page 8: Inference Chapter 10 - VUMC

Remember:Before one can sample, one must clearly define the population.

Page 9: Inference Chapter 10 - VUMC

What is the consequence of collecting data from a subset instead of collecting data from the full population?

Page 10: Inference Chapter 10 - VUMC

What is the consequence of collecting data from a subset instead of collecting data from the full population?

Sampling error or estimation error or variation or uncertainty or loss of precision

Page 11: Inference Chapter 10 - VUMC

Embrace uncertainty

Communicate the degree of uncertainty with conclusions drawn from samples.

Examples: confidence intervals, probabilities, interquartile range

Page 12: Inference Chapter 10 - VUMC

How do we learn from a sample?

Page 13: Inference Chapter 10 - VUMC

Population and Sample

A parameter is a numerical measurement that describes a characteristic

of a population

A statistic is a numerical measurement that describes a characteristic of

a sample

In general, we will use a statistic to infer something about a parameter

Page 14: Inference Chapter 10 - VUMC

Population and Sample

Page 15: Inference Chapter 10 - VUMC

Population and Sample

Page 16: Inference Chapter 10 - VUMC

Population and Sample

Page 17: Inference Chapter 10 - VUMC

Population and Sample

Page 18: Inference Chapter 10 - VUMC

Population and Sample

Page 19: Inference Chapter 10 - VUMC

Population and Sample

• Previously in the NHANES study, we computed summary statistics such as sample means and variances or sample proportions to describe our sample.

• Now, not only do we want to describe the sample, we want to learn something about the population.

• Learn about population = inference about population

Page 20: Inference Chapter 10 - VUMC

Population and Sample

• What might we learn about a population?

▫ Population mean (μ): Average value assumed by a random variable, also called the expected value.

▫ Population variance (σ2): Variability of the random variable. May also use Population standard deviation (σ).

▫ Other population parameters: median, 25th- or 75th-quantile

Page 21: Inference Chapter 10 - VUMC

Statistical InferenceStatistical inference consists of:

• Estimation: Use sample to estimate population parameter(s) of interest.

▫ Proportion of low birthweight infants.

• Hypothesis testing: Use sample to evaluate population parameter(s).

▫ For now, we will concentrate on estimation.

Page 22: Inference Chapter 10 - VUMC

Statistical Inference

• Estimation consists of point estimates and interval estimates:

▫ Point estimate: A “best guess” of the population parameter based on the sample.

Page 23: Inference Chapter 10 - VUMC

MeanY

Best guess for the mean

Page 24: Inference Chapter 10 - VUMC

Statistical Inference

• Estimation consists of point estimates and interval estimates:

▫ Point estimate: A “best guess” of the population parameter based on the sample.

▫ Interval estimate: A range of “reasonable values”, accounting for sampling variability of the point estimate.

• IMPORTANT: The sample must be representative of the population of interest.

Page 25: Inference Chapter 10 - VUMC

Y

Range of reasonable values for the mean

Page 26: Inference Chapter 10 - VUMC

Example:

Inadvertent enterotomy (IE) occurs during abdominal repair

(like hernia repairs) when an incision is unintentionally made in

the intestine.

Page 27: Inference Chapter 10 - VUMC

Example (cont):

Suppose: In a cohort of 3000 laparoscopic ventral hernia repairs, there were 120 IE. Among 2000 open ventral hernia repairs, there were 40 IE.

What is the estimated proportion (and 95% CI) in each group?

What is the difference in IE proportions (and 95% CI) between laparoscopic and open?

Page 28: Inference Chapter 10 - VUMC

So what?Why does one care about the

difference in proportions and 95% CI?

Page 29: Inference Chapter 10 - VUMC

Confidence Intervals &Inference about the PopulationA confidence interval is a type of inference about the larger population. The interval represents the set of population parameters supported by the data.

Page 30: Inference Chapter 10 - VUMC

by CI

Page 31: Inference Chapter 10 - VUMC

Inference by CI - population mean

Example: What is the mean birthweight (and 95% CI) of infants

for mothers that do not smoke, calculated from the Bayside

hospital data?

Page 32: Inference Chapter 10 - VUMC

Inference by CI - population mean

Example (cont):

bwt 115 3054.957 70.1625 2915.965 3193.948 Variable Obs Mean Std. Err. [95% Conf. Interval]

. ci means bwt if smoke == 0

Page 33: Inference Chapter 10 - VUMC

Inference by CI - population proportion

Example: What is the proportion and 95% CI of mothers that

smoke? (Respond on Top Hat.)

Page 34: Inference Chapter 10 - VUMC

Inference by CI - population proportion

Example (cont):

smoke 189 .3915344 .0355036 .324772 .4626181 Variable Obs Proportion Std. Err. [95% Conf. Interval] Wilson

. ci proportions smoke, wilson

Page 35: Inference Chapter 10 - VUMC

Inference by CI – population rate

Example: What is the rate of death and 95% CI in the placebo

population in the Primary Biliary Cirrhosis Trial (liver.dta)?

Page 36: Inference Chapter 10 - VUMC

Inference by CI – population rate

Example (cont):

status 3.06523 19.57439 2.527043 14.93732 25.19612 Variable Exposure Mean Std. Err. [95% Conf. Interval] Poisson Exact

. ci means status if tx == 0, poisson exposure(ot100k)

. gen ot100k = obstime /100000

. use liver.dta

Page 37: Inference Chapter 10 - VUMC

Inference by CI – difference in population means

Example: Difference and CI of mean birthweight between

mothers do and do not smoke (lowbwt.dta).

Page 38: Inference Chapter 10 - VUMC

Inference by CI – difference in population means

Example (cont):

diff 281.7133 103.9741 76.46677 486.9598 combined 189 2944.656 53.02858 729.0224 2840.049 3049.264 smoker 74 2773.243 76.73218 660.0752 2620.316 2926.17nonsmoke 115 3054.957 70.1625 752.409 2915.965 3193.948 Group Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] Two-sample t test with unequal variances

. ttest bwt, by(smoke) unequal

Page 39: Inference Chapter 10 - VUMC

Inference by CI – difference in population proportions

See example of inadvertent enterotomy above.

Page 40: Inference Chapter 10 - VUMC

One can also make inference about the population with hypothesis

testingThere is a connection with confidence intervals.

Page 41: Inference Chapter 10 - VUMC

Generally, studies are designed to identify

Conclusive differences

Conclusive similarities

or

Page 42: Inference Chapter 10 - VUMC

Because of noise or error, a study may also generate

Conclusive differences

Conclusive similarities

or

Inconclusive results

or

Page 43: Inference Chapter 10 - VUMC

To discover conclusive similarities

• A study will a priori establish an equivalence threshold.

Page 44: Inference Chapter 10 - VUMC

To discover conclusive similarities

• A study will a priori establish an equivalence threshold.

Other related terms:• Null region• Region of practical

equivalence

Page 45: Inference Chapter 10 - VUMC

To discover conclusive similarities

• A conclusive similarity is identified when the confidence

interval for the difference falls within the equivalence

threshold.

Page 46: Inference Chapter 10 - VUMC

To discover conclusive differences

• A conclusive difference is identified when the confidence

interval for the difference falls outside the equivalence

threshold.

Page 47: Inference Chapter 10 - VUMC

An inconclusive result

• An inconclusive result occurs when the confidence interval

for the difference straddles the equivalence threshold.

Page 48: Inference Chapter 10 - VUMC

Same framework applies to ratios

Conclusive diff

Conclusive similarityInconclusive

Page 49: Inference Chapter 10 - VUMC

Example

Suppose surgeons establish that the rate of surgical site

infections is equivalent for robotic and laparoscopic hernia

repair.

Page 50: Inference Chapter 10 - VUMC

Example

Suppose surgeons establish that the rate of surgical site infections is equivalent for robotic and laparoscopic hernia repair. The surgeons decide on a 2.5 percentage point difference as threshold.

Page 51: Inference Chapter 10 - VUMC

Example

Suppose surgeons establish that the rate of surgical site infections is equivalent for robotic and laparoscopic hernia repair. The surgeons decide on a 2.5 percentage point difference as threshold.

Page 52: Inference Chapter 10 - VUMC

Example

If 89 in a cohort of 1000 laparoscopic repairs and 97 in a cohort

of 1000 robotic repairs experience an infection, then …

Page 53: Inference Chapter 10 - VUMC

Example

If 89 in a cohort of 1000 laparoscopic repairs and 97 in a cohort

of 1000 robotic repairs experience an infection, then …

Page 54: Inference Chapter 10 - VUMC

Example

If 89 in a cohort of 1000 laparoscopic repairs and 97 in a cohort

of 1000 robotic repairs experience an infection, then …

Inconclusive-1.7 3.3

Page 55: Inference Chapter 10 - VUMC

Example

However, if 892 in a cohort of 10000 laparoscopic repairs and 967 in a cohort of 10000 robotic repairs experience an infection, then …

Page 56: Inference Chapter 10 - VUMC

Example

However, if 892 in a cohort of 10000 laparoscopic repairs and

967 in a cohort of 10000 robotic repairs experience an

infection, then …

Conclusive similarity-0.0 1.6

Page 57: Inference Chapter 10 - VUMC

It is common to have a point null instead of a null region

Page 58: Inference Chapter 10 - VUMC

It is common to have a point null instead of a null region

Conclusive differenceInconclusive

Page 59: Inference Chapter 10 - VUMC

It is common to have a point null instead of a null region

Conclusive differenceInconclusive

Notice that there is no possibility of identifying a conclusive similarity.

Page 60: Inference Chapter 10 - VUMC

A common mistake is to interpret an inconclusive result as evidence for a conclusive similarity.

Inconclusive

You might see in a manuscript: The rates of adverse events were the same in the intervention and placebo groups.

Page 61: Inference Chapter 10 - VUMC

You might see in a manuscript: The rates of adverse events were the same in the intervention and placebo groups.

Why can this be misleading?• There usually is no threshold for equivalence• The statement is usually based on a point null• Fails to communicate the degree of differences supported by the data

A common mistake is to interpret an inconclusive result as evidence for a conclusive similarity.

Page 62: Inference Chapter 10 - VUMC

You might see in a manuscript: The rates of adverse events were the same in the intervention and placebo groups.

Why can this be misleading?• There usually is no threshold for equivalence• The statement is usually based on a point null• Fails to communicate the degree of differences supported by the data

Better practice: Use the CI to communicate the degree of uncertainty.

A common mistake is to interpret an inconclusive result as evidence for a conclusive similarity.

Page 63: Inference Chapter 10 - VUMC

Hypothesis Testing, formalized

• DEFINITIONS:

▫ Hypothesis: A statement about a population parameter. Example: mean

bilirubin.

▫ Null Hypothesis (H0): The default claim.

Example: mean bilirubin = 3.

▫ Alternative Hypothesis (H1): The competing claim.

Example: mean bilirubin > 3 (one-sided)

Example: mean bilirubin < 3 (one-sided)

Example: mean bilirubin ≠ 3 (double-sided or two-sided)

Page 64: Inference Chapter 10 - VUMC

Hypothesis Testing, formalized

• DEFINITIONS:

▫ Hypothesis: A statement about a population parameter. Example: mean

bilirubin.

▫ Null Hypothesis (H0): The default claim.

Example: mean bilirubin = 3.

▫ Alternative Hypothesis (H1): The competing claim.

Example: mean bilirubin > 3 (one-sided)

Example: mean bilirubin < 3 (one-sided)

Example: mean bilirubin ≠ 3 (double-sided or two-sided)

Page 65: Inference Chapter 10 - VUMC

Hypothesis Testing

• DEFINITIONS:

▫ Hypothesis: A statement about a population parameter. Example: mean

bilirubin.

▫ Null Hypothesis (H0): The default claim.

Example: mean bilirubin = 2.

▫ Alternative Hypothesis (H1): The competing claim.

Example: mean bilirubin > 3 (one-sided)

Example: mean bilirubin < 3 (one-sided)

Example: mean bilirubin ≠ 3 (double-sided or two-sided)

Page 66: Inference Chapter 10 - VUMC

Hypothesis Testing

• DEFINITIONS:

▫ Hypothesis: A statement about a population parameter. Example: mean

bilirubin.

▫ Null Hypothesis (H0): The default claim.

Example: mean bilirubin = 2.

▫ Alternative Hypothesis (H1): The competing claim.

Example: mean bilirubin > 2 (one-sided)

Example: mean bilirubin < 2 (one-sided)

Example: mean bilirubin ≠ 2 (double-sided or two-sided)

Page 67: Inference Chapter 10 - VUMC

Hypothesis Testing

• DEFINITIONS:

▫ Hypothesis: A statement about a population parameter. Example: mean

bilirubin.

▫ Null Hypothesis (H0): The default claim.

Example: mean bilirubin = 2.

▫ Alternative Hypothesis (H1): The competing claim.

Example: mean bilirubin > 2 (one-sided)

Example: mean bilirubin < 2 (one-sided)

Example: mean bilirubin ≠ 2 (double-sided or two-sided)

Only interested in detecting differences in one direction

Page 68: Inference Chapter 10 - VUMC

mean bilirubin > 2 (one-sided)

Ignored Only care about differences greater than 2

Page 69: Inference Chapter 10 - VUMC

mean bilirubin < 2 (one-sided)

Ignored Only care about differences less than 2

Page 70: Inference Chapter 10 - VUMC

mean bilirubin ≠ 2 (two-sided)The usual setup

Care to detect mean differences in any direction.

Page 71: Inference Chapter 10 - VUMC

In general, for two-sided test with point null H0: mean = 2 H1: mean ≠ 2

Conclusive difference

You will see the phrase “rejected the null” when a conclusive difference is identified.

Page 72: Inference Chapter 10 - VUMC

In general, for two-sided test with point null H0: mean = 2 H1: mean ≠ 2

Conclusive difference

You will see the phrase “rejected the null” when a conclusive difference is identified.

In my opinion, it is more straightforward to write: “detected a difference in …”

Page 73: Inference Chapter 10 - VUMC

Hypothesis Testing

ONE-SIDED OR TWO-SIDED HYPOTHESIS TESTS

Remember, if there is a point null: One cannot identify conclusive

similarities. Therefore, one does not “accept the null” nor

“declare it to be true”.

Page 74: Inference Chapter 10 - VUMC

One can perform an hypothesis test using a confidence interval.

Page 75: Inference Chapter 10 - VUMC

How to perform an hypothesis test with point null via CI

• Compute a 1-α confidence interval for the parameter of

interest

Is the null hypothesis in the

CI?

Yes

No

Fail to reject H0

Reject H0

(Inconclusive result)

(Conclusive difference)

Page 76: Inference Chapter 10 - VUMC

We saw this earlier … now updated with hypothesis testing vocab.

Reject H0 (Conclusive difference)Fail to reject H0 (Inconclusive result)

Page 77: Inference Chapter 10 - VUMC

Hypothesis Testing via CI

Example: Low Birthweight Study

Suppose there is a concern that birth weights of infants among mothers

who smoked during pregnancy may be below the national average.

Suppose the national average is 3100g, and we will consider it a

population mean.

data(birthwt, package = "MASS")

Page 78: Inference Chapter 10 - VUMC

Hypothesis Testing via CI

Example (cont):

To assess our study question, we will express our test hypotheses as:

Among smoking mothers,

H0: mean birthweight = 3100g

H1: mean birthweight ≠ 3100g.

Page 79: Inference Chapter 10 - VUMC

Hypothesis Testing vi CI

Example (side note):

Why is H1 ≠ 3100g instead of < 3100g? Even though our concern is low

birthweight infants, if smoking mothers are having babies that are

much heavier than the national average, there may be some other

unrealized problem.

Page 80: Inference Chapter 10 - VUMC

Hypothesis testing via CI

Example (cont):

Calculate the 95% CI:

birthwt %>% filter(smoke == 1) %>% select(bwt) %>% t.test

Page 81: Inference Chapter 10 - VUMC

Hypothesis testing via CI

What does one conclude from the CI?

Example (cont):

Calculate the 95% CI:...95 percent confidence interval: 2619.094 2924.744...

Page 82: Inference Chapter 10 - VUMC

How to perform an hypothesis test via CI

Example (cont):

Is the null hyp (3100g) in the CI?

Yes

No

Fail to reject H0

Reject H095% CI: (2619, 2925)

Page 83: Inference Chapter 10 - VUMC

How to perform an hypothesis test via CI

Example (cont):

Is the null hyp (3100g) in the CI?

Yes

No

Fail to reject H0

Reject H095% CI: (2620, 2926)

Page 84: Inference Chapter 10 - VUMC

Could our inference be wrong?(Yes)

Page 85: Inference Chapter 10 - VUMC

Hypothesis TestingThe ways we can be wrongThe ways we can be right

H0 true H0 false

Reject H0 Type I Error (α) Correct

Do not reject H0 Correct Type II Error (β)

Page 86: Inference Chapter 10 - VUMC

Hypothesis TestingThe ways we can be wrongThe ways we can be right

H0 truemean birthweight = 3100g

H0 falsemean birthweight ≠ 3100g

Reject H0 Type I Error (α) Correct

Do not reject H0 Correct Type II Error (β)

In the context of the low birthweight study:

Page 87: Inference Chapter 10 - VUMC

Hypothesis TestingThe ways we can be wrongThe ways we can be right

Example: Type I Error

A type I error is made if conclude mean birthweight ≠ 3100g

(the alt hypothesis) when, in fact, the mean birthweight =

3100g (the null hypothesis).

Page 88: Inference Chapter 10 - VUMC

Hypothesis test via CI

• The hypothesis test by (1-α)% CI has a type I error rate of α.

Page 89: Inference Chapter 10 - VUMC

Hypothesis TestingThe ways we can be wrongThe ways we can be right

Example: Type II Error

A type II error is made if we fail to reject the null hypothesis

that mean birthweight = 3100g when in fact the mean

birthweight ≠ 3100g (alternative hypothesis).

Page 90: Inference Chapter 10 - VUMC

Notation

• α = Probability of a Type I Error

• β = Probability of a Type II Error

• 1 - β = Power

Page 91: Inference Chapter 10 - VUMC

Hypothesis test via CI

Proportion

Page 92: Inference Chapter 10 - VUMC

Hypothesis test via CIProportion

Example:

Suppose that the proportion of pregnant mothers that smoke in

the US is known to be 15%. Is the proportion of mothers that

smoke in the low birthweight study different than the national

proportion?

Page 93: Inference Chapter 10 - VUMC

Hypothesis test via CIProportion

Example (cont):

1. Write the null and alternative hypotheses.

Page 94: Inference Chapter 10 - VUMC

Hypothesis test via CIProportion

Example (cont):

1. Write the null and alternative hypotheses.

H0: p = .15

H1: p ≠ .15

Page 95: Inference Chapter 10 - VUMC

Hypothesis test via CIProportion

Example (cont):

1. Write the null and alternative hypotheses.

2. Calculate the CI.

Page 96: Inference Chapter 10 - VUMC

Hypothesis test via CIProportion

Example (cont):

1. Write the null and alternative hypotheses.

2. Calculate the CI.

birthwt %>% pull(smoke) %>% table %>% rev %>% prop.test

Page 97: Inference Chapter 10 - VUMC

Hypothesis test via CIProportion

Example (cont):

1. Write the null and alternative hypotheses.

2. Calculate the CI.

3. Perform the hypothesis test. (What do you conclude?)

Page 98: Inference Chapter 10 - VUMC

Hypothesis test via CI

Rate

Page 99: Inference Chapter 10 - VUMC

Hypothesis test via CIRate

Example: Is the rate incidence rate of death the same in the

treatment arm the same as placebo in the Primary Biliary

Cirrhosis Trial?

data(pbc, package = "survival")

Page 100: Inference Chapter 10 - VUMC

Hypothesis test via CIRate

Example (cont):

1. Write the hypothesis in terms of the incidence rate ratio

(IRR).

Page 101: Inference Chapter 10 - VUMC

Hypothesis test via CIRate

Example (cont):

1. Write the hypothesis in terms of the incidence rate ratio (IRR).

H0: IRR = 1

H1: IRR ≠ 1

Page 102: Inference Chapter 10 - VUMC

Hypothesis test via CIRate

Example (cont):

1. Write the hypothesis in terms of the incidence rate ratio

(IRR).

2. Using the 95% CI, perform the hypothesis test.

Page 103: Inference Chapter 10 - VUMC

Hypothesis test via CIRate

pbc %>% filter(trt %in% 1:2) %>% mutate(death = 1*(status == 2)) %>% group_by(trt) %>% summarize( obstime = sum(time/365.25/10) , events = sum(death) )poisson.test(c(65, 60), c(87.2, 84.2))

Page 104: Inference Chapter 10 - VUMC

What other CI can you calculate for the purposes of performing an hypothesis test?Difference in population means, Difference in proportions, etc

Page 105: Inference Chapter 10 - VUMC

One-Sided Hypothesis Tests

The confidence interval methods works for one-sided

hypotheses. One simply calculates a one-sided confidence

interval.

Page 106: Inference Chapter 10 - VUMC

One-Sided Hypothesis Tests

Example: Low Birthweight Study

Consider the one-sided hypothesis test for birthweight from smoking

mothers:

H0: mean birthweight ≥ 3100g

H1: mean birthweight < 3100g

Page 107: Inference Chapter 10 - VUMC

One-Sided Hypothesis Tests

Example: Low Birthweight Study

Is the null region in the CI?

birthwt %>% filter(smoke == 1) %>% select(bwt) %>% t.test(alternative = "less")

Page 108: Inference Chapter 10 - VUMC

One-Sided Hypothesis Tests

Words of Warning about One-Sided Tests:

• The choice between a one-sided and a two-sided test can be

controversial.

• A one-sided test can sometimes achieve significance when a two-

sided test does not.

• Studies designed under a one-sided setting have more power (or

need fewer subjects) than the two-sided counterpart (will discuss

this in greater detail later).

Page 109: Inference Chapter 10 - VUMC

One-Sided Hypothesis Tests

• There are few studies based on one-sided hypotheses in the

medical literature.

• If you do encounter one, read it with a very critical eye.

Page 110: Inference Chapter 10 - VUMC

Hypothesis testing via the p-value method(Warning: p-values can be highly addictive. Use sparingly and with caution.)

Page 111: Inference Chapter 10 - VUMC

A heuristic approach to p-values

Recall the following hypothesis from the Low Birthweight

Study:

Among smoking mothers,

H0: mean birthweight = 3100g

H1: mean birthweight ≠ 3100g.

Page 112: Inference Chapter 10 - VUMC

A heuristic approach to p-valuesConfidence Interval α level of hypothesis test

The 95% CI: (2620, 2926)The 99% CI: (2570, 2976)The 99.9% CI: (2510, 3036)The 99.99% CI: (2408, 3137)

.05

.010.0010.00001

Page 113: Inference Chapter 10 - VUMC

0.05

0.001

0.00001

0.01

Page 114: Inference Chapter 10 - VUMC

0.05

0.001

0.00001

0.01

At what α level does the

confidence interval tip

from “reject the null” to

“fail to reject the null”?

Page 115: Inference Chapter 10 - VUMC

A heuristic approach to p-values

The p-value is the tipping-point α.

Page 116: Inference Chapter 10 - VUMC

0.05

0.001

0.00001

0.01

(1 – pvalue)% CI

fail to reject

reject

Page 117: Inference Chapter 10 - VUMC

Why is knowing the tipping point helpful?

Page 118: Inference Chapter 10 - VUMC

Why is knowing the tipping point helpful?It indicates the maximum confidence level for which one would reject the null.

Page 119: Inference Chapter 10 - VUMC

A heuristic approach to p-values

Another example:

Recall the low birthweight study and the hypothesis regarding the

proportion of mothers that smoke during pregnancy. Suppose

H0: proportion = 0.3

H1: proportion ≠ 0.3

Page 120: Inference Chapter 10 - VUMC

A heuristic approach to p-values

Another example (cont):

One might perform the 0.05 level test by calculating a 95%

confidence interval.

Or, one might calculate the p-value.

Page 121: Inference Chapter 10 - VUMC

> birthwt %>% pull(smoke) %>% table %>% rev %>% prop.test(p = 0.3)

1-sample proportions test with continuity correction

data: ., null probability 0.3X-squared = 7.1111, df = 1, p-value = 0.007661alternative hypothesis: true p is not equal to 0.395 percent confidence interval: 0.3222615 0.4652911sample estimates: p 0.3915344

A heuristic approach to p-values

Another example (cont):

Page 122: Inference Chapter 10 - VUMC

A heuristic approach to p-values

Another example (cont):

What will be the bound for the (1-0.007661)% CI?

Page 123: Inference Chapter 10 - VUMC

A heuristic approach to p-values

Another example (cont):

Null hypothesis value

> birthwt %>% pull(smoke) %>% table %>% rev %>% prop.test(conf.level = 1-0.007661)

1-sample proportions test with continuity correction

data: ., null probability 0.5X-squared = 8.4656, df = 1, p-value = 0.003619alternative hypothesis: true p is not equal to 0.599.2339 percent confidence interval: 0.3000003 0.4911500sample estimates: p 0.3915344

Page 124: Inference Chapter 10 - VUMC

Calculating p-values in R

• The same commands we used to generate confidence

intervals for differences in means, proportions, and rates will

be the same commands that generate p-values for hypothesis

tests.

Page 125: Inference Chapter 10 - VUMC

Family-wise error rates

Page 126: Inference Chapter 10 - VUMC

Family-wise error rates

● Rather than thinking about single hypothesis test, consider a group of hypotheses.– The family-wise type I error rate is the probability of making at

least one type I error within the group of tests.

Page 127: Inference Chapter 10 - VUMC

Family-wise error rates

● Thought experiement (10.16.1 in text)– Say we have 250 pennies, and we wish to determine whether any

are unbalanced, i.e., have probability p of heads different from 0.5.

– Study design: (a) flip each coin 100 times.(b) perform hypothesis test with data from coin flips

– Question: What is the family-wise type I error rate?

Page 128: Inference Chapter 10 - VUMC

R <- 5000pennies <- 250flips <- 100l30g60 <- function(x){x < 40 | x > 60}

fwe <- rep(NA, R)for(i in 1:R){ data <- rbinom(pennies, flips, 0.5) type1errors <- l30g60(data) fwe[i] <- sum(type1errors) > 0 }

mean(fwe)

Page 129: Inference Chapter 10 - VUMC