Uit 8: Iferece for Proortios Chaters 8 & 9 i IPS
Lecture Outlie Iferece for a Proortio (oe samle) Iferece for Two Proortios (two samles) Cotigecy Tables ad the χ test
Iferece for Proortios IPS, Chater 8 Iferece for oulatio roortios () Hyothesis tests Cofidece itervals The aroach here should be familiar by ow: Formulate a roblem i terms of a oulatio arameter Fid a atural estimate of the arameter Stadardize the arameter to (hoefully) a z-score, use tables of the stadard ormal to costruct cofidece itervals, hyothesis tests 3
Is ESP for real? I 934, Rhie ad Zeer ublished a aer which cocluded that extra-sesory-ercetio (ESP) was real They erformed a series of trials i which they had a voluteer guess a card which had a -i-5 chace of beig correct by chace aloe (see cards above). I oe of their exerimets, they foud that the voluteers guessed correctly o 07 of 800 total chaces. Does this suort evidece of ESP? 4
I kow there s ESPN but is there ESP? Defie the radom variables: X = cout of correct guesses out of a fixed ( = 800 here) ˆ = roortio of correct guesses ( ˆ = X/) What would be a aroriate ull hyothesis of o ESP effect? What about the alterative hyothesis? H 0 : = 0 = 0.0 H A : > 0 = 0.0 Should this be a -sided test? Because its tougher to reject ad, ever look at your data before comig u with your hyotheses. So what from the data would be a good measuremet for these hyotheses? ˆ What is the stadard deviatio of this measuremet (if H 0 is true)? More formally ( ) 0( 0) 5
Oe samle z-sigificace test for a oulatio roortio () To test the hyothesis H 0 : = 0 agaist a oe or two-sided alterative, comute the oe-samle z-statistic z ˆ 0 ( Use -values or critical values for the stadard ormal (z) distributio. Why the stadard ormal here istead of a t? Because the stadard error i the deomiator is based o the theoretical distributio of a biomial (if we kow, we automatically get σ ^ ). Its ot a secod estimated quatity from the samle like s is for meas i t-tests. 0 0 ) 6
Solutio to test if there is evidece of ESP: H H 0 A : : 0.0 0.0 0.0(just for fu) ˆ 07 800 0.59 z ˆ 0 ( 0 ) 0.59 0.0 0 0.0( 0.0) 800 value P( z 4.7) 0.000 4.7 Sice our -value < 0.0, we ca reject the ull hyothesis. It looks like there is evidece of ESP voluteers teded to guess the card correctly more ofte tha chace aloe. What factors could be biasig this exerimetal study? 7
Cofidece Itervals for a oulatio roortio () The oe-samle level C (cofidece coefficiet) cofidece iterval for has the form ˆ z * ˆ( ˆ) I these formulas, z* is the critical value from the stadard ormal distributio with area C betwee z* ad z*. Note the slight differece i the stadard error here (comared to the deomiator of the z-test): here we are usig the samle roortio, ˆ, sice there is o ull hyothesis from which to draw a assumed 0 from. 8
Solutio to the 99% cofidece iterval for the true roortio/robability of guessig a card correctly Should this iterval cotai the value 0.0? Why? The calculatio: ˆ z * ˆ( ˆ) 0.59.58 (0.9, 0.99) 0.59(0.74) 800 Note that all these calculatios are doe based o the ormal aroximatio to the biomial. So for either the cofidece iterval ad hyothesis test to be valid, we eed both: 0 ad ( - ) 0 9
Lecture Outlie Iferece for a Proortio (oe-samle) Iferece for Two Proortios (two-samles) Cotigecy Tables ad the χ test 0
Who s more likely to wear glasses: Jae or Joe? Could there be a sex-based, biological basis for eedig corrective eyewear? I the first day survey, the questio was asked: Do you wear corrective eyewear? We foud that 4 out of 6 (53.8%) me wear corrective eyewear, ad foud that 4 out of (66.7%) wome wear corrective eyewear. Is there evidece of a true differece betwee the sexes i the robability of wearig corrective eyewear i the etire oulatio [assumig our class is a radom samle]? Or is this differece we see i the samle just by radom chace?
Jae vs. Joe Defie the radom variables: ˆ M= roortio of me w/ corrective eyewear (w/ a fixed M ) ˆW = roortio of wome w/ corrective eyewear (w/ a fixed W ) What would be a aroriate ull hyothesis of o differece betwee the sexes? What about the alterative hyothesis? H 0 : M - W = 0 H A : M - W 0 So what from the data would be a good measuremet for these hyotheses? ˆ ˆ M W What is the stadard deviatio of this measuremet (if H 0 is true)? M ( M ) W ( W ) ( ) ( ) ( ) M W M W M The above sd holds if we assume the true samle roortios are equal, ad thus the same as some overall (ooled) roortio: More formally W
3 Two samle z-sigificace test for a differece i oulatio roortios To test the hyothesis H 0 : = 0 agaist a oe or two-sided alterative, comute the two-samle z-statistic Where: Use -values or critical values for the stadard ormal (z) distributio to determie your coclusio. Notice the ooled estimator of the combied roortio. Why? Sice the ull hyothesis says they are equal, let s use that fact to get a best estimate of that overall combied 0 ) ˆ ( ˆ ) ( ) ˆ ˆ ( H z ˆ X X
Solutio to test if there is evidece of diff i sexes of corrective eyewear: H H 0 A : : ( ˆ z ˆ ˆ 0.05 ( ) ( ˆ ) H ) (0.538 0.667) 0 0 0 0 ˆ X X 4 4 6 0.5957( 0.5957) 6 8 47 0.5957 0.89 value * P( z 0.89 ) * P( z 0.89) *0.867 0.3734 Sice our -value > 0.05, we caot reject the ull hyothesis. There is ot eough evidece of a differece betwee the sexes i the true roortio of eole i the oulatio that wear corrective eyewear. What factors could be biasig observatioal study? 4
Two-samle Cofidece Iterval for a differece i oulatio roortios The two-samle level-c cofidece iterval for the differece betwee two oulatio roortios ( ) has the form: ( ˆ ˆ ) z * ( ( I these formulas, z* is the critical value from the stadard ormal distributio with area C betwee z* ad z*. ˆ Note the slight differece i the stadard error here (comared to the deomiator of the z-test): here we are usig the two samle roortios searately sice there is o ull hyothesis sayig they are equal so o reaso to ool them. ˆ ) ˆ ˆ 5 )
Solutio to the 95% cofidece iterval for the true differece betwee the sexes Should this iterval cotai the value 0? Why? The calculatio: ( ˆ ˆ ) z * ˆ ( ˆ (0.538 0.667).96* ( 0.406, 0.48) ) ( 0.538( 0.538) 6 Agai, all these calculatios are doe based o the ormal aroximatio to the biomial. So for this (CI ad hyo test) to be valid, we eed for both grous: 0 ad ( ) 0 ˆ ˆ ) 0.667( 0.667) 6
Lecture Outlie Iferece for a Proortio (oe-samle) Iferece for Two Proortios (two-samles) Cotigecy Tables ad the χ test 7
Eyewear-by-sex as a cotigecy table A cotigecy table (show below) is a quick way to rereset how two categorical variables occur together. Its just a table of couts of the umber of observatios that fall i the itersectio of the two variables. For examle, we had 7 observatios that were female (sex == F ) ad did ot wear eyewear (glasses == 0 ).. tabulate glasses sex sex glasses F M Total -----------+----------------------+---------- 0 7 9 4 4 8 -----------+----------------------+---------- Total 6 47 Note: The `ooled estimate of is ˆ = 8/47 = 0.673 8
Eyewear-by-sex as a cotigecy table (Exected values uder H 0 ) I the two roortio test for this data, we were testig the ull hyothesis of H 0 : M = W. What does that mea for the cotigecy table below? What would be the exected cell couts if the roortio of idividuals that use corrective eyewear was costat across the sexes (aka, glasses is uassociated with sex)? If ˆ = 0.5957, the we d exect 0.5957* =.5 of the females to wear corrective eyewear.. tabulate glasses sex, cell Sex glasses F M Total -----------+----------------------+---------- 0 8.49 0.5 9.5 5.49 8 -----------+----------------------+---------- Total 6 47 9
Cotigecy Tables More formally, use the followig formula to comute the exected values: Exected cell cout row total colum total A formal test of the ull hyothesis of o associatio betwee row ad colum variables (both categorical, i this case sex ad eyewear status) is costructed by comarig the observed cell values to their exected values uder H 0. Ay large differeces betwee these would be evidece agaist H 0. This leads to the chi-squared (χ ) test. 0
To test the hyotheses: The Chi-squared test H 0 : rows ad colums are ideedet H A : rows ad colums are deedet We calculate the chi-squared test from the observed ad exected cell couts as such: (observed exected) all cells exected This χ test has degrees of freedom df = (#rows ) x (#cols ). Note: there ca be more tha rows or colums (categories) The -value ca be determied by lookig u i the χ table i the aedix of the textbook Eve though this is a two-sided alterative (do t kow the directio of associatio), we oly use oe-tail of the distributio for the -value (sice we square the umerator)
Corrective Eyewear ad Sex χ test solutio H 0 : Sex ad wearig corrective eyewear are ot associated H A : Sex ad wearig corrective eyewear are associated α = 0.05 all cells (observed exected) exected (7 8.49) ( 0.5) (4.5) 8.49 0.5.5 0.6 0. 0.77 0.43 0.793 (4 5.49) 5.49 This χ statistic has df = ( ) x ( ) =. The -value is the: -value > 0.5. We do ot have eough evidece to reject the ull hyothesis. Wearig corrective eyewear does ot seem to be deedet o sex. 3
Some fial oits The chi-square test for ideedece i a cotigecy table is iheretly a two-sided test, eve though we are usig the area uder the chi-square desity fuctio i the right tail. Whe there are two grous ad two categories, the chi-square test ad the test for differeces i two oulatio roortios coicide: df (z) 0.793 ( 0.89) I order for this χ test to be valid, we eed all the exected cell couts to be 5. 4
Examle with more categories What about: is hair color associated with corrective eyewear?. tabulate hair glasses if hair!= "red" & hair!= "gray", chi glasses hair 0 Total -----------+----------------------+---------- black 6 3 9 blode 5 7 brow 7 8 -----------+----------------------+---------- Total 8 6 44 Pearso chi() = 3.48 Pr = 0.8 5
Take Home Message We have leared the followig classical hyothesis tests (ad related cofidece itervals): Oe-samle t-test for a mea (ad the z-test if σ is kow) Paired t-test for meas Two-samle t-test for meas ooled vs. uooled Oe-samle z-test for a roortio Two-samle z-test for roortios χ test for associatio of two categorical variables Note: I the roortios settigs, the formulas for the stadard errors are a little differet i the cofidece itervals vs. the hyothesis tests. 6
Take Home Message (cot.) The key to all these tests is kowig whe to aly each oe. The differece is if the measuremets are quatitative/cotiuous, you ll be doig rocedures for meas, ad if the measuremets are categorical (success/failure or yes/o or 0/) or the summary statistic is a cout or roortio, you ll be doig rocedures for roortios. If there are more tha two categories (or more tha two grous), you will eed to do the χ test. Make sure you are aware of assumtios for each (like how the t-test goes awry whe is small ad there are outliers, ad the roortio test eeds 0 ad ( ) 0, etc ) But you also have to kee track if there are oe samle or two samles (or more tha two samles) Next slides lays out the framework for all the iferetial rocedures we ve leared so far (ad the oes to come) 7
Road Ma to Iferece i Stat S00 σ kow Iferece for μ (z-based) grou σ ukow (use s) Iferece for μ (t-based) Ideedet grous σ = σ Pooled t-rocedure Quatitative Data grous σ σ No-ooled t-rocedure Paired grous Paired t-rocedure or more grous Regressio w/ Biary Predictors Oe Predictor Simle liear regressio Quatitative redictor(s) + Predictor(s) Multile regressio Start Here! grou Iferece for Biary Data (yes/o) grous Iferece for or more grous χ test for associatio Quatitative redictor(s) Logistic Regressio* Categorical Data (+ categories) or more grous 8 χ test for associatio