STAT 113 Independent vs. Paired Samples Colin Reimer Dawson - - PowerPoint PPT Presentation

stat 113 independent vs paired samples
SMART_READER_LITE
LIVE PREVIEW

STAT 113 Independent vs. Paired Samples Colin Reimer Dawson - - PowerPoint PPT Presentation

STAT 113 Independent vs. Paired Samples Colin Reimer Dawson Oberlin College November 16, 2015 Summary: Comparing Two Means Properties of Differences Between Sample Statistics Difference Between Means of Two Independent Groups Inference About


slide-1
SLIDE 1

STAT 113 Independent vs. Paired Samples

Colin Reimer Dawson

Oberlin College

November 16, 2015

slide-2
SLIDE 2

Summary: Comparing Two Means Properties of Differences Between Sample Statistics Difference Between Means of Two Independent Groups Inference About the Mean of Paired Differences

slide-3
SLIDE 3

Cases to Address

We will need standard errors to do CIs and tests for the following parameters:

  • 1. Single Proportion
  • 2. Single Mean
  • 3. Difference of Proportions
  • 4. Difference of Means (last Friday)
  • 5. Mean of Differences (last Friday / today)
slide-4
SLIDE 4

Variance and Standard Error of Differences

◮ The variance of a difference is the sum of the separate

variances, due to having two sources of randomness: s2

ˆ pA−ˆ pB = s2 ˆ pA + s2 ˆ pB

slide-5
SLIDE 5

Standard Error of Difference of Proportions

So the variance of the difference between two sample proportions is s2

ˆ pA−ˆ pB = pA(1 − pA)

nA + pB(1 − pB) nB and the standard deviation (i.e., standard error) of the difference is sˆ

pA−ˆ pB =

  • pA(1 − pA)

nA + pB(1 − pB) nB

slide-6
SLIDE 6

Standard Error of Difference of Means

The exact same reasoning applies to the standard error of a difference between means of two independent samples: s2

¯ xA−¯ xB = σ2 A

nA + σ2

B

nB and the standard deviation (i.e., standard error) of the difference is s¯

xA−¯ xB =

  • σ2

A

nA + σ2

B

nB

slide-7
SLIDE 7

Distribution of Difference of Sample Means

◮ The statistic ¯

xA − ¯ xB is Normal for large enough samples (n ≥ 27ish) and/or when the populations are Normal.

◮ We saw before that

xA−¯ xB =

  • σ2

A

nA + σ2

B

nB

◮ But, as with one mean, we do not know σ2 A or σ2

  • B. So,

substitute s2

A and s2 B. ◮ But, then the distribution is not Normal; it is t. ◮ Conservatively: use d

f = min(nA − 1, nB − 1) (does not assume equal variances).

slide-8
SLIDE 8

Confidence Interval for a Difference of Means

CI Summary: Difference of Means

To compute a confidence interval for a difference of two means when the sampling distribution for ¯ xA − ¯ xB is approximately T-distributed (i.e., Normal populations and/or large sample), use ¯ xA − ¯ xB ± T ∗ ·

  • s2

A

nA + s2

B

nB where T ∗ is the T-statistic of the endpoint appropriate for the confidence level, computed from a t-distribution with min(nA − 1, nB − 1) degrees of freedom.

slide-9
SLIDE 9

P-values for a difference of two means

Computing P-values when the null sampling distribution is approximately Normal (Normal populations and/or large samples) is the reverse process:

  • 1. Convert ¯

xA − ¯ xB to a t-statistic within the theoretical null sampling distribution (i.e., using its mean and standard deviation). Tobserved = ¯ xA − ¯ xB − (µA − µB)0

  • s2

A

nA + s2

B

nB

  • 2. Find the relevant area beyond Tobserved using a

t-distribution with min(nA − 1, nB − 1) degrees of freedom.

slide-10
SLIDE 10

Example: Credit Card Use and Tip Percentage

Credit Cards and Tip Percentage

We analyze the percent tip left on 157 bills from the First Crush Bistro in Northern New York State. The mean percent tip left

  • n the 106 bills paid in cash was 16.39 with a standard

deviation of 5.05. The mean percent tip left on the 51 bills paid with a credit card was 17.10 with a standard deviation of 2.47. ncard = 51 ncash = 106 ¯ xcard = 17.10 ¯ xcash = 16.39 s2

card = 2.472 = 6.10

s2

cash = 5.052 = 25.50

¯ xcard − ¯ xcash = 17.10 − 16.39 = 0.71

slide-11
SLIDE 11

Card Vs. Cash Confidence Interval

Is the Normal approximation reasonable? Yes, the sample sizes are well above 27 CI : point estimate ± T ∗ · SE SE =

  • s2

A

