SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
Stat310            Hypothesis tests


                            Hadley Wickham
Wednesday, 21 April 2010
1. Quiz
                2. Final
                3. Hypothesis tests




Wednesday, 21 April 2010
Final

                    2 hour take home
                    Due last day of exam period
                    Larger number of smaller questions like
                    the homeworks
                    More info on Thursday



Wednesday, 21 April 2010
1. Write down Ho and Ha
                   (positions of defence and prosecution)
                2. Figure out good test statistic
                   (what numeric summary?)
                3. Work out null distribution
                   (distribution of innocents)
                4. Calculate p-value by comparing actual value
                   to null distribution (what proportion of true
                   innocents look more guilty than the suspect)
                5. Reject Ho if p-value smaller than cutoff


Wednesday, 21 April 2010
Hypothesis
                    Null hypothesis = Ho
                    Alternative hypothesis = Ha
                    Hint: because we need to be able to
                    calculate the null distribution, the null
                    hypothesis will always be of the form:
                    Some parameter = some value
                    μ=0


Wednesday, 21 April 2010
Suitcase

                    Does this suitcase contain a radioactive
                    bomb? Construct Ho and Ha.
                    Let R be the background radiation
                    measured over a minute. R ~ Poisson(2).
                    Let S be the radiation from the suitcase.
                    Construct a more precise Ho and Ha.



Wednesday, 21 April 2010
Grade difference
                    I’m interested in whether or not there is a
                    difference between this years average
                    stat310 grade and last years. Construct
                    Ho and Ha.
                    If grades are normally distributed both
                    years, can you rewrite the null hypothesis
                    to be more precise? What other
                    assumptions do you need?


Wednesday, 21 April 2010
Alternative
                    Can be one-sided or two-sided
                    Basically comes down to the question of
                    what more guilty means.
                    For the suitcase: guilty means higher
                    radiation.
                    For course grades: guilty means positive
                    or negative difference.


Wednesday, 21 April 2010
1. Write down Ho and Ha
                   (positions of defence and prosecution)
                2. Figure out good test statistic
                   (what numeric summary?)
                3. Work out null distribution
                   (distribution of innocents)
                4. Calculate p-value by comparing actual value
                   to null distribution (what proportion of true
                   innocents look more guilty than the suspect)
                5. Reject Ho if p-value smaller than cutoff


Wednesday, 21 April 2010
Xi iid, and n large (> 30):



                           ¯n − µ .
                           X
                             √ ∼Z
                           σ/ n
                           ¯n − µ .
                           X
                             √ ∼Z
                           S/ n

Wednesday, 21 April 2010
iid                 2
Xi ∼ Normal(µ, σ )

                       (n − 1)S2

                            2
                                  ∼ χ (n − 1)
                                     2
                          σ
                            X ¯n − µ
                                √ ∼Z
                              σ/ n
                            X ¯n − µ
                                √ ∼ tn−1
                              s/ n
Wednesday, 21 April 2010
Others

                    Difference of normals
                    Sum of poisson
                    Sum of binomial
                    ...




Wednesday, 21 April 2010
Suitcase

                    What test statistic might you use?
                    (What experiment might you conduct?)
                    What is the null distribution?




Wednesday, 21 April 2010
Grade difference


                    What test statistic might you use?
                    What is its null distribution?




Wednesday, 21 April 2010
1. Write down Ho and Ha
                   (positions of defence and prosecution)
                2. Figure out good test statistic
                   (what numeric summary?)
                3. Work out null distribution
                   (distribution of innocents)
                4. Calculate p-value by comparing actual value
                   to null distribution (what proportion of true
                   innocents look more guilty than the suspect)
                5. Reject Ho if p-value smaller than cutoff


Wednesday, 21 April 2010
P-value
                    Standardised measurement of evidence.
                    Low p-value = low probability of innocent
                    looking this guilty = reject the null
                    High p-value = high probability of
                    innocent looking this guilty = don’t reject
                    Don’t need to know anything else about
                    the test!


Wednesday, 21 April 2010
Suitcase
                                                    X ∼ Poisson(2)
                    Background radiation is            X     P(X ≤ x)
                    Poisson(2)                         0      0.14
                    If I measure the suitcase          1      0.41
                    and record a 3, what’s the p
                                                       2      0.68
                    -value? What if I record a
                    5?                                 3      0.86
                    What’s the probability it’s a      4      0.95
                    bomb?                              5      0.98


Wednesday, 21 April 2010
Course grades

                    Assume for simplicity there were 100
                    students both years, and the variance of
                    the course grade was 80.
                    What would the distribution of the test
                    statistic be?




Wednesday, 21 April 2010
1. Write down Ho and Ha
                   (positions of defence and prosecution)
                2. Figure out good test statistic
                   (what numeric summary?)
                3. Work out null distribution
                   (distribution of innocents)
                4. Calculate p-value by comparing actual value
                   to null distribution (what proportion of true
                   innocents look more guilty than the suspect)
                5. Reject Ho if p-value smaller than cutoff


