6. Hypothesis Testing

Typical Steps

Frequentist:

  1. State your hypothesis
    H0:μ=μ0,Ha:μμ0
  2. Find you test statistic
    z=x¯μ0σn
  3. P-value = P[z>z]
  4. Conclusions α= significance level, if P-value <α then reject H0

Bayesian:

  1. State Hypothesis
  2. Find posterior distribution
  3. Find the posterior probability of H0 that is P[H0|Data]
  4. Conclusion if P[H0|Data]<α then we reject H0 (the complement is the pro)

Example Normal

The local consumer watchdog group was concerned about the cost of electricity to residential customers over the summer months. They took a random sample of 25 residential electricity accounts and looked at the total cost of electricity used over the three months of June, July, and August. The costs were:
514 536 345 440 427
443 386 418 364 483
506 385 410 561 275
306 294 402 350 343
480 334 324 414 296

Assume that the amount of electricity used over the three months by a residential account is Normal(μ, σ2), where the known standard deviation σ = 80.

a) Use a Normal(325,802) prior for μ. Find the posterior distribution for μ.

Using the updating rules

1s2=25802+180280226=246.1538m=[18021802+1s2]401.44+[1s21802+1s2]325=2556401.44+3156325398.5P(μ|Data)N(398.5,256.1588)

b) Find a 95% Bayesian credible interval for μ.

m±zα2s2

c) Perform a Bayesian test of the hypothesis
H0:μ=350,Ha:μ350 at the 5% level.

Not within the credible interval so no, reject H0

d) Perform a Bayesian test of the hypothesis
H0:μ350,Ha:μ>350 at the 5% level.

P[μ350|Data]=P[z350ms]=P[z3.09]=0.0010

Rejects H0

Example Poisson

A local enforcement agency claims that the number of times that a patrol car passes through a particular neighbourhood follows a Poisson process with a mean of three times per nightly shift. Suppose that during a randomly selected night shift no patrol cars pass through the neighbourhood. Do you believe the agency’s claim? Perform a Bayesian test of the hypothesis

H0:λ3,Ha:λ<3 at the 5% level.

Use a Gamma(r=1,v=1/3) prior for λ.

by updating rules

p(λ|y=0) is Gamma(r=0+1,v=1+13=43)P[H0|Data]=P[λ3]=343Γ(1)λ11e4/3(λ)dλ=343e4/3(λ)dλ=e4

compare to earlier example

Difference In Parameters

Example Difference in Proportion

A new study indicates that tai chi, an ancient Chinese practice of exercise and med-
itation, may relieve symptoms of chronic painful fibromyalgia. The study assigned 66
fibromyalgia patients to take either a 12-week tai chi class (n1=33) or a wellness educa-
tion class (n2=33). The results of the study are shown in the following table:
Tai Chi Wellness Education

Thai ChiWellness EducationNumber who felt better2613

Show all your work and circle your final answers.
a) Find the posterior distribution of π1, the proportion of fibromyalgia patients who would
admit to feeling better after taking the tai chi class. (Use a Beta(1, 1) prior for π1. )

p(π1|Data)(π1)11(1π)11(π)26(1π)7π1|DataBeta(27,8)

b) Find the posterior distribution of π2, the proportion of fibromyalgia patients who would
admit to feeling better after taking the wellness education class. (Use a Beta(1, 1) prior
for π2.)

π2|DataBeta(14,21)

c) Find the approximate posterior distribution of π1π2.

E[π1π2]=E[π1]E[π2]=2735+1435Var[π1π2]=278(35)2(36)+1421352(36)

d) Test H0:π1π00 vs Ha:π1π2<0 at the 1% level

P[H0|Data]

P[π1π20]P[(π1π2)0.37140.01160.37140.0116]0.9997

Fail to reject

Example Difference in Means

Industrial wastes and sewage dumped into our rivers and streams absorb oxygen and thereby reduce the amount of dissolved oxygen available for fish and other forms of aquatic life. One provincial agency requires a minimum of 5 parts per million (ppm) of dissolved oxygen in order for the oxygen content to be sufficient to support aquatic life. A pollution control inspector suspected that a river community was releasing amounts of semitreated sewage into a river. To check her theory, she drew five randomly selected specimens of river water at a location above the town, and another five below. The dissolved oxygen readings (in parts per million) are as follows:

Above town (A)Below town (B)4.85.05.24.75.04.94.94.85.14.9

(a) We will assume that the observations come from

Normal(μA,σ2)andNormal(μB,σ2),

where

σ2=0.22.

Use independent “flat priors” for μA and μB.

Find the posterior distributions of μA and μB.

Answer:

Flat Prior: g(μ)=1, N(0,sA20)
Assumption: σ2 is known

p(μa|y)e12(σ2/n)[μy¯]2

Updating Rules:

For μA

Posterior Precision =Sample Precision+ Prior Precision1sA2=1sA2limsA2+nAσ21sA2=50.22=5004Posterior Mean=Sample PrecisionPosterior Precision(Sample Mean)+Prior PrecisionPosterior Precision(Prior Mean)mA=[nAσ2(1sA2)]y¯A+0(4500)y¯mA=y¯AmA=5

P(μA|Data)N(5,4500)

For μB

1sB2=nBσ2=5004mB=y¯B=4.86

P(μB|Data)N(5,4500)

b) P(μAμB|Data)Normal
Mean = 54.86=0.14
Variace = 8500

c) 95% C.I = 0.14±1.968500

d) H0:μAμB0 vs Ha:μAμB>0

P[μAμB0.1485090.148400]=0.133

fail to reject