nA + s2

B

nB =

  • 6.10

51 + 25.50 106 = 0.60 T ∗ = ±2.68 (0.005 and 0.995 q-tiles from t50 dist.) Find a 99% CI for µcard − µcash. 0.71 ± 2.68 · 0.60 = (−0.898, 2.318)

slide-12
SLIDE 12

Do people who pay differently tip differently?

Tobserved = observed difference − null difference standard error SE =

  • s2

A

nA + s2

B

nB SE = 0.60 (same as before) Tobserved = 0.70 − 0 0.60 = 1.17 P-value = 0.25 (two-tailed area beyond 1.17 in t50) Decision? Fail to reject H0 : µcard − µcash = 0

slide-13
SLIDE 13

R Code: Key Data

require(mosaic) ## We are given the means and standard deviations, but could compute them ## from a hypothetical dataset: # n.card <- nrow(filter(TippingNY, PaymentMethod == "card")) # n.cash <- nrow(filter(TippingNY, PaymentMethod == "cash")) # xbar.card <- # mean(~PaymentMethod, data = filter(TippingNY, PaymentMethod == "card")) # xbar.cash <- # mean(~PaymentMethod, data = filter(TippingNY, PaymentMethod == "cash")) # s.card <- # sd(~PaymentMethod, data = filter(TippingNY, PaymentMethod == "card")) # s.cash <- # sd(~PaymentMethod, data = filter(TippingNY, PaymentMethod == "cash")) n.card <- 51; n.cash <- 106 xbar.card <- 17.10; xbar.cash <- 16.39 s.card <- 2.47; s.cash <- 5.05

slide-14
SLIDE 14

R Code: Confidence Interval

## Compute the standard error se.diff <- sqrt(s.card^2 / n.card + s.cash^2 / n.cash) ## compute critical t-values (tstar.99 <- xqt(c(0.005, 0.995), df = min(n.card - 1, n.cash - 1)))

density

0.1 0.2 0.3 0.4 0.5 −3 −2 −1 1 2 3

. 5 . 9 9 . 5

[1] -2.677793 2.677793 ## compute the confidence interval (CI.99 <- (xbar.card - xbar.cash) + tstar.99 * se.diff) [1] -0.8971559 2.3171559

slide-15
SLIDE 15

R Code: Hypothesis Test

## We already have the standard error, but here it is again se.diff <- sqrt(s.card^2 / n.card + s.cash^2 / n.cash) ## compute T.observed (slightly different without any rounding) (T.observed <- ((xbar.card - xbar.cash) - 0) / se.diff) [1] 1.18298 ## compute the two-tailed P-value (slightly different without rounding) (P.value <- 2 * xpt(abs(T.observed), df = min(n.card - 1, n.cash - 1), lower.tail = FALSE))

density

0.1 0.2 0.3 0.4 0.5 −3 −2 −1 1 2 3

. 1 2 1 . 8 7 9

[1] 0.2424117

slide-16
SLIDE 16

Independent Groups Vs. Paired Samples Design

◮ Independent Groups: Randomly assign cases to groups (or

get two separate groups, as in observational study)

◮ Random Assignment → Remove systematic differences

between groups

◮ However, still have chance differences between groups. ◮ Chance differences are a source of variability that we need

to account for in CIs and tests.

◮ Paired Samples: Each observation in group A has a

matched (presumably relatively similar) observation in group B

◮ Removes some of the chance differences between the groups ◮ Results in sample differences closer (on average) to any

systematic difference due to the grouping

◮ Narrower CIs ◮ Easier to reject H0 (one less competing “chance”

explanation of a difference)

slide-17
SLIDE 17

Kinds of Paired Samples Designs

  • 1. Repeated Measures Design: Have each case produce an
  • bservation in each group.
  • 2. Matched Pairs Design: Observations come from different

sources (e.g., people), but cases are selected to be similar in key ways (e.g., identical twins that share genetics; or pairs matched by gender, race, age, etc.)

  • 3. Pairing By Time: Alternate cases between groups so that

pairs were collected close in time (e.g., b/c you think time

  • f day / week / year / etc. is a source of variability)
slide-18
SLIDE 18

From Two Samples to One Sample

◮ In a paired samples design, can convert from two sets of

  • riginal response variable to a single set of difference scores.

Then

◮ Parameter of interest: µD, population mean difference score ◮ Null hypothesis: H0 : µD = 0 ◮ Alternative hypothesis H1 : µD = 0 (or > 0 or < 0) ◮ CI: A ≤ µD ≤ B with C% confidence

◮ Reduces to one sample inference for a mean: Sampling

distribution is t, with nD − 1 df (nD is the number of pairs), provided (a) nD large, and/or (b) population of differences is approx. Normal