• Non ci sono risultati.

Inferential Statistics Part C Hypothesis tests

N/A
N/A
Protected

Academic year: 2021

Condividi "Inferential Statistics Part C Hypothesis tests"

Copied!
16
0
0

Testo completo

(1)

Inferential Statistics Part C

Hypothesis tests

Eva Riccomagno, Maria Piera Rogantin

DIMA – Universit`a di Genova

http://www.dima.unige.it/~rogantin/UnigeStat/

(2)

Part C

Hypothesis tests on the mean of a population

0. Review

1. Aside of probability. Normal (or Gaussian) random variable 2. Test on the mean of a Normal variable – known variance

(running example: toxic algae)

(a) Composite hypotheses (b) The power function

(3)

0. Review

A hypothesis testing is formed by - a null and alternative hypothesis

- a test statistics (function of the sample variables) - a rejection region/decision rule

Significance level/Critical value/Test statistic: all contribute to the definition of the rejection rule

Type I and II errors

Example: if R0 = {x such that T (x) > s} then:

α = P(T > s | H0) reject H0 when it’s true β = P(T ≤ s | H1) retain H0 when it’s false

(4)

Formulation of the hypotheses and “form” of R0

Example. The quantity of tomatoes in a can is nominally set at 100 g.

Formulate a statistical hypothesis test as if you were:

1. the Federal Trade Commission 2. an unscrupulous shareholder

3. the worker in charge of the quality control of the can tomato filling machine.

Indicate to which hypotheses the following R0 correspond:

R0 = {x s.t. T (x) > s}

R0 = {x s.t. T (x) < s1} ∪ {x s.t. T (x) > s2} R0 = {x s.t. T (x) < s}

In case of two-sided test s1 and s2 are such that

α1 = P(T < s1 | H0) α2 = P(T > s2 | H0) with α1 + α2 = α If the test statistic has a symmetrical distribution often α1 and α2 are set as: α1 = α2 = α/2

(5)

Consider Ex. 2 of Assignment 5. X ∼ B(20, p)

What happens when the hypotheses change?

1. H0 : p = 0.3 H1 : p = 0.5 α = 0.05 one-sided right 2. H0 : p = 0.5 H1 : p = 0.3 α = 0.05 one-sided left

> p_0=0.3;p_1=0.5;

> s05_right=qbinom(1-0.05,20,p_0);s05_right [1] 9 ### same result as p_1=0.7

> s05_left=qbinom(0.05,20,p_1)-1;s05_left ### note -1 [1] 5

One-sided right R0 = {x > 9}; one-sided left R0 = {x < 5}.

Notice that for x = 5, 6, 7, 8, 9 the decision of the two tests is different (small size and p0 “close” to p1)

What happens when α change?

1. H0 : p = 0.3 H1 : p = 0.5 α = 0.05 3. H0 : p = 0.3 H1 : p = 0.5 α = 0.01

> s01_right=qbinom(1-0.01,20,p_0);s01_right [1] 11

R0 with α = 0.01 is smaller than R0 with α = 0.05

(6)

1. Aside of Probability. Normal (or Gaussian) random variable

Probability density functions and cumulative distribution functions

µ = −1,0, 5 σ = 1

−4 −2 0 2 4 6 8

0.00.20.4

Normal −− sigma = 1

−4 −2 0 2 4 6 8

0.00.20.4

Normal −− sigma = 1

−4 −2 0 2 4 6 8

0.00.20.4

Normal −− sigma = 1

−4 −2 0 2 4 6 8

0.00.40.8

Normal −− sigma = 1

mu= − 1 mu = 0 mu = 5

−4 −2 0 2 4 6 8

0.00.40.8

Normal −− sigma = 1

mu= − 1 mu = 0 mu = 5

−4 −2 0 2 4 6 8

0.00.40.8

Normal −− sigma = 1

mu= − 1 mu = 0 mu = 5

µ = 0

σ = 0.5,1, 3

−5 0 5

0.00.20.40.60.8

Normal −− mu = 0

−5 0 5

0.00.20.40.60.8

Normal −− mu = 0

−5 0 5

0.00.20.40.60.8

Normal −− mu = 0

−5 0 5

0.00.40.8

Normal −− mu = 0

sigma=0.5 sigma=1 sigma=3

−5 0 5

0.00.40.8

Normal −− mu = 0

sigma=0.5 sigma=1 sigma=3

−5 0 5

0.00.40.8

Normal −− mu = 0

sigma=0.5 sigma=1 sigma=3

The density function of X ∼ N (µ, σ2) is: f (x) = 1

2π σ2 exp



(x−µ)

2

2



(7)

Some properties of the Normal random variables

• For X ∼ N (µ, σ2) let Y = aX + b. Then Y ∼ N (aµ + b, a2σ2) In particular

Z = X − µ

σ ∼ N (0, 1) Z is called standard Normal variable

• The sum of Normal variables is a Normal variable.

In particular for X1, . . . , Xn independent and identically dis- tributed (i.i.d.) with Xi ∼ N (µ, σ2) for all i = 1, . . . , n, then

X ∼ N µ, σ2 n

!

(8)

2. Test on the mean of a Normal random variable with known variance

2. (a) Composite hypotheses

Running example:

X models the concentration of toxic alga blooms

The statistical model is:

X ∼ N (µ, σ2) with σ2 known

and experts set a bathing alert if µ > 10000 cells/liter. Thus H0 : µ ≥ 10000 H1 : µ < 10000

The significance level of the test is set at α = 5%

If we reject H0 we can swim with 5% probability of side effects due to the alga

(9)

Test statistics X

Sample size: n = 10 σ = 2100 cells/liter Set α = 5%

The test hypotheses are both composite

First we consider the two cases 1. H0 : µ=10000 H1 : µ= 8500 2. H0 : µ=10000 H1 : µ<10000 and next

3. H0 : µ≥10000 H1 : µ<10000

10000

(10)

Case 1.

Assume H0: X ∼ N (10000, 21002/10)

R0 = {x < s} where s is such that PX < s|µ = 10000 = α Get s = 8908 with R

mu0=10000;std=2100/sqrt(10) c1= qnorm(.05,mu0,std);c1

If the test statistic value on the sample is less than 8908, then we reject H0 Spot the probability of type I error in the plot.

If x is larger than 8908, then the prob- ability of type II error is

β = P X > s|µ = 8500 Get β = 27% with R

mu1=8500;1-pnorm(c1,mu1,std)

We retain H0 with a large probability of type II error

10000

8500 retain H

reject H0 0

10000

8500 retain H

reject H0 0

(11)

Case 2.

H0 : µ=10000 H1 : µ<10000 R0 does not change

as it is computed under H0

The probability β of II type error be- comes a function of µ as it is com-

puted under H1 namely µ < 10000 reject H 10000retain H

0 0

Case 3.

H0 : µ≥10000 H1 : µ<10000

Keeping the same R0, the prob- ability of type I error, denoted by α(µ), is smaller than α

α(µ) < α

The probability β of the type II error is a function of µ under H1, as in

10000 retain H

reject H0 0

(12)

2. (b) The power function P(θ) of a test

Consider a generic test on a parameter θ:

H0 : θ ∈ Θ0 H1 : θ ∈ Θ1

Running example. H0 : µ ≥ 10000 H1 : µ < 10000 Then Θ0 = [10000, +∞), Θ1 = (−∞, 10000)

The power function of a test is the probability to reject H0 as a function of the parameter θ

P (θ) = P(T ∈ R0|θ) =

( 1 − β(θ) if θ ∈ Θ1 correct decision α(θ) if θ ∈ Θ0 type I error

Note that α(θ) ≤ α

1. the critical value is the smallest s s.t. P (T > s|H0) < α 2. the critical region is the largest R0 s.t. P (T ∈ R0|H0) < α

(13)

Power function:

P (θ) = P (T ∈ R0|θ) =

( 1 − β(θ) if θ ∈ Θ1 correct decision α(θ) if θ ∈ Θ0 type I error

Running example:

R0 = {X < 8908}

P (µ) = PX < 8908 | µ ∈ R P (10000) = 0.05 = α

0 1

α

10000 8500

1-β(8500)

std=2100/sqrt(10);c1=qnorm(.05,10000,std) mu=seq(7000,11000)

p=pnorm(c1,mu,std)

plot(mu,p,type="l",lwd=3, col="red")

(14)

Power and sample size

The probability to reject H0, when it is false, grows as the sam- ple size grows

The probabilities of the two type of errors decrease as the sample size grows

Running example

H0 : µ ≥ 10000 and H1 : µ < 10000 R0 = {Xn < 8908}

P (µ) = P Xn < 8908 | µ ∈ R

n = 10 red n = 20 blue 0

1

α

10000 0

1

α

10000

9500 Θ

Θ1 0

If the values of the parameter under H0 and under H1 are “close”

(e.g. 10000 and 9500 respectively), only with large sample the probability of correct decision is large

(15)

The power for one-sided and two-sided tests

One-sided: H0 : µ ≥ 10000 and H1 : µ < 10000

R0 = {X < 8908} P (µ) = PX < 8908| µ ∈ R

Two-sided: H0 : µ = 10000 and H1 : µ 6= 10000 R0 = {X < 8700} ∪ {X > 11300}

P (µ) = PX < 8700 | µ ∈ R + PX > 11300) | µ ∈ R

(16)

One-sided red

H0 : µ ≥ 10000 H1 : µ < 10000

Two-sided blue

H0 : µ = 10000 H1 : µ 6= 10000

0 1

α

10000

mu=seq(7000,13000); mu0=10000; std=2100/sqrt(10) c1_u=qnorm(.05,mu0,std); p=pnorm(c1_u,mu,std)

c1_b=qnorm(.025,mu0,std);c2_b=qnorm(.975,mu0,std);p_b=pnorm(c1_b,mu,std)+1-pnorm(c2_b,mu,std) limx=c(7000,13000);limy=c(0,1)

plot(mu,p,type="l",lwd=3,xaxt="n",yaxt="n",xlab=" ",ylab=" ",col="red",xlim=limx,ylim=limy) par(new=T)

plot(mu,p_b,type="l",lwd=3,xaxt="n",yaxt="n",xlab=" ",ylab=" ",col="blue",xlim=limx,ylim=limy) axis(2, at = 0,0, las=1,cex=1.2,col="blue");axis(2, at = 1,1, las=1,cex=1.2,col="blue")

axis(2, at =0.05,expression(alpha), las=1,cex=1.2,col="blue") axis(1, at = mu0,mu0, las=1,cex=1.2,col="blue")

abline(h=c(0,1));abline(h=0.05,v=c(mu0),lty=3,lwd=2);abline(h=0.05,lty=3,lwd=2)

Riferimenti

Documenti correlati

If the points form a nearly linear pattern, the normal distribution is a good model for this data. Departures from the straight line indicate departures

The challenge is to use the one sample that is available, together with the assumption of independent and iden- tically distributed sample values, to infer the sampling distribution

Consider a test on the mean µ of a random variable X with unknown distribution and assume a large sample size.. Aside of probability.. Test on the proportion p of a binary

Part F Confidence intervals.. Chicago land’s technology professionals get local technology news from various newspapers and magazines. A marketing company claims that 25% of the

Chi-square test, Phi coefficient, and Fisher exact test... , X n ) is distribution-free if its distribution is invariant for each distribution of the sample variables.. An example:

Provide the example of a sequential game in extensive form, with two players and two strategies, with two Nash equilibria, but only one 'perfect subgame equilibrium'.

© Lars Bendix - Lund Institute of Technology Bologna, Italy, May 6th, 2004?. Software Configuration Management

Let a, b, and c be the lengths of the sides of a triangle, and let R and r be the circumradius and inradius of the