Wednesday, 21 April 2010
Say is      Say is
                                       guilty    innocent

                                                  False
                           Is guilty   Correct
                                                 acquittal

                               False
                 Is innocent                     Correct
                             conviction


Wednesday, 21 April 2010
Your turn


                    Which type of error is more expensive/
                    more costly/worse in the criminal justice
                    system?




Wednesday, 21 April 2010
Reject HO Accept HO


                                                Type II
                       HO false       Correct
                                                 error

                                      Type I
                           HO true              Correct
                                      error


Wednesday, 21 April 2010
Rates

                    For a given test,
                    P(false conviction) = α = significance level
                    P(false acquittal) = β = power
                    What do think happens to β if you try to
                    make α smaller?



Wednesday, 21 April 2010
α↑ β↓
                           α↓ β↑
Wednesday, 21 April 2010
Cut off

                    Choose cut-off based on rate of false
                    convictions.
                    If you want a 5% rate of false convictions,
                    reject Ho if the p-value is less than 0.05.
                    Can work out power.



Wednesday, 21 April 2010
Connection to
                           confidence intervals
                    If you construct a 90% confidence
                    interval, and it doesn’t include the
                    parameter until the null, then the p-value
                    must be > 1 - 0.9 = 0.1.
                    If the p-value is 0.08, then a 92% or
                    greater confidence interval would include
                    the null parameter, and a smaller
                    confidence interval would not.


Wednesday, 21 April 2010
Next time
                    Last notes on testing.
                    More info about the final and study
                    sessions.
                    Opportunity for feedback.
                    Why statistics is awesome and you should
                    do more.
                    Class party!


Wednesday, 21 April 2010

Mais conteúdo relacionado

Destaque (6)

24 modelling
24 modelling24 modelling
24 modelling
 
Plyr, one data analytic strategy
Plyr, one data analytic strategyPlyr, one data analytic strategy
Plyr, one data analytic strategy
 
R packages
R packagesR packages
R packages
 
27 development
27 development27 development
27 development
 
27 development
27 development27 development
27 development
 
22 spam
22 spam22 spam
22 spam
 

Semelhante a 24 tests (6)

23 testing
23 testing23 testing
23 testing
 
04 Bayes Rule
04 Bayes Rule04 Bayes Rule
04 Bayes Rule
 
25 fin
25 fin25 fin
25 fin
 
6주차
6주차6주차
6주차
 
JSM 2011 round table
JSM 2011 round tableJSM 2011 round table
JSM 2011 round table
 
JSM 2011 round table
JSM 2011 round tableJSM 2011 round table
JSM 2011 round table
 

Mais de Hadley Wickham (20)

21 spam
21 spam21 spam
21 spam
 
20 date-times
20 date-times20 date-times
20 date-times
 
19 tables
19 tables19 tables
19 tables
 
17 polishing
17 polishing17 polishing
17 polishing
 
16 critique
16 critique16 critique
16 critique
 
15 time-space
15 time-space15 time-space
15 time-space
 
14 case-study
14 case-study14 case-study
14 case-study
 
13 case-study
13 case-study13 case-study
13 case-study
 
12 adv-manip
12 adv-manip12 adv-manip
12 adv-manip
 
11 adv-manip
11 adv-manip11 adv-manip
11 adv-manip
 
11 adv-manip
11 adv-manip11 adv-manip
11 adv-manip
 
10 simulation
10 simulation10 simulation
10 simulation
 
10 simulation
10 simulation10 simulation
10 simulation
 
09 bootstrapping
09 bootstrapping09 bootstrapping
09 bootstrapping
 
08 functions
08 functions08 functions
08 functions
 
07 problem-solving
07 problem-solving07 problem-solving
07 problem-solving
 
06 data
06 data06 data
06 data
 
05 subsetting
05 subsetting05 subsetting
05 subsetting
 
04 reports
04 reports04 reports
04 reports
 
03 extensions
03 extensions03 extensions
03 extensions
 

