56
Day 2, Evening: Univariate Tests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall [email protected] marshalltaylor.net

Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall [email protected]

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Day2,Evening:Univariate TestsofStatistical

InferenceInstructor:MarshallA.Taylor

[email protected]

Page 2: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Recap• Thismorningwetalkedabouthowtheasymptotictheoryofprobabilitydistributionsallowsustoassesshowrepresentativeoursampledistributionisofthepopulationdistribution.

• Wespecificallylookedathowwecanquantifythestandarddeviationofthesamplingdistributionofsamplemeans(thestandarderror),whichissmallerwhenwehavelargersamplessizes.Thesmallerthestandarderror,themorereliableourestimates—assumingthesamplingdistributionisnormalpertheCLT.

Page 3: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Recap

• Wethenusedthestandarderrorandourassumptionsofthesamplingdistributiontocreateconfidenceintervalsaroundthepopulationmean.

• Finally,wetalkedaboutz-scores—whichtransformanobservation’svalueonx sowecanseehowmanystandarddeviationsitisfromthevariablemean.

Page 4: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Butwhataboutrandomchance?• Standarderrorsandconfidenceintervalsaroundthemeangiveusagenerallyideaofhowefficientoursamplemeanmightbe.

• Buthowdewereallyknowwhetherornotoursamplemeanisduetosamplingerror?

• Forexample,ifoursamplemeanisdifferentfromaknownpopulationmean,howdoweknowwhetherornotthisdifferenceispotentiallyrealorjustaproductofrandomchance?

Page 5: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

HypothesisTesting• Answeringaquestionsuchasthisnecessitateshypothesistesting.

• Ahypothesis isastatementabouttheexpectedpropertyofavariableortherelationshipbetweenmultiplevariables.

• Wetest ahypothesisbycomparingtheseexpectationstoobserveddatatodeterminewhetherornottheseexpectedpropertiesorrelationshipsaregeneralizabletothetargetpopulation.

Page 6: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

HypothesisTesting

• Suchatestfirstrequiresstatingbothanullhypothesisandanalternativehypothesis.

• Anullhypothesis (denotedH0) isastatementthatistestedtodeterminewhetheritspremiseshouldbeacceptedorrejected.Instatistics,H0 istypicallythatthereisnostatisticallysignificantdifferencebetweentwonumbers.

Page 7: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

HypothesisTesting

• Suchatestfirstrequiresstatingbothanullhypothesisandanalternativehypothesis.

• Analternativehypothesis (denotedHA)isthehypothesisthatweeitherfindsupportforornotdependingonwhetherH0 isrejectedoraccepted.Thealternativehypothesisisoftenassimpleasthepropositionthatthereisastatisticallysignificantdifferencebetweentwonumbers.

Page 8: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

HypothesisTesting

• Forexample,ifwearecuriousifthehypothesizedmeanheightofNDundergrads(x) findssupportgivenameanfromarandomsampleofNDundergrads,thenournullhypothesiswouldbe:

H0 : µ = x

Page 9: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

HypothesisTesting• Ifwethinkthatthepopulationaverageisactuallytallerthantheonepreviouslyhypothesized,thenouralternativehypothesiswouldbe:

HA : µ > x

• Ifwethinkitisshorter,thenHA wouldbe:

HA : µ < x

Page 10: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

HypothesisTesting

• OrwemightbesatisfiedwiththeHA thatthepopulationaverageissimplydifferentformtheonehypothesized—regardlessoftheparticulardirectionofthedifference.Inthiscase,HA wouldbe:

HA : µ ≠ x

Page 11: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

HypothesisTesting

• Inhypothesistesting,wetestH0—not HA!– IfH0 isaccepted,thenwedonotfindsupportfor

HA assomethingthatishappeninginthepopulation.

– IfH0 isrejected,thenwedofindsupportforHA assomethingthatishappeninginthepopulation.

Page 12: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

HypothesisTesting

• SoweunderstandthisH0 andHA business.ButhowdowegoaboutactuallytestingH0?

• Forexample,howdoweknowwhetherornotthepopulationheightissignificantlydifferentfromtheonehypothesized?

Page 13: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Backtothetheory!

