Steply

Comparing two groups

University Statistics · 21 problems, easy to harder

▶ Watch the first one solved

How we do it

  1. Write the hypotheses
  2. The two parts
  3. Pool the groups
  4. Standard error
  5. The test number
  6. The p-value
  7. Decide
  8. Say it in words
  9. Check

The steps for Test p1 > p2: 45 of 100 and 30 of 100, alpha 0.05. Every solution names its steps, so you always know what comes next.

Worked examples

Test p1 > p2: 45 of 100 and 30 of 100, alpha 0.05 Easy

The question

Question: in group 1, 45 of 100 say yes, and in group 2, 30 of 100: at the 5% level, is the first proportion more than the second?

p1 > p2? 45 of 100, 30 of 100, α = 0.05

1 Write the hypotheses

H₀ is the "nothing new" idea: it has the equal sign.

Here: the two proportions are the same, so the difference is 0.

H0 : p1 = p2

Hₐ is what we want to show.

Here: the first proportion is more than the second.

Ha : p1 > p2

More than: one tail, the right end.

one tail: the right end

2 The two parts

Group 1: 45/100 is 0.45.

p′1 = 45100 = 0.45

Group 2: 30/100 is 0.3.

p′2 = 30100 = 0.3

3 Pool the groups

If H zero is true, the two groups are the same.

So we put them together: the pooled proportion.

if H0 is true, the groups are the same: put them together

All the yeses over everyone: 75/200 is 0.375.

pc = 45 + 30100 + 100 = 75200 = 0.375

Careful!

We pool the counts, not the two proportions.

Careful: pool the counts: (x₁ + x₂) ÷ (n₁ + n₂)

And q c is 1 minus 0.375: 0.625.

qc = 1 − 0.375 = 0.625

4 Standard error

The standard error, the SD of the difference: the square root of p c times q c, times 1/n 1 plus 1/n 2.

SE = √pc × qc × (1n1 + 1n2)

0.375 times 0.625 is 0.2344.

1/100 plus 1/100 is 0.02.

Multiply, then the square root: about 0.0685.

SE = √0.375 × 0.625 × (1100 + 1100) ≈ 0.0685

5 The test number

z is the difference over the SE.

0.45 minus 0.3 is 0.15.

Divided by 0.0685: about 2.19.

z = p′1 − p′2SE = 0.45 − 0.30.0685 ≈ 2.19

6 The p-value

The p-value is the chance of getting a sample this far out, if H zero is true.

p-value: the chance of a sample this far out, if H0 is true

On the bell of H zero: 0 in the middle, our sample at z = 2.19.

We shade the right end, from our z up.

The z-table gives the area to the left of z.

Row 2.1, column .09.

For z = 2.19: the row 2.1 and the column .09 meet at 0.9857.

The right end is 1 minus 0.9857: 0.0143.

p-value = 1 − 0.9857 = 0.0143

7 Decide

The p-value, 0.0143, is less than alpha, 0.05.

Our sample would be rare if H zero were true.

So we reject H zero.

= p-value 0.0143 < α = 0.05 → reject H0

8 Say it in words

At the 5% level, there is enough evidence that

In words: at the 5% level, there is enough evidence that the first proportion is more than the second.

the first proportion is more than the second.

9 Check

Let's check the other way, with the cut-off.

0.05 in the right end gives the cut-off 1.645.

0.05 in one end: cut-off 1.645

z is 2.19: past the cut-off.

The same decision.

So it is right!

z = 2.19 > 1.645: past the cut-off, reject

Let's look back.

First: write the hypotheses.

Then: the two parts.

Then: pool the groups.

Then: standard error.

Then: the test number.

Then: the p-value.

Then: decide.

Then: say it in words.

Last: check.

Answer
= p-value 0.0143 < α = 0.05 → reject H0

▶ Watch it solved

Test p1 != p2: 120 of 200 and 100 of 200, alpha 0.05 Medium

The question

Question: in group 1, 120 of 200 say yes, and in group 2, 100 of 200: at the 5% level, is the first proportion different from the second?

p1 ≠ p2? 120 of 200, 100 of 200, α = 0.05

1 Write the hypotheses

H₀ is the "nothing new" idea: it has the equal sign.

Here: the two proportions are the same, so the difference is 0.

H0 : p1 = p2

Hₐ is what we want to show.

Here: the first proportion is different from the second.

Ha : p1 ≠ p2

Different from: two tails.

two tails

2 The two parts

Group 1: 120/200 is 0.6.

p′1 = 120200 = 0.6

Group 2: 100/200 is 0.5.

p′2 = 100200 = 0.5

3 Pool the groups

If H zero is true, the two groups are the same.

So we put them together: the pooled proportion.

if H0 is true, the groups are the same: put them together

All the yeses over everyone: 220/400 is 0.55.

pc = 120 + 100200 + 200 = 220400 = 0.55

Careful!

We pool the counts, not the two proportions.

