statistics visualization and more using r 298 916 block
play

Statistics, Visualization and More Using R (298.916) Block IV: - PowerPoint PPT Presentation

An introductory example Binom.test One sample t -test Two sample t -test Statistics, Visualization and More Using R (298.916) Block IV: (Elementary) hypothesis testing Ass.-Prof. Dr. Wolfgang Trutschnig Research group for


  1. An introductory example Binom.test One sample t -test Two sample t -test Statistics, Visualization and More Using ”R” (298.916) Block IV: (Elementary) hypothesis testing Ass.-Prof. Dr. Wolfgang Trutschnig Research group for Stochastics/Statistics Department for Mathematics University Salzburg www.trutschnig.net Salzburg, April 2017 Wolfgang Trutschnig Statistics, Visualization and More Using ”R” (298.916)

  2. An introductory example Binom.test One sample t -test Two sample t -test Plan for Block IV: ◮ An introductory example for the Binomial Distribution. ◮ Error of first and second kind; power. ◮ The p -value. ◮ Tests for the binomial (alternative) distribution. ◮ t -tests. ◮ Exercises. Wolfgang Trutschnig Statistics, Visualization and More Using ”R” (298.916)

  3. An introductory example Binom.test One sample t -test Two sample t -test Alternative and binomial distribution ◮ The alternative distribution is fully determined by one single parameter p ∈ [0 , 1]. ◮ If X has an alternative distribution we will write X ∼ A ( p ) in the sequel. ◮ If X ∼ A ( p ) then X can only assume two values: 0 and 1; more precisely P ( X = 1) = p , P ( X = 0) = 1 − p . ◮ We all know examples of variables with alternative distribution: ◮ If we denote the result of flipping a coin by 0 (tails) and 1 (heads), then p = 1 2 and X ∼ A ( 1 2 ). ◮ If X denotes the result of rolling a dice and we write 1 if the result is either 5 or 6 and 0 otherwise then p = 1 3 and X ∼ A ( 1 3 ). Wolfgang Trutschnig Statistics, Visualization and More Using ”R” (298.916)

  4. An introductory example Binom.test One sample t -test Two sample t -test Alternative and binomial distribution ◮ In practice, we do not know the parameter p and have to estimate it based on a sample x 1 , x 2 , . . . , x n . Example (Election forecasts simplified) ◮ Suppose that one week before the election 100 (randomly drawn) people are asked which of the two candidates ’0’ and ’1’ they will vote for. ◮ 42 answer ’0’ and 58 answer ’1’. ◮ How would you estimate p = P ( X = 1)? ◮ Natural choice is x 100 = 0 . 58 =: ˆ p 100 . Wolfgang Trutschnig Statistics, Visualization and More Using ”R” (298.916)

  5. An introductory example Binom.test One sample t -test Two sample t -test Alternative and binomial distribution ◮ Suppose that Z ∼ A ( p ) and we repeat the ’experiment’ n times. ◮ Let X denote the number of 1s observed in the n trials. ◮ We will write X ∼ Bin ( n , p ) and say that X has binomial distribution (with parameters n and p ). ◮ X can attain all integer values between 0 and n . ◮ With a little bit of mathematics we get the following well-known formula: � n � p k (1 − p ) n − k , P ( X = k ) = k ∈ { 0 , 1 , . . . , n } . k Example (Election again) ◮ Suppose that in the election exactly 50% voted for candidate ’0’ and candidate ’1’ each. ◮ We ask 100 randomly selected voters, which candidate they voted for. ◮ What is the probability that 42 answer ’0’ and 58 answer ’1’? 0 . 5 58 0 . 5 42 ≈ 0 . 022. � 100 ◮ P ( X = 58) = � 58 Wolfgang Trutschnig Statistics, Visualization and More Using ”R” (298.916)

  6. An introductory example Binom.test One sample t -test Two sample t -test Toy example hypothesis testing Example (Toy example hypothesis testing) ◮ Suppose that somebody rolls a dice (that you can not see). ◮ You only know that the dice either has (i) a ’1’ on four sides and a ’0’ on the other two sides or (ii) a ’1’ on two sides and a ’0’ on the other four sides. ◮ If we let X denote the result of rolling this dice once, then we either have 4 6 = 2 P ( X = 0) = 2 6 = 1 ( i ) p := P ( X = 1) = 3 = 1 − p and 3 or 2 6 = 1 P ( X = 0) = 4 6 = 2 ( ii ) p := P ( X = 1) = 3 = 1 − p . and 3 ◮ In other words, X ∼ A ( p ) and we know that p ∈ Θ = { 2 3 , 1 3 } . ◮ We will call H 0 : p = 2 3 the null hypothesis and H 1 : p = 1 3 the alternative hypothesis (for whatever reason). Wolfgang Trutschnig Statistics, Visualization and More Using ”R” (298.916)

  7. An introductory example Binom.test One sample t -test Two sample t -test Toy example hypothesis testing Example (Toy example hypothesis testing, cont.) ◮ For the moment we focus on H 0 : p = 2 3 . ◮ Suppose that the dice is rolled twice and the result is denoted by ( X 1 , X 2 ). ◮ Possibility 1: ( X 1 , X 2 ) = (1 , 1). Would you stick to H 0 or reject H 0 (i.e. change to H 1 ), and why? ◮ Possibility 2: ( X 1 , X 2 ) = (1 , 0). Would you stick to H 0 or reject H 0 , and why? ◮ Possibility 3: ( X 1 , X 2 ) = (0 , 1). Would you stick to H 0 or reject H 0 , and why? ◮ Possibility 4: ( X 1 , X 2 ) = (0 , 0). Would you stick to H 0 or reject H 0 , and why? ◮ Which criterion is your decision based upon? ◮ For a given observation we check under which of the two hypotheses the observation has higher probability. Wolfgang Trutschnig Statistics, Visualization and More Using ”R” (298.916)

  8. An introductory example Binom.test One sample t -test Two sample t -test Toy example hypothesis testing Example (Toy example hypothesis testing, cont.) ◮ If H 0 is correct then we have 4 P H 0 ( X 1 = 1 , X 2 = 0) = 2 P H 0 ( X 1 = 1 , X 2 = 1) = 9 , 9 2 P H 0 ( X 1 = 0 , X 2 = 0) = 1 P H 0 ( X 1 = 0 , X 2 = 1) = 9 , 9 . ◮ If H 1 is correct then we have 1 P H 1 ( X 1 = 1 , X 2 = 0) = 2 P H 1 ( X 1 = 1 , X 2 = 1) = 9 , 9 2 P H 1 ( X 1 = 0 , X 2 = 0) = 4 P H 1 ( X 1 = 0 , X 2 = 1) = 9 , 9 . ◮ In case of (1 , 1) we do not reject H 0 . ◮ In case of (1 , 0) and in case of (0 , 1) we do not reject H 0 (the observation is equally probable under both hypotheses, so by changing from H 0 to H 1 we don’t gain anything). ◮ In case of (0 , 0) we reject H 0 . Wolfgang Trutschnig Statistics, Visualization and More Using ”R” (298.916)

  9. An introductory example Binom.test One sample t -test Two sample t -test Toy example hypothesis testing Example (Toy example hypothesis testing, cont.) ◮ We intuitively reject H 0 if - under the assumption that H 0 is true - the observation we made is very unlikely (in the sense of having low probability). ◮ In our toy setting we can make two different mistakes: ◮ Type I error : We reject H 0 although it is correct. ◮ Type II error : We do not reject (accept) H 0 although it is wrong. ◮ Let us calculate the probability of a type I and the probability of a type II error in our toy setting: ◮ @type I error α : α := P H 0 ( reject H 0 ) = P H 0 ( X 1 = 0 , X 2 = 0) = 1 9 ◮ We have a chance of more than 11% to make a type I error. Wolfgang Trutschnig Statistics, Visualization and More Using ”R” (298.916)

  10. An introductory example Binom.test One sample t -test Two sample t -test Toy example hypothesis testing Example (Toy example hypothesis testing, cont.) ◮ @type II error β : β := P H 1 ( accept H 0 ) = P H 1 ( X 1 = 1 , X 2 = 1) + P H 1 ( X 1 = 1 , X 2 = 0) + P H 1 ( X 1 = 0 , X 2 = 1) 1 − P H 1 ( X 1 = 0 , X 2 = 0) = 5 = 9 ◮ We have chance of more than 55% to make a type II error. ◮ Could we improve our decision criterion to reduce the type I and the type II error? ◮ Is there a perfect decision rule such that α = β = 0? ◮ If we want α = 0 then we can NEVER reject H 0 , so we get β = 1. ◮ If we want β = 0 then we always have to reject H 0 , so we get α = 1. ◮ α and β are antagonists. ◮ Which one is more important? Think of a criminal trial... Wolfgang Trutschnig Statistics, Visualization and More Using ”R” (298.916)

  11. An introductory example Binom.test One sample t -test Two sample t -test Toy example hypothesis testing Hypothesis testing vs. criminal trials ◮ Consider a criminal trial. ◮ Based on evidence the jury (or the judge) has to decide whether the defendant is guilty or not. ◮ Suppose that H 0 = { innocent } and that H 1 = { guilty } . ◮ Right at the start the jury (or the judge) accepts H 0 and assumes that the defendant is innocent. ◮ Only if enough evidence is brought in, H 0 will be rejected and the defendant will be declared guilty. ◮ The afore-mentioned type I error α corresponds to the situation that the defendant will be declared guilty although he is innocent. ◮ The afore-mentioned type II error β corresponds to the situation that the defendant will be declared innocent although he is guilty. Wolfgang Trutschnig Statistics, Visualization and More Using ”R” (298.916)

  12. An introductory example Binom.test One sample t -test Two sample t -test Toy example hypothesis testing ◮ Which error has worse consequences for the defendant? ◮ Obviously the type I error. ◮ In the Anglo-Saxon jurisdiction system there there is the term ’Beyond reasonable doubt’ underlining this fact. ◮ In other words: We want to keep the type I error α (very) small. ◮ The same applies to hypothesis testing: α should be small, standard significance levels are α = 0 . 05 and α = 0 . 01 (one error out of twenty or one out of hundred). ◮ As soon as α is fixed it is the statisticians’ job to develop optimal tests, i.e. decision rules (criteria) with a probability of (at most) α for a type I error and, at the same time, minimal type II error β . Wolfgang Trutschnig Statistics, Visualization and More Using ”R” (298.916)

Recommend


More recommend