• Luckily,wehavetheCLTandthosecriticalvaluestohelpusoutagain!

• WecanusetheCLTtohelpusassesshowlikelywearetoobserveHA assumingthatH0 istrue.IfwearenotveryliketoobserveHA whenassumingH0 istrue,butweobserveitanyway,thenwerejectthepremiseofH0 andinsteadfindsupportforHA assomethingthatmaybehappeninginthepopulation.

Page 14: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Backtothetheory!

Thoughwehavetalkedaboutthesamplingdistributionofsamplemeansuptothispoint,theCLTactuallyholdsforanyrandomvariable—standarddeviations,differences,whatever!

Page 15: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Backtothetheory!

• Ifwewanttoknowwhetherornotasamplemeanisdifferentfromapopulationmean,thenweareinterestedinthedistributionofmeandifferences.

So,ifweknowthat95%ofsamplemeandifferencesfallwithin±1.96standarddeviationsofthe“real”meandifference(whichwewillassumetobe0),then,bywayofthecomplementsrule,wealsoknowthat5%donot.Soifourobservedsamplemeandifferencefallsabove1.96orbelow–1.96,thenwerejectH0 becausethereislessthana5%chancethatwewouldobserveoursamplemeandifferenceifH0 weretrue.

Page 16: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSamplet-test• Thinkbacktoourheightexample.Let’ssaythemeanheightinoursampleis67inches(about5’6”).Nowlet’shypothesizethemeanheightofpopulationtobe63inches(about5’4”).Thereareelevenofyou,andlet’ssaythesamplestandarddeviationis3inches.

• OurH0 wouldbethatthereisnodifference betweenthetwomeans(H0 : µ = 63).

• OurHA wouldbethat thepopulationheightistallerthantheonehypothesized(HA : µ > 63).

Page 17: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSamplet-test• Weonlyhaveonesamplestatisticthatweareworkingwith:themeanheightinthesample.Assuch,wecantestournullhypothesisusingwhatisreferredtoasaonesamplet-test.

• Further,sincewearehypothesizingthatthedifferenceisinaparticulardirection,wesaythatthisisaone-tailedtest.Ifwewerenothypothesizingaparticulardirectionforthedifference,thiswouldbeatwo-tailedtest.

Page 18: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSamplet-test

• Theonesamplet-testdirectlyassessesourH0thatthereisnostatisticallysignificantdifferencebytakingthedifferencebetweenthesampleandpopulationmeanandscalingthisvaluebythestandarderror:

• Theresultiswhatisreferredtoasthetstatistic.

Page 19: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSamplet-test

• Thisstatisticisourteststatistic.Butwhatdowedowithitoncewe’vegotit?

Page 20: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSamplet-test• Wehavetocompareourteststatistic(at-statistic,inthiscase)to

thecriticalvalueassociatedwithourdesiredconfidencelevelinwhatiscalledthet-distribution (whichisverysimilartoanormaldistribution,but“penalizes”youforhavingsmallsamplesizesandthereforefewerdegreesoffreedom).

• Solet’ssaythatweonlywanttohavea.05probabilityofbeingwrong.Thecriticalt-valueassociatedwiththis(one-tailed)probability,giventhatwehave10degreesoffreedom(11– 1),is1.81.

• BTW:This“.05probabilityofbeingwrong”isknownasoursignificancelevel,alsoknownasthealphalevel(α).

Page 21: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSamplet-test

Ifourteststatisticfallsabove1.81,thenwecanrejectH0 becauseourstatisticdoesnotfallwithinthebottom95%ofthenormaldistributionifweassumethe“real”meandifferenceis0!

Page 22: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSamplet-test• IfwecouldrejectH0,thenourteststatistic(thet statistic,in

thiscase)wouldfallintotherighttailofdistribution,asshownbelow(withthedifferencebeingthatthecriticalvalueis1.64asopposedto1.81).