Careful: pool the counts: (x₁ + x₂) ÷ (n₁ + n₂)

And q c is 1 minus 0.55: 0.45.

qc = 1 − 0.55 = 0.45

4 Standard error

The standard error, the SD of the difference: the square root of p c times q c, times 1/n 1 plus 1/n 2.

SE = √pc × qc × (1n1 + 1n2)

0.55 times 0.45 is 0.2475.

1/200 plus 1/200 is 0.01.

Multiply, then the square root: about 0.0498.

SE = √0.55 × 0.45 × (1200 + 1200) ≈ 0.0498

5 The test number

z is the difference over the SE.

0.6 minus 0.5 is 0.1.

Divided by 0.0498: about 2.01.

z = p′1 − p′2SE = 0.6 − 0.50.0498 ≈ 2.01

6 The p-value

The p-value is the chance of getting a sample this far out, if H zero is true.

p-value: the chance of a sample this far out, if H0 is true

On the bell of H zero: 0 in the middle, our sample at z = 2.01.

Two tails: we shade both ends, as far out as our sample or more.

The z-table gives the area to the left of z.

Row 2.0, column .01.

For z = 2.01: the row 2.0 and the column .01 meet at 0.9778.

One end is 1 minus 0.9778: 0.0222.

Two ends: 2 times that is 0.0444.

p-value = 2 × (1 − 0.9778) = 2 × 0.0222 = 0.0444

7 Decide

The p-value, 0.0444, is less than alpha, 0.05.

Our sample would be rare if H zero were true.

So we reject H zero.

= p-value 0.0444 < α = 0.05 → reject H0

8 Say it in words

At the 5% level, there is enough evidence that

In words: at the 5% level, there is enough evidence that the first proportion is different from the second.

the first proportion is different from the second.

9 Check

Let's check the other way, with the cut-off.

0.05 split into two ends gives the cut-offs plus and minus 1.96.

0.05 in two ends: cut-offs ±1.96

z is 2.01: past the cut-off.

The same decision.

So it is right!

z = |2.01| > 1.96: past the cut-off, reject

Let's look back.

First: write the hypotheses.

Then: the two parts.

Then: pool the groups.

Then: standard error.

Then: the test number.

Then: the p-value.

Then: decide.

Then: say it in words.

Last: check.

Answer
= p-value 0.0444 < α = 0.05 → reject H0

▶ Watch it solved

Test p1 != p2: 256 of 400 and 216 of 400, alpha 0.01 Harder

The question

Question: in group 1, 256 of 400 say yes, and in group 2, 216 of 400: at the 1% level, is the first proportion different from the second?

p1 ≠ p2? 256 of 400, 216 of 400, α = 0.01

1 Write the hypotheses

H₀ is the "nothing new" idea: it has the equal sign.

Here: the two proportions are the same, so the difference is 0.

H0 : p1 = p2

Hₐ is what we want to show.

Here: the first proportion is different from the second.

Ha : p1 ≠ p2

Different from: two tails.

two tails

2 The two parts

Group 1: 256/400 is 0.64.

p′1 = 256400 = 0.64

Group 2: 216/400 is 0.54.

p′2 = 216400 = 0.54

3 Pool the groups

If H zero is true, the two groups are the same.

So we put them together: the pooled proportion.

if H0 is true, the groups are the same: put them together

All the yeses over everyone: 472/800 is 0.59.

pc = 256 + 216400 + 400 = 472800 = 0.59

Careful!

We pool the counts, not the two proportions.

Careful: pool the counts: (x₁ + x₂) ÷ (n₁ + n₂)

And q c is 1 minus 0.59: 0.41.

qc = 1 − 0.59 = 0.41

4 Standard error

The standard error, the SD of the difference: the square root of p c times q c, times 1/n 1 plus 1/n 2.

SE = √pc × qc × (1n1 + 1n2)

0.59 times 0.41 is 0.2419.

1/400 plus 1/400 is 0.005.

Multiply, then the square root: about 0.0348.

SE = √0.59 × 0.41 × (1400 + 1400) ≈ 0.0348

5 The test number

z is the difference over the SE.

0.64 minus 0.54 is 0.1.

Divided by 0.0348: about 2.88.

z = p′1 − p′2SE = 0.64 − 0.540.0348 ≈ 2.88

6 The p-value

The p-value is the chance of getting a sample this far out, if H zero is true.

p-value: the chance of a sample this far out, if H0 is true

On the bell of H zero: 0 in the middle, our sample at z = 2.88.

Two tails: we shade both ends, as far out as our sample or more.

The z-table gives the area to the left of z.

Row 2.8, column .08.

For z = 2.88: the row 2.8 and the column .08 meet at 0.9980.

One end is 1 minus 0.9980: 0.0020.

Two ends: 2 times that is 0.0040.

p-value = 2 × (1 − 0.9980) = 2 × 0.0020 = 0.0040

7 Decide

