Inference for Distributions Marc H. Mehlman marcmehlman@yahoo.com - - PowerPoint PPT Presentation

inference for distributions
SMART_READER_LITE
LIVE PREVIEW

Inference for Distributions Marc H. Mehlman marcmehlman@yahoo.com - - PowerPoint PPT Presentation

Inference for Distributions Marc H. Mehlman marcmehlman@yahoo.com University of New Haven Based on Rare Event Rule: rare events happen but not to me. Marc Mehlman Marc Mehlman (University of New Haven) Inference for Distributions 1


slide-1
SLIDE 1

Marc Mehlman

Inference for Distributions

Marc H. Mehlman

marcmehlman@yahoo.com

University of New Haven

Based on Rare Event Rule: “rare events happen – but not to me”.

Marc Mehlman (University of New Haven) Inference for Distributions 1 / 42

slide-2
SLIDE 2

Marc Mehlman

Table of Contents

1

t Distribution

2

CI for µ: σ unknown

3

t-test: Mean (σ unknown)

4

t test: Matched Pairs

5

Two Sample z–Test: Means (σX and σY known)

6

Two Sample t–test: Means (σX and σY unknown)

7

Pooled Two Sample t–test: Means (σX = σY unknown)

8

Two Sample F–test: Variance

9

Chapter #8 R Assignment

Marc Mehlman (University of New Haven) Inference for Distributions 2 / 42

slide-3
SLIDE 3

Marc Mehlman

t Distribution

t Distribution

t Distribution.

Marc Mehlman (University of New Haven) Inference for Distributions 3 / 42

slide-4
SLIDE 4

Marc Mehlman

t Distribution

If X1, · · · , Xn is a normal random sample ¯ X ∼ N

  • µ, σ

√n

¯ X − µ σ/√n ∼ N(0, 1). If the random sample is not normal, but n ≥ 30, the above is also true (approximately) by the CLT. However, typically one does not know what σ equals so one is tempted to use s instead of σ. This gives Definition (Student t Distribution) If a random sample is normal or the sample size is ≥ 30 ¯ X − µ S/√n ∼ t(n − 1), where t is the Student t Distribution with n − 1 degrees of freedom.

Marc Mehlman (University of New Haven) Inference for Distributions 4 / 42

slide-5
SLIDE 5

Marc Mehlman

t Distribution

7

When comparing the density curves of the standard Normal distribution and t distributions, several facts are apparent:

 The density curves of the t distributions are similar in shape to the standard Normal curve.  The spread of the t distributions is a bit greater than that of the standard Normal distribution.  The t distributions have more probability in the tails and less in the center than does the standard Normal.  As the degrees of freedom increase, the t density curve approaches the standard Normal curve ever more closely. We can use Table D in the back of the book to determine critical values t* for t distributions with different degrees of freedom.

The t Distributions

Marc Mehlman (University of New Haven) Inference for Distributions 5 / 42

slide-6
SLIDE 6

Marc Mehlman

t Distribution

Robustness

The t procedures are exactly correct when the population is exactly

  • Normal. This is rare.

The t procedures are robust to small deviations from Normality, but:

The sample must be a random sample from the population.

Outliers and skewness strongly influence the mean and therefore the t

  • procedures. Their impact diminishes as the sample size gets larger

because of the Central Limit Theorem.

As a guideline:

When n < 15, the data must be close to Normal and without outliers.

When 15 > n > 40, mild skewness is acceptable, but not outliers.

When n > 40, the t statistic will be valid even with strong skewness. Marc Mehlman (University of New Haven) Inference for Distributions 6 / 42

slide-7
SLIDE 7

Marc Mehlman

CI for µ: σ unknown

CI for µ: σ unknown

Confidence intervals for µ when σ is unknown.

Marc Mehlman (University of New Haven) Inference for Distributions 7 / 42

slide-8
SLIDE 8

Marc Mehlman

CI for µ: σ unknown

Confidence intervals

A confidence interval is a range of values that contains the true population parameter with probability (confidence level) C. We have a set of data from a population with both µ and σ unknown. We use x̅ to estimate µ, and s to estimate σ, using a t distribution (df n − 1). C

t* −t* m m