*ImagefromPsychStatisticswebsite(http://www.psychstatistics.com/2010/11/24/stata-graphing-distributions/).

Page 23: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSamplet-test

• Solet’scrunchthenumbersforourheightexample:

Page 24: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSamplet-test• Ourteststatisticis4.42.Thisismuchlargerthan1.81.

• Assuch,wecanrejectthenullhypothesis—atthe.05level—thatthehypothesizedpopulationmeanheightis63inches.Maybeweshouldthereforereconsiderthe“real”valueofthepopulationmean(i.e.,allNDundergrads).

• Ifweareabsolutelysurethatthepopulationmeanheightis63inches,thenwecanatleastsaythatitisveryunlikelythatoursamplemeancamefromapopulationwithameanof63.Perhapsoursampleisnotentirelyrandom,ormaybewejustgotabadsample.

Page 25: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSamplet-test

• ConfirmwithStata:

.

Pr(T < t) = 0.9994 Pr(|T| > |t|) = 0.0013 Pr(T > t) = 0.0006 Ha: mean < 63 Ha: mean != 63 Ha: mean > 63

Ho: mean = 63 degrees of freedom = 10 mean = mean(x) t = 4.4222 x 11 67 .904534 3 64.98457 69.01543 Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] One-sample t test

. ttesti 11 67 3 63, level(95)

Page 26: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Let’stryanotherone• Arandomsampleoffivecongressionalcandidatesfrom

2006raised,onaverage,$1,964,018.Nowlet’ssaythattheaveragefundsraisedacrossallcongressionalcandidatesinthecountryin2006washypothesizedtobe$5,000,000.*Further,thesamplecandidatesvaryfromtheirmeanof$1,964,018byabout$925,149.Atα =.05,howlikelyisitthatourhypothesizedmeanvaluereflectsthepopulationparameter(regardlessofdirection)?

• Tip:thecriticalt-valuewithfourdegreesoffreedom(5candidates– 1)is±2.776.

*Madeupnumber.

Page 27: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Let’stryanotherone• Firststateyournullhypothesis:

H0 : µ = $5,000,000

• Thenthealternativehypothesisthattheyaredifferent:

HA : µ ≠ $5,000,000

• Thisisatwo-tailedtest,sincewearenotassumingaparticulardirection ofthedifference.Thusthe≠ ratherthanthe< or>!

Page 28: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Let’stryanotherone

• Specifically,werejectH0 ifourteststatisticfallsabove2.776orbelow–2.776,asillustratedbytheshadedregionsinthedistributionbelow:

FigurecreatedusingStudent’st-distributionappletattheUniversityofIowa(http://homepage.divms.uiowa.edu/~mbognar/applets/t.html).

Page 29: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Let’stryanotherone

• Rememberourformula:

• So:

Page 30: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Let’stryanotherone• Ourteststatisticis–7.338.Thisissmallerthanourcriticalvalue,–

2.776.

• So,atthe.05significancelevel,werejectthenullhypothesis thatthepopulationmeanfundsraisedis$5,000,000.

• Instead,wefindstatisticalsupportforouralternativehypothesisthatthepopulationmeanfundsraisedisnot $5,000,000.

• Ifwearesurethatthepopulationmeanis$5,000,000(i.e.,itismorethanahypothesizedmean),thenwecanatleastsaythatitisveryunlikelythatoursamplemeancouldhavecomefromapopulationwithameanof$5,000,000.

Page 31: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Let’stryanotherone

• Nowlet’ssaywewantedtoknowifthedifferenceissignificantinaparticulardirection.Specifically,wewanttoknowifthepopulationmeanissmallerthantheonehypothesized.

• Inthiscase:HA : µ < $5,000,000

Page 32: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Let’stryanotherone• Ournewcriticalvalueis–2.132.Thisvalueissmallerthanthe

onefromourtwo-tailedtest,meaningthatwehavemorepowertorejecttheH0 (becausetheshadedregionisbigger).However,itcomesattheexpenseofnotbeingabletodetectsignificantteststatisticsattheotherendofthedistribution.

FigurecreatedusingStudent’st-distributionappletattheUniversityofIowa(http://homepage.divms.uiowa.edu/~mbognar/applets/t.html).

Page 33: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Let’stryanotherone

• So–7.338issmallerthanourcriticalvalueof–2.132.

• WecanonceagainrejecttheH0.

• However,wecannowsaythatitislikely(atthe.05significancelevel)thattherealpopulationmeansislessthanthehypothesizedpopulationmean.

Page 34: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

ButletStata dothework!

• Luckily,Stata canhandlethis.

. univar FRAISED if Y2006==1 & STATE2==14

Pr(T < t) = 0.0009 Pr(|T| > |t|) = 0.0018 Pr(T > t) = 0.9991 Ha: mean < 5000000 Ha: mean != 5000000 Ha: mean > 5000000

Ho: mean = 5000000 degrees of freedom = 4 mean = mean(FRAISED) t = -7.3379 FRAISED 5 1964018 413739.2 925149 815293.9 3112742 Variable Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] One-sample t test

. ttest FRAISED==5000000 if Y2006==1 & STATE2==14

Page 35: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

ButletStata dothework!

• Luckily,Stata canhandlethis.

. univar FRAISED if Y2006==1 & STATE2==14

Pr(T < t) = 0.0009 Pr(|T| > |t|) = 0.0018 Pr(T > t) = 0.9991 Ha: mean < 5000000 Ha: mean != 5000000 Ha: mean > 5000000

Ho: mean = 5000000 degrees of freedom = 4 mean = mean(FRAISED) t = -7.3379 FRAISED 5 1964018 413739.2 925149 815293.9 3112742 Variable Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] One-sample t test