24 tests

  • 1. Stat310 Hypothesis tests Hadley Wickham Wednesday, 21 April 2010
  • 2. 1. Quiz 2. Final 3. Hypothesis tests Wednesday, 21 April 2010
  • 3. Final 2 hour take home Due last day of exam period Larger number of smaller questions like the homeworks More info on Thursday Wednesday, 21 April 2010
  • 4. 1. Write down Ho and Ha (positions of defence and prosecution) 2. Figure out good test statistic (what numeric summary?) 3. Work out null distribution (distribution of innocents) 4. Calculate p-value by comparing actual value to null distribution (what proportion of true innocents look more guilty than the suspect) 5. Reject Ho if p-value smaller than cutoff Wednesday, 21 April 2010
  • 5. Hypothesis Null hypothesis = Ho Alternative hypothesis = Ha Hint: because we need to be able to calculate the null distribution, the null hypothesis will always be of the form: Some parameter = some value μ=0 Wednesday, 21 April 2010
  • 6. Suitcase Does this suitcase contain a radioactive bomb? Construct Ho and Ha. Let R be the background radiation measured over a minute. R ~ Poisson(2). Let S be the radiation from the suitcase. Construct a more precise Ho and Ha. Wednesday, 21 April 2010
  • 7. Grade difference I’m interested in whether or not there is a difference between this years average stat310 grade and last years. Construct Ho and Ha. If grades are normally distributed both years, can you rewrite the null hypothesis to be more precise? What other assumptions do you need? Wednesday, 21 April 2010
  • 8. Alternative Can be one-sided or two-sided Basically comes down to the question of what more guilty means. For the suitcase: guilty means higher radiation. For course grades: guilty means positive or negative difference. Wednesday, 21 April 2010
  • 9. 1. Write down Ho and Ha (positions of defence and prosecution) 2. Figure out good test statistic (what numeric summary?) 3. Work out null distribution (distribution of innocents) 4. Calculate p-value by comparing actual value to null distribution (what proportion of true innocents look more guilty than the suspect) 5. Reject Ho if p-value smaller than cutoff Wednesday, 21 April 2010
  • 10. Xi iid, and n large (> 30): ¯n − µ . X √ ∼Z σ/ n ¯n − µ . X √ ∼Z S/ n Wednesday, 21 April 2010
  • 11. iid 2 Xi ∼ Normal(µ, σ ) (n − 1)S2 2 ∼ χ (n − 1) 2 σ X ¯n − µ √ ∼Z σ/ n X ¯n − µ √ ∼ tn−1 s/ n Wednesday, 21 April 2010
  • 12. Others Difference of normals Sum of poisson Sum of binomial ... Wednesday, 21 April 2010
  • 13. Suitcase What test statistic might you use? (What experiment might you conduct?) What is the null distribution? Wednesday, 21 April 2010
  • 14. Grade difference What test statistic might you use? What is its null distribution? Wednesday, 21 April 2010
  • 15. 1. Write down Ho and Ha (positions of defence and prosecution) 2. Figure out good test statistic (what numeric summary?) 3. Work out null distribution (distribution of innocents) 4. Calculate p-value by comparing actual value to null distribution (what proportion of true innocents look more guilty than the suspect) 5. Reject Ho if p-value smaller than cutoff Wednesday, 21 April 2010
  • 16. P-value Standardised measurement of evidence. Low p-value = low probability of innocent looking this guilty = reject the null High p-value = high probability of innocent looking this guilty = don’t reject Don’t need to know anything else about the test! Wednesday, 21 April 2010
  • 17. Suitcase X ∼ Poisson(2) Background radiation is X P(X ≤ x) Poisson(2) 0 0.14 If I measure the suitcase 1 0.41 and record a 3, what’s the p 2 0.68 -value? What if I record a 5? 3 0.86 What’s the probability it’s a 4 0.95 bomb? 5 0.98 Wednesday, 21 April 2010
  • 18. Course grades Assume for simplicity there were 100 students both years, and the variance of the course grade was 80. What would the distribution of the test statistic be? Wednesday, 21 April 2010
  • 19. 1. Write down Ho and Ha (positions of defence and prosecution) 2. Figure out good test statistic (what numeric summary?) 3. Work out null distribution (distribution of innocents) 4. Calculate p-value by comparing actual value to null distribution (what proportion of true innocents look more guilty than the suspect) 5. Reject Ho if p-value smaller than cutoff Wednesday, 21 April 2010
  • 20. Say is Say is guilty innocent False Is guilty Correct acquittal False Is innocent Correct conviction Wednesday, 21 April 2010
  • 21. Your turn Which type of error is more expensive/ more costly/worse in the criminal justice system? Wednesday, 21 April 2010
  • 22. Reject HO Accept HO Type II HO false Correct error Type I HO true Correct error Wednesday, 21 April 2010
  • 23. Rates For a given test, P(false conviction) = α = significance level P(false acquittal) = β = power What do think happens to β if you try to make α smaller? Wednesday, 21 April 2010
  • 24. α↑ β↓ α↓ β↑ Wednesday, 21 April 2010
  • 25. Cut off Choose cut-off based on rate of false convictions. If you want a 5% rate of false convictions, reject Ho if the p-value is less than 0.05. Can work out power. Wednesday, 21 April 2010
  • 26. Connection to confidence intervals If you construct a 90% confidence interval, and it doesn’t include the parameter until the null, then the p-value must be > 1 - 0.9 = 0.1. If the p-value is 0.08, then a 92% or greater confidence interval would include the null parameter, and a smaller confidence interval would not. Wednesday, 21 April 2010
  • 27. Next time Last notes on testing. More info about the final and study sessions. Opportunity for feedback. Why statistics is awesome and you should do more. Class party! Wednesday, 21 April 2010