m=t∗s/√n

 C is the area between −t* and t*.  We find t* in the line of Table.  The margin of error m is:

Marc Mehlman (University of New Haven) Inference for Distributions 8 / 42

slide-9
SLIDE 9

Marc Mehlman

CI for µ: σ unknown

Definition (standard error) The standard error of the sample mean for σ unknown is SE¯

x def

= S √n. Theorem (CI for µ, σ unknown) Assume n ≥ 30 or the population is normal. Let margin of error = m def = t⋆(n − 1) ⋆ s √n = t⋆(n − 1) ⋆ SE¯

x.

Then the confidence interval is ¯ x ± m.

Marc Mehlman (University of New Haven) Inference for Distributions 9 / 42

slide-10
SLIDE 10

Marc Mehlman

CI for µ: σ unknown

Example

The meters of total rainfall for Jupa, Beliana in the first decade of each of the last sixteen centuries is given below: 3.790155 3.628361 3.989105 5.124677 4.227491 3.183561 5.286963 3.323666 4.116425 2.771781 6.243354 5.040272 6.821760 6.170435 5.439190 5.206938 Find a 90% confidence interval for the mean rainfall per first decade of each century. Solution: The following normal quartile plot indicates

  • −2

−1 1 2 3 4 5 6 Normal Q−Q Plot Theoretical Quantiles Sample Quantiles

that the data comes from a normal (or at least almost normal) distribution. Since σ is unknown and the distribution is close to normal with no outliers, R gives us > mean(mdat)-qt(0.95,15)*sd(mdat)/sqrt(16) [1] 4.124238 > mean(mdat)+qt(0.95,15)*sd(mdat)/sqrt(16) [1] 5.171278 Thus a 90% confidence interval is (4.124238, 5.171278). Notice > t.test(mdat,mu=4.5,conf.level=0.90) One Sample t-test data: mdat t = 0.4948, df = 15, p-value = 0.6279 alternative hypothesis: true mean is not equal to 4.5 90 percent confidence interval: 4.124238 5.171278 sample estimates: mean of x 4.647758 Marc Mehlman (University of New Haven) Inference for Distributions 10 / 42

slide-11
SLIDE 11

Marc Mehlman

CI for µ: σ unknown

Example

The meters of total rainfall for Jupa, Beliana in the first decade of each of the last sixteen centuries is given below: 3.790155 3.628361 3.989105 5.124677 4.227491 3.183561 5.286963 3.323666 4.116425 2.771781 6.243354 5.040272 6.821760 6.170435 5.439190 5.206938 Find a 90% confidence interval for the mean rainfall per first decade of each century. Solution: The following normal quartile plot indicates

  • −2

−1 1 2 3 4 5 6 Normal Q−Q Plot Theoretical Quantiles Sample Quantiles

that the data comes from a normal (or at least almost normal) distribution. Since σ is unknown and the distribution is close to normal with no outliers, R gives us > mean(mdat)-qt(0.95,15)*sd(mdat)/sqrt(16) [1] 4.124238 > mean(mdat)+qt(0.95,15)*sd(mdat)/sqrt(16) [1] 5.171278 Thus a 90% confidence interval is (4.124238, 5.171278). Notice > t.test(mdat,mu=4.5,conf.level=0.90) One Sample t-test data: mdat t = 0.4948, df = 15, p-value = 0.6279 alternative hypothesis: true mean is not equal to 4.5 90 percent confidence interval: 4.124238 5.171278 sample estimates: mean of x 4.647758 Marc Mehlman (University of New Haven) Inference for Distributions 10 / 42

slide-12
SLIDE 12

Marc Mehlman

t-test: Mean (σ unknown)

t-test: Mean (σ unknown)

t-test: Mean (σ unknown)

Marc Mehlman (University of New Haven) Inference for Distributions 11 / 42

slide-13
SLIDE 13

Marc Mehlman

t-test: Mean (σ unknown)

Theorem (t–test for the Mean (σ unknown)) Given a random sample, X1, · · · , Xn, where either the random sample was sampled from a normal population or the sample size n ≥ 30, let the test statistic be T = ¯ X − µ0 S/√n . Then T ∼ t(n − 1) under H0 : µ = µ0. The p–value of a test of H0