. ttest FRAISED==5000000 if Y2006==1 & STATE2==14

Wegotourteststatisticcorrect.

Page 36: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

ButletStata dothework!

• Luckily,Stata canhandlethis.

. univar FRAISED if Y2006==1 & STATE2==14

Pr(T < t) = 0.0009 Pr(|T| > |t|) = 0.0018 Pr(T > t) = 0.9991 Ha: mean < 5000000 Ha: mean != 5000000 Ha: mean > 5000000

Ho: mean = 5000000 degrees of freedom = 4 mean = mean(FRAISED) t = -7.3379 FRAISED 5 1964018 413739.2 925149 815293.9 3112742 Variable Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] One-sample t test

. ttest FRAISED==5000000 if Y2006==1 & STATE2==14

Andbothourtwo-tailedandone-tailedtestswerecorrect.Thep-valuefortheone-tailedtesttellsusthatthereisonlya.09%chancethatoursamplemeanwoulddifferbyatleastthismuchfromthepopulationwhenweassumethatthe“real”meandifferenceiszero.

Page 37: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

ButletStata dothework!

• Luckily,Stata canhandlethis.

. univar FRAISED if Y2006==1 & STATE2==14

Pr(T < t) = 0.0009 Pr(|T| > |t|) = 0.0018 Pr(T > t) = 0.9991 Ha: mean < 5000000 Ha: mean != 5000000 Ha: mean > 5000000

Ho: mean = 5000000 degrees of freedom = 4 mean = mean(FRAISED) t = -7.3379 FRAISED 5 1964018 413739.2 925149 815293.9 3112742 Variable Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] One-sample t test

. ttest FRAISED==5000000 if Y2006==1 & STATE2==14

Butnoticeourone-tailedtestintheotherdirectionwouldhavegivenusanon-significantresult.

Page 38: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Othertests• Butsometimesweneedtoteststatisticsotherthanmeans.Remember,meansaren’talwaysanappropriatemeasureofcentraltendency!

• Sometimeswehaveavariablethatcanonlytakeontwocategories.Inthiscase,wecanusetheonesampledifference-of-proportionstest.

• Othertimesthemedianisabettermeasureofcentraltendency.Inthiscase,wecanusetheonesample signtest.

Page 39: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

OneSampleDifference-of-ProportionsTest

• Verysimilartotheonesamplet-test,butforadichotomousvariableinsteadofamean.

• Theteststatisticcanbefoundwith:

• Noticetheteststatisticisaz-statisticinsteadofat-statistic.Thissimplymeansthatweareassumingasamplingdistributionthatfollowsanormaldistributioninsteadofat-distribution(which,withalargeenoughsample,convergetoessentiallybesamething).

Page 40: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSampleDifference-of-ProportionsTest