The p-value, 0.0040, is less than alpha, 0.01.

Our sample would be rare if H zero were true.

So we reject H zero.

= p-value 0.0040 < α = 0.01 → reject H0

8 Say it in words

At the 1% level, there is enough evidence that

In words: at the 1% level, there is enough evidence that the first proportion is different from the second.

the first proportion is different from the second.

9 Check

Let's check the other way, with the cut-off.

0.01 split into two ends gives the cut-offs plus and minus 2.576.

0.01 in two ends: cut-offs ±2.576

z is 2.88: past the cut-off.

The same decision.

So it is right!

z = |2.88| > 2.576: past the cut-off, reject

Let's look back.

First: write the hypotheses.

Then: the two parts.

Then: pool the groups.

Then: standard error.

Then: the test number.

Then: the p-value.

Then: decide.

Then: say it in words.

Last: check.

Answer
= p-value 0.0040 < α = 0.01 → reject H0

▶ Watch it solved

Practice

Try each one, then open the answer. Stuck? Open the problem to watch every step.

Easy

  1. test p1 > p2: 45 of 100 and 30 of 100, alpha 0.05
    Answer
    = p-value 0.0143 < α = 0.05 → reject H0
  2. test p1 < p2: 30 of 150 and 45 of 150, alpha 0.05
    Answer
    = p-value 0.0228 < α = 0.05 → reject H0
  3. test mean1 > mean2: mean 52, sd 6, n 36 and mean 49, sd 8, n 64, alpha 0.05
    Answer
    = p-value 0.0170 < α = 0.05 → reject H0
  4. test mean1 < mean2: mean 70, sd 10, n 25 and mean 75, sd 10, n 25, alpha 0.05
    Answer
    = p-value 0.0384 < α = 0.05 → reject H0
  5. test p1 > p2: 60 of 200 and 50 of 200, alpha 0.05
    Answer
    = p-value 0.1314 > α = 0.05 → do not reject H0
  6. test mean1 > mean2: mean 34, sd 4, n 16 and mean 32, sd 3, n 9, alpha 0.05
    Answer
    = p-value 0.0793 > α = 0.05 → do not reject H0
  7. test p1 > p2: 70 of 200 and 50 of 200, alpha 0.05
    Answer
    = p-value 0.0146 < α = 0.05 → reject H0

Medium

  1. test p1 != p2: 120 of 200 and 100 of 200, alpha 0.05
    Answer
    = p-value 0.0444 < α = 0.05 → reject H0
  2. test mean1 != mean2: mean 81, sd 12, n 36 and mean 76, sd 9, n 36, alpha 0.05
    Answer
    = p-value 0.0456 < α = 0.05 → reject H0
  3. test p1 > p2: 90 of 300 and 60 of 300, alpha 0.01
    Answer
    = p-value 0.0023 < α = 0.01 → reject H0
  4. test mean1 > mean2: mean 5.2, sd 1.2, n 36 and mean 4.8, sd 0.8, n 64, alpha 0.05
    Answer
    = p-value 0.0367 < α = 0.05 → reject H0
  5. test p1 < p2: 18 of 120 and 30 of 120, alpha 0.05
    Answer
    = p-value 0.0262 < α = 0.05 → reject H0
  6. test mean1 < mean2: mean 120, sd 20, n 100 and mean 126, sd 15, n 100, alpha 0.01
    Answer
    = p-value 0.0082 < α = 0.01 → reject H0
  7. test p1 != p2: 45 of 150 and 60 of 150, alpha 0.10
    Answer
    = p-value 0.0688 < α = 0.1 → reject H0

Harder

  1. test p1 != p2: 256 of 400 and 216 of 400, alpha 0.01
    Answer
    = p-value 0.0040 < α = 0.01 → reject H0
  2. test mean1 != mean2: mean 16.2, sd 3, n 50 and mean 15, sd 4, n 40, alpha 0.05
    Answer
    = p-value 0.1142 > α = 0.05 → do not reject H0
  3. test p1 > p2: 58 of 160 and 40 of 140, alpha 0.05
    Answer
    = p-value 0.0793 > α = 0.05 → do not reject H0
  4. test mean1 > mean2: mean 68.5, sd 3, n 30 and mean 67, sd 2.5, n 35, alpha 0.05
    Answer
    = p-value 0.0150 < α = 0.05 → reject H0
  5. test p1 < p2: 41 of 250 and 63 of 260, alpha 0.05
    Answer
    = p-value 0.0143 < α = 0.05 → reject H0
  6. test mean1 != mean2: mean 102, sd 15, n 25 and mean 95, sd 12, n 36, alpha 0.05
    Answer
    = p-value 0.0524 > α = 0.05 → do not reject H0
  7. test mean1 < mean2: mean 7.4, sd 2, n 64 and mean 8, sd 2.4, n 36, alpha 0.05
    Answer
    = p-value 0.1020 > α = 0.05 → do not reject H0