1 versus H1 : µX > µ0 is P(T ≥ t). 2 versus H2 : µX < µ0 is P(T ≤ t). 3 versus H3 : µX = µ0 is 2P(T ≥ |t|). Marc Mehlman (University of New Haven) Inference for Distributions 12 / 42

slide-14
SLIDE 14

Marc Mehlman

t-test: Mean (σ unknown)

Example

The number of hours of Sesame Street that American 4 year olds watch each year is assumed to distributed normally. Twenty-five 4 year olds are randomly sampled and one finds ¯ x = 125 and s2

X = 100. What is the p–value

for a test of H0 : µX = 120 versus HA : µX > 120? Solution: The population is normally distributed so the test statistic is t = 125 − 120 10/ √ 25 = 2.5 comes from t(24) under H0. Thus the p–value is

> 1-pt(2.5,24) [1] 0.009827088

It seems unlikely that the average number of Sesame Street watching hours is 120 or less. Marc Mehlman (University of New Haven) Inference for Distributions 13 / 42

slide-15
SLIDE 15

Marc Mehlman

t-test: Mean (σ unknown)

Example

The number of hours of Sesame Street that American 4 year olds watch each year is assumed to distributed normally. Twenty-five 4 year olds are randomly sampled and one finds ¯ x = 125 and s2

X = 100. What is the p–value

for a test of H0 : µX = 120 versus HA : µX > 120? Solution: The population is normally distributed so the test statistic is t = 125 − 120 10/ √ 25 = 2.5 comes from t(24) under H0. Thus the p–value is

> 1-pt(2.5,24) [1] 0.009827088

It seems unlikely that the average number of Sesame Street watching hours is 120 or less. Marc Mehlman (University of New Haven) Inference for Distributions 13 / 42

slide-16
SLIDE 16

Marc Mehlman

t-test: Mean (σ unknown)

Example

> set.seed(1234) > ntab=rnorm(99,5,1) > t.test(ntab,mu=4.6) One Sample t-test data: ntab t = 2.2299, df = 98, p-value = 0.02804 alternative hypothesis: true mean is not equal to 4.6 95 percent confidence interval: 4.624239 5.016220 sample estimates: mean of x 4.820229 > t.test(ntab,mu=4.6,alternative="greater") One Sample t-test data: ntab t = 2.2299, df = 98, p-value = 0.01402 alternative hypothesis: true mean is greater than 4.6 95 percent confidence interval: 4.65623 Inf sample estimates: mean of x 4.820229 Marc Mehlman (University of New Haven) Inference for Distributions 14 / 42

slide-17
SLIDE 17

Marc Mehlman

t test: Matched Pairs

t test: Matched Pairs

Matched Pairs

Marc Mehlman (University of New Haven) Inference for Distributions 15 / 42

slide-18
SLIDE 18

Marc Mehlman

t test: Matched Pairs

Matched pairs t procedures

Sometimes we want to compare treatments or conditions at the individual level. The data sets produced this way are not independent. The individuals in one sample are related to those in the other sample.

Pre-test and post-test studies look at data collected on the same sample elements before and after some experiment is performed.

Twin studies often try to sort out the influence of genetic factors by comparing a variable between sets of twins.

Using people matched for age, sex, and education in social studies allows us to cancel out the effect of these potential lurking variables. Marc Mehlman (University of New Haven) Inference for Distributions 16 / 42

slide-19
SLIDE 19

Marc Mehlman

t test: Matched Pairs

Theorem (Matched Pairs) Let (X1, Y1), · · · , (Xn, Yn) be a bivariate random sample and define Dj

def

= Xj − Yj. Assume n ≥ 30, or the Dj’s are normal (or pretty much so). Let H0 : µD = d. The test statistic is T = ¯ D − d sD/√n ∼ t(n − 1) for H0. A (1 − α)100% CI for µD is ¯ d ± t⋆(n − 1) ⋆ sD √n.

Marc Mehlman (University of New Haven) Inference for Distributions 17 / 42

slide-20
SLIDE 20

Marc Mehlman

t test: Matched Pairs

Example (Does lack of caffeine increase depression?)