• Alandlordatabusydowntownapartmentbuildingtookapollandfoundthatonly3%ofresidentsareinfavorofrequiringparkingpasses.Youquestionthelandlord’sconclusionandtakearandomsampleof50residents.Youfindthat,amongtheseresidents,23areinfavorofrequiringparkingpasses—46%ofyoursample.Howvalidisthelandlord’sconclusion,assumingthatyouareonlywillingtobewrong5%ofthetime?

Page 41: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSampleDifference-of-ProportionsTest

• Ournullhypothesis:

H0 : µ = .03

• Ifwetakeonaone-tailedtest,ouralternativehypothesiswouldbe:

HA : µ > .03

.

Page 42: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSampleDifference-of-ProportionsTest

• Ourcriticalz-valueis1.645.Wechoosethisvalueinsteadof±1.96becauseweareperformingaone-tailedtest.So,insteadofrejectingH0 ifourteststatisticfallswithinthetopandbottom2.5%ofthenormaldistribution(bottomleftplot),welookatthetop5%only(bottomrightplot).

.

*FiguremadewithNormalDistributionCalculatoratOnlineStatsbook(http://onlinestatbook.com/2/calculators/normal_dist.html).

Page 43: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:TheOneSampleDifference-of-ProportionsTest

• Nowlet’sdothemath:

• Ourteststatisticismuchlargerthanourcriticalvalueof1.645.Assuch,thereislessthana5%chancethatwewouldfind46%of50residentsinfavorofparkingpassesifitweretruethatonly3%oftotalresidentswereinfavorofparkingpasses.Weconcludethatmoreresidentsareinfavorofthispolicyatthe.05significancelevel.

.

Page 44: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AStata Example• Weknowthat52%ofoursampleofHousecandidatesin2006“wentnegative”—thatis,theyengagedinnegativecampaigningagainsttheiropponent.Let’ssay(hypothetically)thatpreviousstudiessuggestthat,onaverageandacrosstime,Housecandidatesgonegativeabout55%ofthetime.Ifoursampleconsistsof227candidatesandisindeedarepresentativerandomsampleofHousecandidatesacrosstime,canwesaythatHousecandidatesactuallygonegativelessthan55%ofthetime?

Page 45: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AStata Example

• Wecannotrejectthenullhypothesisatthe.05levelthatHousecandidates,onaverageandacrosstime,gonegative55%ofthetime.

. display (.5242291-.55)/sqrt((.55(1-.55))/227)

Pr(Z < z) = 0.2176 Pr(|Z| > |z|) = 0.4351 Pr(Z > z) = 0.7824 Ha: p < 0.55 Ha: p != 0.55 Ha: p > 0.55

Ho: p = 0.55 p = proportion(GONEG) z = -0.7805 GONEG .5242291 .0331472 .4592618 .5891964 Variable Mean Std. Err. [95% Conf. Interval] One-sample test of proportion GONEG: Number of obs = 227

. prtest GONEG==.55 if Y2006==1 & SENATE==0

Page 46: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

OneSampleSignTest

• Sometimesthemedianisthemostefficientmeasureofcentraltendency.– Perhapsthevariableisordinal.– Ormaybeitisacontinuousvariablebutskewedbecauseofoutliers.

• Inthiscaseourbestunivariate testofstatisticalinferenceistheonesamplesigntest.

Page 47: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

OneSampleSignTest

• Theteststatisticforthistestis(1)inthecaseofone-sidedtests,thenumberofpositiveornegativedifferencesbetweentheobservedvaluesandthehypothesizedmedianvalue,or(2)inthecaseoftwo-sidedtests,thesmallerofthesetwodifferences.Ineithercase,thenumberofpositive(P)differencesandnegative(N) differencesiscalculatedwithΣxi– m0.Theyarethensortedbasedonthesignofthedifference.

Page 48: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

OneSampleSignTest• Thenullhypothesisforthistestisthatthereisno

statisticallysignificantdifferencebetweenthesamplemedianandthehypothesizedmedian(H0 : m = m0).

• Thetwo-tailedalternativehypothesiswouldbe:

HA : m ≠ m0

• Withone-tailedtests,theHA canbeoneof:

HA : m > m0HA : m < m0

Page 49: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

OneSampleSignTest• Wethencalculatetheprobabilityofobservingthedifferences(d) thatwedoundertheassumptionthatthe“real”differenceis0:

– Wheren isthesamplesizeminus“ties”andp istheprobabilityofobservingeitherapositiveornegativedifferencewhenthedifferencebetweenthesamplemedianandhypothesizedmedianisassumedtobe0—thatis,p =.5,sincewearejustaslikelytoobserveeitherkindofdifference.

Page 50: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:OneSampleSignTest

• Ninestudentsaresurveyedtoassesshowmuchtheyenjoythequalityoftheirschoolfood.TheyaregivenaLikert scalethatrangesbetween1(verybad)to5(verygood).Theobservedscoresare1,3,5,4,2,3,3,4,and5.Previoussurveyssuggestthatthemedianratingforfoodqualityamongstudentsis4(fairlygood).Dowehavesufficientevidencetoinferthatstudentsnowratethefoodqualitymorepoorly?

Page 51: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:OneSampleSignTest

• First,wefindthenumberofpositiveandnegativedifferences:

Observed m0 Difference1 4 -33 4 -15 4 14 4 02 4 -23 4 -13 4 -14 4 05 4 1

5negatives

2positives

2ties(0s)

Page 52: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:OneSampleSignTest

• Weareinterestedifstudentsratefoodqualitymorepoorly,sothisisaone-tailedtestandwefocusonthenegativedifferences(d =5):

• Thenumber.164representstheprobabilitythatwewouldobservethismanynegativedifferencesifthemedianswereequal.

Page 53: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

AnExample:OneSampleSignTest• Wethenrepeatthisproceduretoobtaintheprobabilitiesforgetting6,7,8,and9negativedifferences.

• Afterdoingthisweadduptheprobabilities:.227.

• Thisismuchlargerthanourcut-offvalueof.05,sowecannotrejectthenullhypothesisthatthereisnostatisticallysignificantdifferencebetweenoursamplemedianandthehypothesizedmedian.Giventhesedata,wecannotsaythatstudentsnowratetheirschoolfoodqualityanylowerthantheyusedto.

Page 54: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

YayforStata!

min(1, 2*Binomial(n = 7, x >= 5, p = 0.5)) = 0.4531 Pr(#positive >= 5 or #negative >= 5) = Ha: median of var1 - 4 != 0 Ho: median of var1 - 4 = 0 vs.Two-sided test:

Binomial(n = 7, x >= 5, p = 0.5) = 0.2266 Pr(#negative >= 5) = Ha: median of var1 - 4 < 0 Ho: median of var1 - 4 = 0 vs.

Binomial(n = 7, x >= 2, p = 0.5) = 0.9375 Pr(#positive >= 2) = Ha: median of var1 - 4 > 0 Ho: median of var1 - 4 = 0 vs.One-sided tests:

all 9 9 zero 2 2 negative 5 3.5 positive 2 3.5 sign observed expected

Sign test

. signtest var1=4

Page 55: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

Conclusion• Ourknowledgeofsamplingdistributionsiswhatallowsus

togetagrasponthelikelihoodthatoursampleestimatesare“generalizable”tothetargetpopulationorduetosamplingerror(randomchance).

• Wemaketheseinferencesthroughhypothesistesting.

• Weexploredavarietyofunivariate inferentialtests.Theyareunivariate becausewecomparejustonesampleestimatetohypothesizedpopulationparameters.

• Tomorrowwestartlookingatbivariateinferentialtests;i.e.,comparisonsbetweentwosampleestimates.

Page 56: Day 2, Evening: UnivariateTests of Statistical Inference · Day 2, Evening: UnivariateTests of Statistical Inference Instructor: Marshall A. Taylor 844 Flanner Hall mtaylo15@nd.edu

DatasetsUsed• Druckman,James,MichaelParkin,andMartinKifer.2013.CongressionalCandidateWebsites.ICPSR-34895-v1.AnnArbor,MI:Inter-UniversityConsortiumforPoliticalandSocialResearch.RetrievedFebruary10,2015(http://doi.org/10.3886/ICPSR34895.v1).

• TheStata surveydocumentationdata,nhanes2f,fromtheStata Presswebsite.RetrievedJuly24,2016(http://www.stata-press.com/data/r11/svy.html).