Randomly selected caffeine-dependent individuals were deprived of all caffeine–rich foods and assigned to receive daily pills. At

  • ne time the pills contained caffeine and, at another time they were a placebo. Depression was assessed quantitatively (higher

scores represent greater depression). Find the p–value of the test H0 : µdiff = 0 versus HA : µdiff ≥ 0 Subject 1 2 3 4 5 6 7 8 9 10 11 Caffeine 5 5 4 3 8 5 2 11 1 Placebo 16 23 5 7 14 24 6 3 15 12 Difference 11 18 1 4 6 19 6 3 13 1

  • 1

Solution: The normal quartile plot to the left indicates

  • −1.5

−1.0 −0.5 0.0 0.5 1.0 1.5 5 10 15 Normal Q−Q Plot Theoretical Quantiles Sample Quantiles

that the data comes from a normal (or at least almost normal) distribution. > cdat=c(5,5,4,3,8,5,0,0,2,11,1) > pdat=c(16,23,5,7,14,24,6,3,15,12,0) > tstat=(mean(pdat-cdat)-0)/(sd(pdat-cdat)/sqrt(11)) > tstat [1] 3.530426 > 1-pt(tstat,10) [1] 0.002721472 It is very likely that caffeine deprivation causes an increase in rates of depression. Marc Mehlman (University of New Haven) Inference for Distributions 18 / 42

slide-21
SLIDE 21

Marc Mehlman

t test: Matched Pairs

Example (Does lack of caffeine increase depression?)

Randomly selected caffeine-dependent individuals were deprived of all caffeine–rich foods and assigned to receive daily pills. At

  • ne time the pills contained caffeine and, at another time they were a placebo. Depression was assessed quantitatively (higher

scores represent greater depression). Find the p–value of the test H0 : µdiff = 0 versus HA : µdiff ≥ 0 Subject 1 2 3 4 5 6 7 8 9 10 11 Caffeine 5 5 4 3 8 5 2 11 1 Placebo 16 23 5 7 14 24 6 3 15 12 Difference 11 18 1 4 6 19 6 3 13 1

  • 1

Solution: The normal quartile plot to the left indicates

  • −1.5

−1.0 −0.5 0.0 0.5 1.0 1.5 5 10 15 Normal Q−Q Plot Theoretical Quantiles Sample Quantiles

that the data comes from a normal (or at least almost normal) distribution. > cdat=c(5,5,4,3,8,5,0,0,2,11,1) > pdat=c(16,23,5,7,14,24,6,3,15,12,0) > tstat=(mean(pdat-cdat)-0)/(sd(pdat-cdat)/sqrt(11)) > tstat [1] 3.530426 > 1-pt(tstat,10) [1] 0.002721472 It is very likely that caffeine deprivation causes an increase in rates of depression. Marc Mehlman (University of New Haven) Inference for Distributions 18 / 42

slide-22
SLIDE 22

Marc Mehlman

t test: Matched Pairs

Example (cont.)

Using R, one can find the p–value two other ways too. > t.test(pdat-cdat,mu=0,alternative="greater") One Sample t-test data: pdat - cdat t = 3.5304, df = 10, p-value = 0.002721 alternative hypothesis: true mean is greater than 0 95 percent confidence interval: 3.583269 Inf sample estimates: mean of x 7.363636 > t.test(pdat,cdat,paired=TRUE,mu=0,alternative="greater") Paired t-test data: pdat and cdat t = 3.5304, df = 10, p-value = 0.002721 alternative hypothesis: true difference in means is greater than 0 95 percent confidence interval: 3.583269 Inf sample estimates: mean of the differences 7.363636 Marc Mehlman (University of New Haven) Inference for Distributions 19 / 42

slide-23
SLIDE 23

Marc Mehlman

t test: Matched Pairs Without any assumptions of population distribution types or sample sizes one has:

Theorem (Sign Test for Matched Pairs)

Ignore pairs with differences of zero and let n be the count of the remaining pairs. The test statistic is the count, X, of pairs with a positive difference. To find the p–value of a test note that X ∼ BIN(n, 1/2) under the hypotheses H0 the median of the two matched pairs are the same.

Example

In the previous example concerning caffeine deprivation, ten out of eleven subjects experienced an increase in depression. Consider the signed test for matched pairs, H0 : median depression with caffeine = median depression with placebo versus HA : median depression with caffeine < median depression with placebo. Noticing that x = 10, the p–value is P(X ≥ 10) = P(X = 10) + P(X = 11) = 11 10 1 2 10 1 − 1 2 1 + 11 11 1 2 11 1 − 1 2

  • r, using R,

> 1-pbinom(9,11,1/2) [1] 0.005859375 Marc Mehlman (University of New Haven) Inference for Distributions 20 / 42

slide-24
SLIDE 24

Marc Mehlman

Two Sample z–Test: Means (σX and σY known)

Two Sample z–Test: Means (σX and σY known)

Two Sample z–Test: Means (σX and σY known)

Marc Mehlman (University of New Haven) Inference for Distributions 21 / 42

slide-25
SLIDE 25

Marc Mehlman

Two Sample z–Test: Means (σX and σY known)

Theorem (Two Sample z–Test: Means (σX and σY known)) Let X1, · · · , XnX and Y1, · · · , YnY be independent random samples where each random sample is either sampled from a normal population or has sample size ≥ 30, Let H0 : µX = µY with test statistic Z = ¯ X − ¯ Y

  • σ2

X

nX + σ2

Y

nY

∼ N(0, 1) for H0. A (1 − α)100% confidence interval for µX − µY is ¯ x − ¯ y ± z⋆

  • σ2

X

nX + σ2

Y

nY .

Marc Mehlman (University of New Haven) Inference for Distributions 22 / 42

slide-26
SLIDE 26

Marc Mehlman

Two Sample z–Test: Means (σX and σY known)

Example

The range of Brand X wireless routers is distributed as N(µX , 17.7) and the range of Brand Y wireless routers is distributed as N(µY , 15.3). Suppose ten Brand X routers are sampled and ¯ X = 131.2 meters. Further suppose that nine Brand Y routers are sampled and ¯ Y = 141.5 meters. Find the p–value of the test of H0 : µX = µY versus HA : µX < µY . Solution: z = 131.2 − 141.5

  • 17.72

10

+ 15.32

9

= −1.360229. which comes from N(0, 1) under H0. The p–value for the test is > zstat=(131.2-141.5)/sqrt((17.7^2/10)+(15.3^2/9)) > zstat [1] -1.360229 > pnorm(zstat,0,1) [1] 0.08687867 One must accept H0 at the 0.05 significance level and reject H0 at the 0.10 significance level.

Marc Mehlman (University of New Haven) Inference for Distributions 23 / 42

slide-27
SLIDE 27

Marc Mehlman

Two Sample z–Test: Means (σX and σY known)

Example

The range of Brand X wireless routers is distributed as N(µX , 17.7) and the range of Brand Y wireless routers is distributed as N(µY , 15.3). Suppose ten Brand X routers are sampled and ¯ X = 131.2 meters. Further suppose that nine Brand Y routers are sampled and ¯ Y = 141.5 meters. Find the p–value of the test of H0 : µX = µY versus HA : µX < µY . Solution: z = 131.2 − 141.5

  • 17.72

10

+ 15.32

9

= −1.360229. which comes from N(0, 1) under H0. The p–value for the test is > zstat=(131.2-141.5)/sqrt((17.7^2/10)+(15.3^2/9)) > zstat [1] -1.360229 > pnorm(zstat,0,1) [1] 0.08687867 One must accept H0 at the 0.05 significance level and reject H0 at the 0.10 significance level.

Marc Mehlman (University of New Haven) Inference for Distributions 23 / 42

slide-28
SLIDE 28

Marc Mehlman

Two Sample t–test: Means (σX and σY unknown)

Two Sample t–test: Means (σX and σY unknown)

Two Sample t–test: Means (σX and σY unknown)

Marc Mehlman (University of New Haven) Inference for Distributions 24 / 42

slide-29
SLIDE 29

Marc Mehlman

Two Sample t–test: Means (σX and σY unknown)

Theorem (Conservative Two Sample t-test: Means (σX and σY unknown))

Let X1, · · · , XnX and Y1, · · · , YnY be independent random samples. Assume either the random samples were sampled from a normal population or the sum of the sample sizes, nX + nY , are ≥ 30. Let H0 : µX = µY The (conservative) test statistic is T = ¯ X − ¯ Y

  • S2

X

nX + S2

Y

nY

∼ t(min(nX − 1, nY − 1)) for H0. A (1 − α)100% confidence interval for µX − µY is ¯ x − ¯ y ± t⋆(min(nX − 1, nY − 1))

  • s2

X

nX + s2

Y

nY .

Marc Mehlman (University of New Haven) Inference for Distributions 25 / 42

slide-30
SLIDE 30

Marc Mehlman

Two Sample t–test: Means (σX and σY unknown)

Theorem (Welch’s t Test)

Let X1, · · · , XnX and Y1, · · · , YnY be independent random samples. Assume either the random samples were sampled from a normal population or the each the sample sizes are ≥ 5. Let H0 : µX = µY The test statistic is T = ¯ X − ¯ Y

  • S2

X nX + S2 Y nY

∼ t (df) where df =

  • s2

X nX + s2 Y nY

2

1 nX −1

  • s2

X nX

2 +

1 nY −1

  • s2

Y nY

2 for H0. When using a table, let the degrees of freedom be largest integer that is less than or equal to df for a slightly more conservative test (statistical software can handle non–integer degree of freedoms). A (1 − α)100% confidence interval for µX − µY is ¯ x − ¯ y ± t⋆(df)

  • s2

X

nX + s2

Y

nY . Marc Mehlman (University of New Haven) Inference for Distributions 26 / 42

slide-31
SLIDE 31

Marc Mehlman

Two Sample t–test: Means (σX and σY unknown)

Robustness:

Two sample t–tests tend to be more robust than One sample t–test. This is especially true when either the two sample sizes are equal or the two populations have the similarly shaped distributions. When either (or both) of these conditions hold, the guidelines for using the Conservative Two Sample t–test or Welch’s t–test can be relaxed.

Marc Mehlman (University of New Haven) Inference for Distributions 27 / 42

slide-32
SLIDE 32

Marc Mehlman

Two Sample t–test: Means (σX and σY unknown)

Example

Does smoking damage the lungs of children exposed to parental smoking? Forced Vital Capacity (FVC) is the volume (in milliliters) of air that an individual can exhale in 6 seconds. FVC was obtained for a sample of children not exposed to parental smoking and for a sample of children exposed to parental smoking. Is the mean FVC lower in the population of children exposed to parental smoking? We test:

Parental smoking Mean FVC s n Yes 75.5 9.3 30 No 88.2 15.1 30

H0: µsmoke = µno <=> (µsmoke − µno) = 0 Ha: µsmoke < µno <=> (µsmoke − µno) < 0 (one-sided) Marc Mehlman (University of New Haven) Inference for Distributions 28 / 42

slide-33
SLIDE 33

Marc Mehlman

Two Sample t–test: Means (σX and σY unknown)

Example (cont.)

The test statistic is > (75.5-88.2)/sqrt(9.3^2/30 + 15.1^2/30) [1] -3.922419 The conservative test gives 29 for the degrees of freedom and a p–value of > tstat=(75.5-88.2)/sqrt(9.3^2/30 + 15.1^2/30) > tstat [1] -3.922419 > pt(tstat,29) [1] 0.0002468389 The degrees of freedom for Welch’s Test is

  • 9.32

30 + 15.12 30

2

1 30−1

  • 9.32

30

2 +

1 30−1

  • 15.12

30

2 = 48.23342. (Use 48 if you looking up the p–value in a table). Using R, Welch’s test gives a p–value of > pt(-3.922419, 48.23342) [1] 0.0001385454

Marc Mehlman (University of New Haven) Inference for Distributions 29 / 42

slide-34
SLIDE 34

Marc Mehlman

Two Sample t–test: Means (σX and σY unknown)

Example

> dat1=rnorm(25,0.9,2.5) > dat2=rnorm(43,0.6,1.3) > t.test(dat1,dat2,mu=0.0) Welch Two Sample t-test data: dat1 and dat2 t = 1.2977, df = 29.947, p-value = 0.2043 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval:

  • 0.4611103

2.0679355 sample estimates: mean of x mean of y 1.2426692 0.4392566

Marc Mehlman (University of New Haven) Inference for Distributions 30 / 42

slide-35
SLIDE 35

Marc Mehlman

Pooled Two Sample t–test: Means (σX = σY unknown)

Pooled Two Sample t–test: Means (σX = σY unknown)

Pooled Two Sample t–test: Means (σX = σY unknown)

Marc Mehlman (University of New Haven) Inference for Distributions 31 / 42

slide-36
SLIDE 36

Marc Mehlman

Pooled Two Sample t–test: Means (σX = σY unknown)

Theorem (Pooled Two Sample t–test: Means (σ = σX = σY unknown))

Let X1, · · · , XnX and Y1, · · · , YnY be independent random samples. Assume σ = σX = σY and that either the random samples were sampled from a normal population or the sum of the sample sizes, nX + nY , are ≥ 30. Define the pooled estimator of σ2, S2

p def

= (nX − 1)S2

X + (nY − 1)S2 Y

nX + nY − 2 . Let H0 : µX = µY The test statistic is T = ¯ X − ¯ Y Sp 1

nX + 1 nY

∼ t(nX + nY − 2) for H0. A (1 − α)100% confidence interval for µX − µY is ¯ x − ¯ y ± t⋆(nX + nY − 2)sp

  • 1

nX + 1 nY . Marc Mehlman (University of New Haven) Inference for Distributions 32 / 42

slide-37
SLIDE 37

Marc Mehlman

Pooled Two Sample t–test: Means (σX = σY unknown)

Example

> atab=rnorm(45,3,2) > btab=rnorm(50,3.5,2) > t.test(atab,btab,var.equal=TRUE) Two Sample t-test data: atab and btab t = -1.7116, df = 93, p-value = 0.0903 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval:

  • 1.3836440

0.1026042 sample estimates: mean of x mean of y 3.356853 3.997373

Marc Mehlman (University of New Haven) Inference for Distributions 33 / 42

slide-38
SLIDE 38

Marc Mehlman

Two Sample F–test: Variance

Two Sample F–test

Two Sample F–Test: Variance

Marc Mehlman (University of New Haven) Inference for Distributions 34 / 42

slide-39
SLIDE 39

Marc Mehlman

Two Sample F–test: Variance

Definition Let X1, · · · , Xn be a random sample from N(µX, σ) and let Y1, · · · , Ym be an independent random sample N(µY , σ). Then S2

X

S2

Y

∼ F(n − 1, m − 1) is the F distribution with n − 1 degrees of freedom for the numerator and m − 1 degrees of freedom for the denominator. The F distribution is named after Sir Ronald A. Fisher. “Even scientists need their heroes, and R. A. Fisher was certainly the hero of 20th century statistics. His ideas dominated and transformed our field to an extent a Caesar or an Alexander might have envied.” – Bradley Efron

Marc Mehlman (University of New Haven) Inference for Distributions 35 / 42

slide-40
SLIDE 40

Marc Mehlman

Two Sample F–test: Variance

Theorem (Two–Sample F Test) Let X1, · · · , Xn be a random sample from N(µX, σX) and let Y1, · · · , Ym be an independent random sample from N(µY , σY ). Let H0 : σX = σY . Then F def = S2

X

S2

Y

∼ F(n − 1, m − 1) under H0. Furthermore the p–value of H0 versus

1 HA : σX > σY is P(f ≥ F(n − 1, m − 1)). 2 HA : σX < σY is P(f ≤ F(n − 1, m − 1)). 3 HA : σX = σY is twice the smaller value from the two alternative

hypothesis above. Warning The F–test is not robust with respect normal distribution assumptions.

Marc Mehlman (University of New Haven) Inference for Distributions 36 / 42

slide-41
SLIDE 41

Marc Mehlman

Two Sample F–test: Variance

Example

The # of tail wags per minute of 11 randomly chosen Labrador dogs at feeding time was tallied and sample variance of 6.73 was calculated. The # of tail wags per minute of 9 randomly chosen terriers at feeding time was tallied and sample variance of 25.91 was calculated. Assuming that the number of wags for both types of dogs are normal, find the p–value of a test of H0 : σL = σT versus HA : σL < σT . Solution: F def =

S2

L

S2

T

∼ F(11 − 1, 9 − 1) under H0 and f =

6.73 25.91 = 0.26. The p–value of the

left–tailed test is > pf(6.73/25.91,10,8) [1] 0.02510348 There is reason to reject the hypothesis that variance of tail wagging is the same between terriers and Labradors in favor of more tail wagging variance for terriers.

Marc Mehlman (University of New Haven) Inference for Distributions 37 / 42

slide-42
SLIDE 42

Marc Mehlman

Two Sample F–test: Variance

Example

The # of tail wags per minute of 11 randomly chosen Labrador dogs at feeding time was tallied and sample variance of 6.73 was calculated. The # of tail wags per minute of 9 randomly chosen terriers at feeding time was tallied and sample variance of 25.91 was calculated. Assuming that the number of wags for both types of dogs are normal, find the p–value of a test of H0 : σL = σT versus HA : σL < σT . Solution: F def =

S2

L

S2

T

∼ F(11 − 1, 9 − 1) under H0 and f =

6.73 25.91 = 0.26. The p–value of the

left–tailed test is > pf(6.73/25.91,10,8) [1] 0.02510348 There is reason to reject the hypothesis that variance of tail wagging is the same between terriers and Labradors in favor of more tail wagging variance for terriers.

Marc Mehlman (University of New Haven) Inference for Distributions 37 / 42

slide-43
SLIDE 43

Marc Mehlman

Two Sample F–test: Variance

Example

> dat1=rnorm(25,0.9,2.5) > dat2=rnorm(43,0.6,1.5) > var.test(dat1,dat2) F test to compare two variances data: dat1 and dat2 F = 2.4715, num df = 24, denom df = 42, p-value = 0.009983 alternative hypothesis: true ratio of variances is not equal to 1 95 percent confidence interval: 1.242724 5.280972 sample estimates: ratio of variances 2.471486

Marc Mehlman (University of New Haven) Inference for Distributions 38 / 42

slide-44
SLIDE 44

Marc Mehlman

Two Sample F–test: Variance

To use a F table:

1 To use a F table, chose X to be the random variable with the larger

variance (thus the F statistic ≥ 1).

2 If the test is two–sided, use α/2 for the table. 3 When a degree of freedom can not be found in the table, use the

closest value that is less than the desired degree of freedom for a conservative test.

Marc Mehlman (University of New Haven) Inference for Distributions 39 / 42

slide-45
SLIDE 45

Marc Mehlman

Chapter #8 R Assignment

Chapter #8 R Assignment

Chapter #8 R Assignment

Marc Mehlman (University of New Haven) Inference for Distributions 40 / 42

slide-46
SLIDE 46

Marc Mehlman

Chapter #8 R Assignment

First create the normal datasets:

> set.seed(4321) > ndat1=rnorm(73,3.1,1.9) > ndat2=rnorm(57,2.9,2.3) > ndat3=rnorm(83,3.5,2.3)

and then do the problems:

1

For dataset ndat1, not knowing the mean is 3.1 or the standard deviation is 1.9, find the p–value of the test H0 : µ = 3.7 versus HA : µ < 3.7.

2

The dataset “immer” (found on my website) contains the barley yield in years 1931 and 1932 where the same field are recorded. The matched pair yield data are presented in by the columns Y1 and Y2. Find a 97.5% confidence interval for the difference of the means, µY1 − µY2, and use a matched pair t–test to find the p–value of H0 : µY1 = µY2 versus HA : µY1 = µY2.

Marc Mehlman (University of New Haven) Inference for Distributions 41 / 42

slide-47
SLIDE 47

Marc Mehlman

Chapter #8 R Assignment 3 Assuming the means and standard deviations of ndat1 and ndat2 are

unknown, use Welch’s t test to test if the means of the two data sets are equal.

4 Assuming the means and standard deviations of ndat2 and ndat3 are

unknown, but we know the population variances are equal, use pooled two sample t test to test if the means of the two data sets are equal.

Marc Mehlman (University of New Haven) Inference for Distributions 42 / 42