<<

ONGOODNESSOFFITOF

LOGISTICREGRESSIONMODEL

by YINGLIU M.S.,UniversityofRhodeIsland,2003 M.S.,HenanNormalUniversity,2000 ANABSTRACTOFADISSERTATION submittedinpartialfulfillmentoftherequirementsforthedegree DOCTOROFPHILOSOPHY Departmentof CollegeofArtsandSciences KANSASSTATEUNIVERSITY Manhattan,Kansas 2007

Abstract

Logisticregressionmodelisabranchofthegeneralizedlinearmodelsandis widelyusedinmanyareasofscientificresearch.Thelogitlinkfunctionandthebinary dependentvariableofinterestmakethelogisticregressionmodeldistinctfromlinear regressionmodel. Theconclusiondrawnfromafittedlogisticregressionmodelcouldbeincorrector misleadingwhenthecovariatescannotexplainand/orpredicttheresponsevariable accuratelybasedonthefittedmodelthatis,lackoffitispresentinthefittedlogistic regressionmodel. Thecurrentgoodnessoffittestscanberoughlycategorizedintofourtypes.(1) Thetestsarebasedoncovariatepatterns,e.g.,Pearson’sChisquaretest,D test,andOsiusandRojek’snormalapproximationtest.(2)HosmerLemeshow’s Ĉand HosmerLemeshow’s Ĥtestsarebasedontheestimatedprobabilities.(3)Scoretests arebasedonthecomparisonoftwomodels,wheretheassumedlogisticregression modelisembeddedintoamoregeneralparametricfamilyofmodels,e.g.,Stukel’s ScoretestandTsiatis’stest.(4)SmoothedresidualtestsincludeleCessieandvan Howelingen’stestandHosmerandLemeshow’stest.Allofthemhaveadvantagesand disadvantages. Inthisdissertation,weproposedapartitionlogisticregressionmodelwhichcan beviewedasageneralizedlogisticregressionmodel,sinceitincludesthelogistic regressionmodelasaspecialcase.Thispartitionmodelisusedtoconstructgoodness offittestforalogisticregressionmodelwhichcanalsoidentifythenatureoflackoffitis duetothetailormiddlepartoftheprobabilitiesofsuccess.Severalsimulationresults showedthattheproposedtestperformsaswellasorbetterthanmanyoftheknown tests.

ONGOODNESSOFFITOF

LOGISTICREGRESSIONMODEL

by YINGLIU M.S.,UniversityofRhodeIsland,2003 M.S.,HenanNormalUniversity,2000 ADISSERTATION submittedinpartialfulfillmentoftherequirementsforthedegree DOCTOROFPHILOSOPHY DepartmentofStatistics CollegeofArtsandSciences KANSASSTATEUNIVERSITY Manhattan,Kansas 2007 Approvedby: MajorProfessor ShieshienYang

Abstract

Logisticregressionmodelisabranchofthegeneralizedlinearmodelsandis widelyusedinmanyareasofscientificresearch.Thelogitlinkfunctionandthebinary dependentvariableofinterestmakethelogisticregressionmodeldistinctfromthelinear regressionmodel. Theconclusiondrawnfromafittedlogisticregressionmodelcouldbeincorrector misleadingwhenthecovariatescannotexplainand/orpredicttheresponsevariable accuratelybasedonthefittedmodelthatis,lackoffitispresentinthefittedlogistic regressionmodel. Thecurrentgoodnessoffittestscanberoughlycategorizedintofourtypes.(1) Thetestsarebasedoncovariatepatterns,e.g.,Pearson’sChisquaretest,DevianceD test,andOsiusandRojek’snormalapproximationtest.(2)HosmerLemeshow’s Ĉand HosmerLemeshow’s Ĥtestsarebasedontheestimatedprobabilities.(3)Scoretests arebasedonthecomparisonoftwomodels,wheretheassumedlogisticregression modelisembeddedintoamoregeneralparametricfamilyofmodels,e.g.,Stukel’s ScoretestandTsiatis’stest.(4)SmoothedresidualtestsincludeleCessieandvan Howelingen’stestandHosmerandLemeshow’stest.Allofthemhaveadvantagesand disadvantages. Inthisdissertation,weproposedapartitionlogisticregressionmodelwhichcan beviewedasageneralizedlogisticregressionmodel,sinceitincludesthelogistic regressionmodelasaspecialcase.Thispartitionmodelisusedtoconstructgoodness offittestforalogisticregressionmodelwhichcanalsoidentifythenatureoflackoffitis duetothetailormiddlepartoftheprobabilitiesofsuccess.Severalsimulationresults showedthattheproposedtestperformsaswellasorbetterthanmanyoftheknown tests.

TableofContents

ListofFigures ...... vii ListofTables ...... viii Acknowledgements ...... x CHAPTER1Introduction ...... 1 1.1 BasicConceptsonLogisticRegressionModel ...... 1 1.2 TheGoodnessofFitTestforLogisticRegressionModel ...... 8 CHAPTER2LiteratureReview ...... 16

2 2.1PearsonChisquare χ TestandDevianceDTest ...... 18 2.2TheHosmerandLemeshowTests ...... 24 2.2.1HosmerandLemeshow’s Cˆ ...... 24 2.2.2HosmerandLemeshow Hˆ ...... 26 2.3OsiusandRojekNormalApproximationTest ...... 28 2.4Stukel’sScoreTest ...... 30 2.5.AnIllustrativeExample ...... 33 CHAPTER3TheProposedMethod ...... 36 3.1DescriptionoftheProposedTest ...... 38 3.2TheFirstExample ...... 43 3.3TheSecondExample ...... 46 3.4TheThirdExample ...... 53 3.5TheFourthExample ...... 55 CHAPTER4SimulationStudy ...... 61 4.1TheFirstSimulationStudy ...... 62 4.2TheSecondSimulationStudy ...... 68 4.3TheThirdSimulationStudy ...... 75 4.4TheFourthSimulationStudy ...... 80 4.5SummaryonSimulationStudies ...... 85 4.6ConvergenceProblemintheSimulationStudies ...... 86

v CHAPTER5Summary ...... 94 CHAPTER6ExtensionandFutureStudy ...... 96 CHAPTER7References ...... 97 AppendixAonORingFailure ...... 104 AppendixBDataonVasoconstriction ...... 105 AppendixCDataonLeukemiaSurvival ...... 107 AppendixDBeetleDataSet ...... 109 AppendixEWarsawGirlData ...... 110 AppendixFDatasetForIllustrativeExample3 ...... 111 AppendixGDatasetforIllustrativeExample4 ...... 112 AppendixHSASProgramCodeforSimulationStudy ...... 113

vi

ListofFigures

Figure11EstimatedFailureProbabilityfromLogisticRegressionModelandProbability LinearModel ...... 7 Figure12ThreeDimensionalPlotonTransformedVasoconstrictionData ...... 11 Figure21thePlotof π (x) versus η(x) forStukel’sModel ...... 31 Figure31PlotofEstimatedprobabilitiesfromtheAssumedand ...... 45 Figure32theObservedProbabilityofMenstruatingonWarsawGirls ...... 46 Figure33thePlotofResidualversusAge ...... 47 Figure34ProbabilityversusAgeonWarsawGirlData ...... 51 Figure41PlotsofRejectionRateforStudyOne(n=100) ...... 65 Figure42PlotsofRejectionRateforStudyOne(n=200) ...... 66 Figure43PlotsofRejectionRateforStudyOne(n=500) ...... 66 Figure44PlotsofRejectionRateforStudyTwo(n=100) ...... 72 Figure45PlotsofRejectionRateforStudyTwo(n=200) ...... 72 Figure46PlotsofRejectionRateforStudyTwo(n=500) ...... 73 Figure47PlotsofRejectionRateforStudyThree(n=100) ...... 78 Figure48PlotsofRejectionRateforStudyThree(n=200) ...... 78 Figure49PlotsofRejectionRateforStudyThree(n=500) ...... 79 Figure410PlotsofRejectionRateforStudyFour(n=100) ...... 82 Figure411 PlotsofRejectionRateforStudyFour(n=200) ...... 83 Figure412 PlotsofRejectionRateforStudyFour(n=500) ...... 83 Figure413ScatterPlotSamplePointswithCompleteSeparationData ...... 90

vii

ListofTables

Table11LinkFunctionsfortheGeneralizedLinearModels ...... 3 Table12AComparisonofLinear&LogisticRegressionModels ...... 5 Table13InformationonCovariatesfromLogisticRegression ...... 9 Table14GoodnessofFitTest ...... 9 Table15ModelFitStatisticsfromLogisticRegressionModel ...... 10 Table16InformationonCovariatesfromLogisticRegression ...... 12 Table17ModelFitStatisticsfromLogisticRegressionwith ...... 12 Table18GoodnessofFitTestwithLogtransformation ...... 13 Table21theResultsofHosmerLemeshowĈTest ...... 26 Table22ParameterEstimatesofLeukemiaData ...... 33 Table23ResultfromSixGoodnessofFitTestsonLeukemiaData ...... 34 Table24GroupSchemeofHosmerLemeshow’s Cˆ testwithSASSoftware ...... 35 Table31SummaryTableforKnownandProposedTests ...... 42 Table32ResultsfromtheKnownandProposedMethodsforBeetleData ...... 43

Table33intervalofNumberofBeetlesKilledbyCS 2...... 44 Table34ResultsfromtheKnownforWarsawGirlsData ...... 47 Table35ResultsfromDifferentGroupingSchemesoftheProposedMethod ...... 49 Table36theParameterEstimatesforModelwithGroupingSchemeI ...... 50 Table37ModelFitStatisticsofModel3.6 ...... 50 Table38ObservedCountsandConfidenceInterval(AssumedModelandProposed Method)fortheWarsawGirlData ...... 52 Table39ResultsfromtheKnownandProposedMethodsforWomen’sRoleData ..... 53 Table310ResultsfromtheKnownTestsforCreditCardData ...... 55 Table311GoodnessoffitTestBasedonModel(3.8) ...... 56 Table312ParameterEstimatesofModel(3.8) ...... 57 Table313ModelFitStatisticsfromTwoCasesofModel(3.8)i=2 ...... 58 Table314ParameterEstimatesofModel(3.9) ...... 59

viii Table41ObservedTypeIErrorRateforSimulationStudyone ...... 63 Table42the95%ConfidenceIntervalfortheTypeIErrorRate ...... 64 Table43RejectionRatesfortheKnownandProposedTestsforStudyOne ...... 65 Table44ObservedTypeIErrorRateforSimulationStudyTwo ...... 69 Table45RejectionRatesfortheKnownandProposedTestsforStudyTwo ...... 71 Table46ObservedTypeIErrorRateforSimulationStudyThree ...... 76 Table47RejectionRatesfortheKnownandProposedTestsforStudyThree ...... 77 Table48ObservedTypeIErrorRateforSimulationStudyFour ...... 81 Table49RejectionRatesfortheKnownandProposedTestsforStudyFour ...... 82 Table410CompleteSeparationData ...... 89 Table411PartialLogisticIterationStepsPrintout ...... 91 Table412DispersionMatricesontheSelectedIterations ...... 92

ix

Acknowledgements

MyPhDstudyintheDepartmentofStatistics,KansasStateUniversitycould neverbefulfilledwithoutthefullsupportfrommymajoradvisor,myadvisorycommittee, thedepartmentoffice,myfriendsandmyfamily.Iwouldliketotakethisopportunityto thankallofthemfortheirsupport,inspiringguidance,helpfuldiscussion,beautiful friendshipandgenerouslove.

Iwouldliketoexpressmysinceregratitudetomymajorprofessorandmentor,

Dr.ShieshienYang,forhisconstantsupport,patience,andencouragementthroughout mystudyinglifeatKansasStateUniversity.Hissupportofmyresearchand extracurricularactivitieswereinvaluableinmakingmygraduateexperienceapositive andsuccessfulone.Withouthissupport,Iwouldnotcompletethislongjourney.

IwanttothankmygraduatecommitteememberDr.PaulI.Nelson,Dr.Susan

Brown,Dr.HaiyanWangfortheirwarmheartedhelp,support,andconstructive suggestions,throughoutmydoctoralprogramofstudyeitherthroughformalmeetingsor informalchat.

IwouldalsotakethisopportunitytothankDr.JohnE.Boyerforgivingmea chancetobeagraduateteachingassistant.LetmyappreciationsgotoDr.JohnE.

BoyerandDr.JimHigginsfortheirinfinitepatienceandgeneroushelpinmyteaching.

Thisteachingexperiencewillbethetreasureofmywholelife.

IwouldalsogivemythankstoallthefacultymembersintheDepartmentsof

Statisticsforsharingtheirknowledgewithme.WithspecialthankstoDr.Dallas,E.

x Johnsonforhisverynicehelp,infinitepatienceduringmystudying.Hisattitudetoward studentsandworkwillinfluencemeinthefuture.

Thefriendshipandsupportfromallthegraduatestudentsandthedepartment staffwillbekeptinmyheartfortherestofmylife.SpecialthankstomybestfriendsLin

XieandSuzhiWang,youmakemystudyinglifeatKstatecolorful.

Lastbutnottheleast,Iwouldliketogivemyspecialthankstomybeloved husbandandbestfriend,Dr.ZhiwuLiandanamazingdaughter,Yeleeya.Theirsupport throughoutthisprocessisimmeasurableandIwouldnotbewhereIamtodaywithout them,Iamforeverhumbledandgrateful.Iwouldalsothankmydearparents,brothers andsistersfortheirsupportduringmyoverseastudy.Theirloveisalwaysthe motivationtopursuemygoals.

xi CHAPTER1Introduction

1.1BasicConceptsonLogisticRegressionModel Generalizedlinearmodel(GLZ)isausefulgeneralizationofthegenerallinear model.InaGLZ,thedependentoroutcomevariableyisassumedtobegeneratedfrom aparticularprobabilitydistributionfunctionfromtheexponentialfamily.Generalized linearmodelsaredefinedbythreecomponents:

1.RandomComponents:theprobabilitydistributionfunction fforthedependent

variable y=(y 1,y 2,…,y n)’ isfromanexponentialfamilyofdistributions.

2.Systematiccomponent:alinearpredictor η= Xβ,wherethematrixXcontains

columnsofexplanatoryvariableswhichiscalledthedesignmatrix,βarethe

unknownparametersand η=(η1,η2,…ηn).

3.Alinkfunction gsuchthatE( y|X )= = g1(η),whichprovidesthelink

betweenthelinearpredictorandtheoftheprobabilitydistribution

functionfofy(McCullaghandNelder1989,Agresti1990).LetE(yi|x i)=i,

th i=1,2,…N.then xiisthei rowof X;theexplanatoryvariablesassociatedwith

th thei responsey ivectorofindependentvariables.

1 Generally,theexponentialfamilyofdistributionsforthedependentvariablesy aretheprobabilitydistributions,parameterizedby θand φ withdensityfunctions expressedintheform:

 yθ −b(θ )   +c( y,φ)  a(φ)  f (y;θ,φ) = e (1.1)

θisrelatedtothemeanofthedistributionwith E ( y | x ) = = b ' (θ ) .Φisthe dispersionparameter ,typicallyisknownandisusuallyrelatedtotheofthe distributionand Var ( y | x ) = b '' (θ )a (φ ) .Thefunctions a, b,and c,areknown.

Thegeneralizedlinearmodelscanbesummarizedinthefollowingtablewiththe followingcommonlyusedlinkfunctions(McCullaghandNelder,1989).

2

Table11LinkFunctionsfortheGeneralizedLinearModels

Distribution Name LinkFunction MeanFunction

Normal Identity xβ = = xβ

Exponential −1 −1 Inverse xβ = = (xβ ) Gamma

Poisson Log xβ = ln( ) = exp(xβ )

Binomial exp(xβ) Logit xβ = ln( ) = 1 − 1+ exp(xβ) Multinomial

Wheneachoftheresponsevariableofyisabinaryordichotomousoutcome

(takingononlyvalues0and1),thedistributionfunctionisgenerallychosentobethe

Bernoullidistribution.ThereareseverallinkfunctionsfortheBernoullidata.Theyare probitlink,logloglinkandcomplementarylogloglink,andlogitlinkfunction.Inthe generalizedlinearmodels,thelogisticlinkfunctionismostwidelyusedandthemodel withthistypeoflinkfunctioniscalledlogisticregressionmodel(NelderandWedderburn

1972)whichwasfirstsuggestedbyBerkson(1944),whoshowedthemodelcouldbe

3 fittedbyusingiterativelyweightedleastsquares.Thelogisticregressionmodelisused insocialandscientificfields(Dreisitletal.2005,Tanetal.2004,BedrickandHill1996).

Insomecases,theresponsevariableymayhavemorethantwooutcomes(Tabachnick andFidell1996).

Inordertosimplifythenotation,wedenotethequantity E(y | x) = π (x) asthe conditionalmeanofygiven xinthelogisticregressionmodelwhichisalsothe probabilityoftakingthevalue1.Thus,theprobabilityofytakingthevalue0is1π (x) .

Thelogittransformationiscentraltotheformulationofthelogisticregression

π (x) model.Itisassumedthatthelogoftheodds islinearlyrelatedtothe 1−π (x) covariates,thatis,

 π (x)  log  = logit(π (x)) = xβ (1.2) 1−π (x)

Thelogit, η= xβ,maybecontinuous,andmayfrom∞to+∞.

Thelogittransformationleadstothefollowingformoftheprobabilityofsuccess:

e xβ π (x) = (1.3) 1+ exβ

Tworequirementsforlogisticregressionarethattheobservationsare independentandbinary,andthatthelogitofunknownbinomialprobabilitiesislinearly relatedtothecovariates.Table12givesacomparisonofthestandardlinearregression modelwiththelogisticregressionmodel.

4 Table12AComparisonofLinear&LogisticRegressionModels

Linearregression Logisticregression

Model E(y) = β0 + β1x1 +...+ β p x p logit(π(x)) = β0 + β1x1 +...+ βp xp

Response Continuousvariable Binaryvariable

Covariates Continuous/ordiscrete Continuous/ordiscrete

Amountofexpected Amountofchangeoflog Meaningof changeintheresponsey oddsperunitchangeinthe coefficient perunitchangein covariates covariates

Linkfunction Identity Logit

Responsevariablesare Responsevariables Distribution independentandeachhasa areindependentandwith Bernoullidistributionwith assumptions constantvariance probabilityofeventdependent ofthecovariates

Whentheresponseisbinary,thelinearregressionmodel

E(y | x) = π (x) = α + x'β (1.4) isalsocalledlinearprobabilitymodel(Agresti1990).Thismodelbelongstogeneralized linearmodelwithidentitylinkfunction.Theprobability π (x) isassumedtofallbetween0 and1overafiniterangeofxvalues.However,someofestimatedprobabilitieswillfall outsidetherangeof0and1withthismodelstructure.

ORingfailuredata(AppendixA)willbeusedtoillustratethatlogisticregression modelismoresuitabletoexplaintheprobabilityoftheeventthanlinearprobability

5 model.ThespaceshuttleChallengeraccidentoccurredonJanuary28,1986.AnO ringthatwasusedtosealajointoftheboosterrocketsexperiencedthermaldistress.

TheRogersCommissionappointedbyPresidentR.Reagantofindthecauseofthe accident,foundthattheOringmaynotbesealedproperlyatlowtemperature.TheO ringfailuredataconsistof23preaccidentlaunchesofthespaceshuttle.Dalal,

Fowlkes,andHoadley(1989)discoveredthattheOringsealingfunctionunderthe lauchingconditionsisaffectedbythelowtemperaturesbyusingthelogisticregression model.ThisdatasetwasalsoanalyzedbyLavine(1991)andMartzandZimmer(1992) usinglogisticregressionmodel.TheChallenger(spaceshuttle)waslaunchedat differenttemperaturestostudywhethertheexplosionwasduetolowtemperature condition.Thelaunchesareviewedasindependenttrials.

Thegraph(Figure11)showthatthelikelihoodoffailuredecreaseswhenthe temperatureincreaseswiththelinearprobabilitymodelandlogisticregressionmodel.

Forthelogisticregressionmodel,alltheestimatedprobabilitiesfallbetween0and1.

However,forthelinearprobabilitymodel,someofestimatedprobabilitiesarelessthan

0.Obviously,thelogisticregressionmodelmakesmoresensethanthelinearprobability modeldoesforthisdataset.

6

Figure11EstimatedFailureProbabilityfromLogisticRegressionModeland ProbabilityLinearModel

Thereddotsaretheestimateprobabilitiesfromthelogisticregressionmodel, andthebluetrianglesaretheestimateprobabilitiesfromthelinearprobabilitymodel.

7

1.2TheGoodnessofFitTestforLogisticRegressionModel Thegoaloflogisticregressionmodelsisusedtomodeltheprobabilityofthe occurrenceofaneventdependingonthevalueofcovariates x.Themodelisofthe followingform:

e(Xβ) Pr( y = |1 x) = π (x) = (1.4) 1+ e(Xβ)

Inotherwords,wewanttofindamodelthatfitstheobserveddatawell.Amodelissaid tofitpoorlyifthemodel’sresidualvariationislargeandsystematic(Hosmeretal,1997).

Thisisusuallythecasewhentheestimatedvaluesproducedbythelogisticregression modeldonotaccuratelyreflecttheobservedvalues.Therearemanywaysthatcause thelogisticregressionmodeltofitthedatainadequately,Themostimportantofwhich involvestheproblemwiththelinearcomponent(Collett,1991),suchas,omissionof higherordertermsofcovariates,orimportantcovariatesrelatedtotheresponse variablesfromthemodel.Influentialobservationsandoutlierscanalsoleadtoapoorfit.

Goodnessoffitorlackoffittestsaredesignedtodetermineformallythe adequacyorinadequacyofthefittedlogisticregressionmodel.Apoorlyfittedmodelcan givebiasedorinvalidconclusionsonthestatisticalinferencebasedonthefittedmodel.

Therefore,wemusttestthelackoffitofamodelbeforewecanuseittomake inferences.

8 Next,wewillusearealdatasettoillustratetheimportanceofassessingthe adequacyofamodel.VasoconstrictiondataisfromFinney(1941)andPregibon(1981).

Thisdata(AppendixB)consistofvariables,theoccurrenceofvasoconstrictioninthe skinofthefingers,therateandvolumeofairbreathed.Theendpointofeachtestwith

1indicatingthatconstrictionoccurred,0indicatingthatconstrictiondidnotoccur.Inthis controlled,39testsundervariouscombinationsofrateandvolumeofair inspiredwereobtained(Finney1941).AlogisticregressionusesVolumeandRateofair breathedascovariatestoexplainandpredicttheprobabilityofoccurrenceof vasoconstrictionintheskinofthefingers.

Table13InformationonCovariatesfromLogisticRegression

AnalysisofMaximumLikelihoodEstimates

Standard Wald Parameter DF Estimate Error ChiSquare Pr>ChiSq

Intercept 1 9.5293 3.2331 8.6873 0.0032

Rate 1 2.6490 0.9142 8.3966 0.0038

Volume 1 3.8820 1.4286 7.3844 0.0066

Table14GoodnessofFitTest

HosmerandLemeshowGoodnessofFitTest

ChiSquare Df Pr>ChiSq

19.1837 8 0.0139

9

Table15ModelFitStatisticsfromLogisticRegressionModel

ModelFitStatistics

Intercept Interceptand Criteria only Covariates

AIC 56.040 35.772

SC 57.703 40.763

2LogL 54.040 29.772

FromTable13,wemayconcludethatthesetwopredictorsdohavesignificant effectsontheoccurrenceprobabilityofthevasoconstrictionintheskinofthefingers, andwegetthefollowingmodel

logit(π (x)) = − .9 5293+ .2 6490*rate + .3 8820*volume (1.5)

ThegoodnessoffittestresultshowninTable14indicatesthepresenceoflackoffitin model(1.5).Therefore,model(1.5)maynotbereliableforustopredicttheprobability ofoccurrenceofvasoconstriction.Inordertogetasuitablemodel,ahigherorderor termmaybeneeded,orlatentpredictorsshouldbeinvestigatedinthis experiment.

ThenaturallogtransformationonRateandVolumewasusedtosearchforan adequatemodel.TheFigure12istheplotonthelogtransformeddata.

10 Figure12ThreeDimensionalPlotonTransformedVasoconstrictionData

Thestatisticalinferenceonthemodelparametersforthelogtransformationdata showninTable16suggeststhefollowingmodel

logit(π (x)) = − .2 8754+ .4 5617*log(rate) + .5 1793*log(volume) (1.6)

ItfitstheVasoconstrictiondatabetterthanmodel(1.5)basedontheresultofHosmer andLemeshowgoodnessoffittest(Table18).

AICandBICaretwousefulcriteriatoselectabettermodel.AkaikeInformation

Criterion(AIC)isproposedbyHirotsugeAkaike(Akaike,1974),whichisusually consideredasagoodcriteriontocompareseveralmodels. AIC = −2*ln L + 2*k ,where

L isthemaximizedvalueofthelikelihoodfunction,kisthenumberoftheparametersin themodel(Akaike,1974).BayesianInformationCriterion(BIC)isanotherimportant criterion,whichprovidesmoreparsimoniousmodelthanAICdoes.BIC(Bayesian informationcriterion)isalsocalledSICorSC(SchwarzinformationcriterionorSchwarz

11 criterion),becauseSchwarz(Schwarz1978)gaveaBayesianargumentonit.Inthe logisticregressionmodelselection, BIC = −2*ln L + k ln(n) ,where L isthemaximized valueofthelikelihoodfunction,Kisthenumberofparametersinthemodel,andnis thesamplesize.ThesmallertheAICand/orSCis,thebetterthemodelis.Model(1.6) isbetterthanmodel(1.5)basedonAICandSCfromTable15andTable17.

Table16InformationonCovariatesfromLogisticRegression withLogtransformation

AnalysisofMaximumLikelihoodEstimates

Standard Wald Parameter DF Estimate Error ChiSquare Pr>ChiSq

Intercept 1 2.8754 1.3208 4.7395 0.0295

Log_Rate 1 4.5617 1.8380 6.1597 0.0131

Log_Volume 1 5.1793 1.8648 7.7136 0.0055

Table17ModelFitStatisticsfromLogisticRegressionwith Logtransformation

ModelFitStatistics

Intercept Interceptand Criteria only Covariates

AIC 56.040 35.227

SC 57.703 40.218

2LogL 54.040 29.227

12 Table18GoodnessofFitTestwithLogtransformation

HosmerandLemeshowGoodnessofFitTest

ChiSquare Df Pr>ChiSq

11.0873 8 0.1986

Unlikethelinearregressionmodel,R2isnotasuitabletomeasurethepredictor powerofthemodelinlogisticregression,becausewecan'texplainthevariationina binarydependentvariablethesamewayaswedoforcontinuousdependentvariables.

InmanycasestheR2and/orpseudoR2aresmallevenwhenthemodelisadequate forthedata(HosmerandLemeshow,2000).Pearson’sclassicalChisquaretestand

Deviancetestarewellknown,andtheyworkverywellwhenthecovariatesare categorical.Whenoneormorecovariatesarecontinuous,thedisadvantagesof

PearsonchisquaretestandDeviancetestprovideincorrectpvalues.

Consequently,manygoodnessoffittestsoflogisticregressionmodelare developed.Forexample,theCˆ and Hˆ testsproposedbyHosmerandLemeshow

(1980and1982).PulksterisandRobinson(2002)alsoproposedtwoteststatistics dealingwiththesituationinwhichbothdiscreteandcontinuouscovariatesareinvolved inthelogisticregressionmodel.However,theirmethodscannothandlethesituation whenallthecovariatesarecontinuous.Brown(1982),Tsiatis(1980)andStukel(1988) proposedtestsderivedfromscoretest,respectively.Thesescoretestsaremainly designedtotestoverallgoodnessoffitforthelogisticregressionmodel.Osiusand

Rojek(1992)proposednormalgoodnessoffittestsformultinomialmodelswithmany

13 degreesoffreedom,whichcanbeappliedtothebinarycases.Thistestcanbeviewed asanextensionofPearsonChisquaretest.leCessieandvanHouwelingen(1991) proposedagoodnessoffittestbasedonthesmoothingoftheresidualstechniques proposedbyCopas(1983),Landwehretal(1984),Fowlkes(1987)andAzzalinietal.

(1989).Hosmeretal(1997)developedanothersmoothedresidualtestfollowingthe stepofleCessieandvanHouwelingen(1991).However,Hosmeretal.(1997)showed thatsmoothedresidualtestsarenotverypowerfulcomparedwithStukel’stestand

HosmerLemeshow’s Cˆ test.

Inspiteofthefactthatmanygoodnessoffittestshavebeenproposedby researchersinrecentdecades,noneofthemcanbeconsideredastheuniversalbest oneinassessingtheadequacyorinadequacyofthelogisticregressionmodel.Each proposedtesthasitsadvantagesordisadvantages.

Inthisdissertation,weproposedanewgoodnessoffittestforthelogistic regression.Theproposedtestisexpectedtoperformaswellasorbetterthanthe knowntests.Theproposedtestcanidentifythenatureofthelackoffit.Theproposed partitionlogisticregressionmodelcanbeusedasageneralizedlogisticregression modeltoimprovethefitofastandardlogisticregressionmodel.

Therestofthechaptersareorganizedasfollows.Chapter2reviewsseveral primaryoverallgoodnessoffittestsincludingtheirtheoreticaldevelopments, advantagesanddrawbacks.Chapter3presentstheproposedmethod,andapplications oftheproposedtesttoseveralrealdatasets,toillustratetheperformanceofthe proposedtest.Chapter4givesseveralsimulationsstudiesunderdifferentsettingto evaluateandcomparetheproposedtestswithotherknowntests.Chapter5and

14 Chapter6summarizethefindingobtainedinthisresearchandsomepossible extensionsofthepresentworkinafuturestudy.

15

CHAPTER2LiteratureReview

Manymethodsonassessingthegoodnessoffitforlogisticregressionmodelshave beendevelopedrecently(EvansandLi2005).Thecurrentmethodscanberoughly categorizedintofourtypes.(1)Thetestsarebasedoncovariatepatterns,which

2 includesPearson’sChisquare χ test(Pearson1900),DevianceDtest,andOsius andRojek’snormalapproximationtest(OsiusandRojek1992).(2)Hosmerand

Lemeshow’s Cˆ andHosmerandLemeshow’s Hˆ tests(HosmerandLemeshow1980) usegroupingofeventestimatedprobabilityfromtheassumedmodel.(3)Scoretests arebasedonthecomparisonoftwomodels,wheretheassumedlogisticregression modelisembeddedinamoregeneralparametricfamilyofmodels(Prentice1976).The scoretestscontainsBrown’sScoretest(Brown1982),Stukel’sScoretest(Stukel1988) andTsiatis’stest(Tsiatis1980).(4)SmoothedresidualtestsincludeleCessieandvan

ˆ Howelingen’sTlc test(CessieandHowelingen1991)andHosmerandLemeshow’s

ˆ Trc test(Hosmeretal.1997).Thesetwomethodshavesimilarperformances,Hosmeret al(1997)indicatetheyarenotbetterthanStukel’sscroetest, Cˆ test,and Hˆ test.

Inthisdissertation,sixwellknowngoodnessoffittestsforlogisticregressionmodel willbecomparedwiththeproposedtest.ThesixtestsarethePearsonChisquare

16 2 χ test(Pearson1900),DevianceDtest,HosmerandLemeshow’s Cˆ test,Hosmerand

Lemeshow’s Hˆ test(HosmerandLemeshow1980),theOsiusandRojeknormal approximationtest(OsiusandRojek1988)andStukel’sscoretest(Stukel1988).The firstthreemethodsareadoptedinseveralcommercialstatisticalpackagessuchas,

SAS,SPSS,GLIM,Splus/R.TheHosmerandLemeshow’s Cˆ ,theOsiusandRojek normalapproximationtestandStukel’sscoretestareconsideredasbettermethodsfor overallassessmentofgoodnessoffittestswhencontinuouscovariatesarepresentin themodel.Theyarerecommendedbyseveralresearchers(HosmerandLemeshow

2000).

17 2 2.1PearsonChisquare χ TestandDevianceDTest Inlogisticregression,thereareseveralgoodnessoffittestsobtainedby comparingtheoveralldifferencebetweentheobservedandfittedvalues.Amongthese

2 testsPearsonChiSquare χ andDevianceDteststatisticareusedmostoftenamong.

2 Pearsonchisquare χ goodnessoffittestwasproposedbyKarlPearson(Pearson

1900).Thismethodmadearevolutionaryimpactonthecategoricaldataanalysis.We willfirstdefinetheitemsneededtodescribethesetwotests.

Supposethat (xi , yi ) , i = 2,1 ,..n areindependentpairsofobservationsobtainedfrom

th nsubjects.Forthei subject,theresponse yi isaBernoullivariablewithprobability

success π i and xi isasinglesetofvaluesofindependent(predictororexplanatory)

th variablescalledcovariatesassociatedwiththei responsey i.Thelogitofthelogistic regressionmodelisthelinearpredictor:

η(xi ) = β0 + β1 xi1 + ...+ β p xip ,i = 2,1 ,...n, (2.1) where π (x) = Pr(y = |1 x) istheconditionalprobabilitythatyis1givenx,and

π (x) 1−π (x) = Pr( y = |0 x) istheconditionalprobabilitythatyis0givenx. iscalled 1−π (x) theoddsassociatedwiththesetofcovariate xinthelogisticregressionmodel.

Thelikelihoodfunctionforthepair (xi , yi ) is

yi 1− yi π (xi ) 1[ −π (xi )] (2.2)

18 Thelikelihoodfunctionandloglikelihoodfunctionof (xi , yi ) , i = 2,1 ,..n are respectively,

n yi 1−yi L(β ) = ∏π (xi ) 1[ − π (xi )] (2.3) i=1

n LogL(β ) = ∑ {yi logπ (xi ) + 1( − yi )log(1−π (xi ))}(2.4) i=1

Thevalueof β , βˆ thatmaximizestheequation(2.3)or(2.4)iscalledthemaximum

likelihoodestimateof β .Theestimatedprobability πˆ(xi ) andestimatedlogitηˆ(xi ) are

obtainedbythemaximumloglikelihoodmethod.Thus, πˆ(xi ) isthemaximumlikelihood

estimateof π (xi ) ,and ηˆ(xi ) isthemaximumlikelihoodestimateofthelinearpredictor

η(xi ) .

Supposethefittedmodelhaspdimensionalcovariates x = (x1 , x2 ,..., x p ) .A singlecovariatepatternisdefinedasasinglesetofvaluesofthecovariatesusedinthe model.Forexample,iftwocovariates,gender(FemaleandMale)andclass(Freshmen,

Sophomore,Junior,Senior)areusedinadataset,thenthemaximumnumberof distinctcovariatepatternsiseight.Thereareessentiallytwotypesofcovariate patterns.Typeonepattern,therearenotiedcovariateswhichindicatesthateach subjecthasauniquesetofcovariatevalues,andthenumberofcovariatepatternsJis equaltothenumberofsubjects,i.e.,J=n.Thisisverycommon,whenonlycontinuous covariatesareinvolvedinthelogisticregressionmodel.Thedatasetisconsideredto besparseinthissituation(Kuss2002).Forthetypetwopattern,somesubjectshave tiedcovariates,thatis,theyhavethesamecovariatevalues,makingthenumberof covariatepatternslessthanthenumberofsubjects,i.e.,J

19 thetotalnumberofsuccesses(y=1)be n1 andthetotalnumberoffailures(y=0)be

th n0 ,anditfollowsthat n1 + n0 = n .Supposemjsubjectsinthej covariatepatternhave

J thesamecovariatevaluesxj,then, ∑m j = n .Letthe y j1 denotethenumberof j=1

J th th successesinthej groupwithj covariatepattern.Itfollowsthat ∑ y j1 = n1 .Similarly,let j=1

th th the y j0 denotethenumberoffailuresobservedbysubjectsinthej groupwithj

J covariatepattern.Itfollowsthat ∑ y j0 = n0 .Undertypetwocovariatepattern,thebinary j=1 outcomescanberepresentedbyaJby2table.Thetwocolumnsofthetable correspondingtotheresponsevariable,y=1,0andtheJrowscorrespondingtoJ possiblecovariatepatterns.

th Let πˆ j bethemaximumlikelihoodestimateof π j associatedwiththej covariate pattern,thentheexpectednumberofsuccessobservedbythesubjectinthej th group withj th covariatepatternis

yˆ j1 =mjπˆ(xj )

Thelikelihoodfunction(2.3)andtheloglikelihoodfunction(2.4)canbewritten respectivelyasbelowfortypetwocovariatepattern

J m j  L(β ) =  (π (x )) y j1 1( −π (x ))m j − y j1 (2.5) ∏  j j j=1  y j1 

J m j  LogL(β ) = {log  + y logπ (x ) + (m − y )log(1−π (x ))}(2.6) ∑   j1 j j j1 j j=1  y j1 

ThePearsonresidual(HosmerandLemeshow1989)isdefinedas

20 (y j1 − m jπˆ(x j )) r(y j1,πˆ(x j )) = (2.7) m jπˆ(x j )(1−πˆ(x j ))

J 2 ˆ 2 ThePearsonChiSquareteststatisticis χ = ∑r(y j1,π (x j )) (2.8) j=1

Ifthefittedmodeliscorrect,thedistributionofthePearsonchiSquaretest statisticcanbeapproximatedbyaChiSquaredistributionwithdegreesoffreedomJ

(p+1),wherepisthenumberoftheparametersinthemodel.Forthetypeonepattern casewithJ=n.Pearson’schisquare(McCullaghandNelder1989)teststatisticisnotan applicablegoodnessoffittest,becausetheteststatisticwillnothaveaChisquare distribution(Christensen1997).Thisduetothefactthatwhenm j=1,onesubjectfor eachcovariatepattern,thePearsonresidualdoesnotasymptoticallyhaveanormal distributionforlargen.

ThedevianceasameasureofgoodnessoffitwasfirstproposedbyNelderand

Wedderburn(1972).Thedevianceresidualforthej th covariatepatternisdefinedas

(HosmerandLemeshow1989)

y j1 (m j − y j1 ) 2/1 d(y j1,πˆ(x j )) = ± [2{ y j1 ln( ) + (m j − y j1 ) ln( )]} (2.9) m jπˆ(x j ) m j 1( − πˆ(x j ))

wherethesignofthedevianceresidualisthesameasthatof (y j1 − m jπˆ(x j )) .The

J ˆ 2 Devianceteststatisticis D = ∑d(y j1,π (x j )) (2.10) j=1

Ifthemodeliscorrect,theteststatisticofDeviancehasapproximatelyaChiSquare distributionwithdegreeoffreedomJ(p+1).

UnderthenullmodelandTypeonecovariatepattern,thedevianceresidualisreduced to

21 yi1 1( − yi1) 2/1 d(yi1,πˆ(xi ))= ± [2{ yi1 ln( )+ 1( − yi1)ln( )]} (2.11) πˆ(xi ) 1( −πˆ(xi ))

Devianceresidualmeasuresthedifferenceoftheloglikelihoodbetweenthe assumedmodelandthesaturatedmodel.y i1 hastwovalues0and1,whichindicates

that yi1 log yi1 and 1( − yi1 ) log(1− yi1 )willbeboth0.ThenunderTypeonecovariate patterntheteststatisticofDeviancecanbeexpressedas(Collett1991)

n D=−2∑{πˆ(xi )logπˆ(xi )+ 1( −πˆ(xi ))log(1−πˆ(xi ))}(2.12) i=1

Notethattheteststatistic(2.12)ofDeviancedoesnotinvolveinthecomparisonofthe observedandfittedfrequencyofsuccessbutinvolvesacomparisonofthelogofthe maximumlikelihoodofthesaturatedmodelandtheassumedmodel.

HosmerandLemeshow(HosmerandLemeshow2000)reportedthatthep valuesofthePrearsonChisquaretestandDeviancetestarenotcorrectundertype onecovariatepatternforwhichJ=n.ThemajoradvantageofDeviancetestandPearson

Chisquareistheirelementarycalculationoftheteststatisticsandtheassociatedp value.WhenthePearsonChisquare χ 2 andDevianceDhavedifferentconclusionson thedataset,extremecautionshouldbetaken,becauseitmayindicatetheChisquare distribution(df=J(p+1))maynotapproximatethesamplingdistributionofPearsonChi squareandDevianceteststatistic(Collett1991).

Usually,theDeviancetestispreferredtothePearsonChisquaretestforthe followingreasons.(1)Thelogisticregressionmodelisfittedbythemaximumlikelihood method,andthemaximumlikelihoodestimatesofthesuccessprobabilitiesminimize theteststatisticD(Collett1991).(2)TheDeviancetestcanbeusedtocomparea

22 sequenceofhierarchicallogisticmodels,butthePearsonChisquaretestcannotbe usedinthisway(Collett1991).

23 2.2TheHosmerandLemeshowTests HosmerandLemeshowdevelopedseveraldifferentmethodstotestthelackoffit ofalogisticregressionmodel.Wewillonlyconsidertwowidelyknowntestswhichgroup thesubjectsbasedontheestimatedprobabilitiesofsuccess.Theteststatistic, Hˆ ,is calculatedbasedonthefixedandpredeterminedcutoffpointsoftheestimated probabilityofsuccess(HosmerandLemeshow1980).Theteststatistic, Cˆ ,iscalculated basedontheofestimatedprobabilities(LemeshowandHosmer1980).Only theteststatistic Cˆ methodiswellacceptedandisincludedinseveralmajorstatistical packages.

ThetestsproposedbyHosmerandLemeshow(HosmerandLemeshow1980,

LemeshowandHosmer1982)donotrequirethenumberofcovariatepatternslessthan thetotalnumberofthesubjects.

2.2.1HosmerandLemeshow’s Cˆ Inthismethod,thesubjectsaregroupedintoggroupswitheachgroup

containingn/10subjects.Thenumberofgroupsgisabout10andcanbelessthan

' 10,duetofewersubjects.Ideally,thefirstgroupcontains n1 = n /10 subjectshavingthe

smallestestimatedsuccessprobabilitiesobtainedfromthefittedassumedmodel.The

' secondgroupcontains n2 = n /10 subjectshavingthesecondsmallestestimated

successprobabilities,andsoon.Let π k betheaverageestimatedsuccessprobability

basedonthefittedmodelcorrespondingtothesubjectsinthek th groupwithy=1,and

24 th let ok bethenumberofsubjectswithy=1inthek group.Wehaveagby2frequency

tablewiththetwocolumnsofthetablecorrespondingtothetwovaluesofthe

responsevariable,y=1,0andthegrowscorrespondingtotheggroups.Theformulaof

HosmerandLemeshowteststatisticĈis

g (o − n' π )2 ˆ k k k (2.13) C = ∑ ' k=1 nkπ k 1( −π k )

g ' ' th where ∑nk = n ,and nk k = 2,1 ,...g ,isthetotalsubjectsinthek group. k=1

Underthenullhypothesis,theteststatistic, Cˆ ,isapproximatelydistributedasa

Chisquaredistributionwithg2degreesoffreedom(LemeshowandHosmer,1980).

Theequationn=10*wdoesnotalwayshold,wherenisthetotalnumberofsubjects andWisanarbitrarypositiveinteger.Thereisatendencytoensurethateachgroup hasfairnumberofsubjects.Theteststatistic, Cˆ ,maybesensitivetothecutoffpoints specifiedtoformthegroups.Toillustratethesentivitityof Cˆ ,Hosmeretal.(Hosmeret al.1997)used6differentpackagestocarryoutlackoffittestonlowbirthweightdata

(HosmerandLemeshow1989).Thesixdifferentpackagesdidproducethesamefitted modelwithsamecoefficients;however,thesedifferentpackagesprovidedsixdifferent

Cˆ valuesassociatedwithsixdifferentpvalues.

25 Table21theResultsofHosmerLemeshowĈTest fromDifferentPackages

Package Cˆ df pvalue

BMDPLR 18.11 8 0.02

LOGXACT 13.08 8 0.109

SAS 11.83 8 0.159

STATA 12.59 8 0.127

STATISTIX 12.11 8 0.147

SYSTAT 14.70 8 0.065

Theaboveresultsarenotsurprising,sincedifferentstatisticalpackageshave theirownalgorithmstodeterminethecutoffpoints.Bertolinietal.(2000)pointedout thattheparadoxofHosmerandLemshow’sgoodnessoffittestmayoccurwhenties arepresentinthecovariates.TheyalsopointedoutthatHosmerandLemeshow goodnessoffittestresultsmaybeinaccurate,whenthenumberofcovariatepatternsis lessthannumberofsubjects.

2.2.2HosmerandLemeshow Hˆ ThistestwasdevelopedbyHosmerandLemeshow(1980),inwhichthesubjects aregroupedinto10groupsiftheestimatedprobabilitiescover01.Thegrouping methodisdescribedasthefollowing:thesubjectsareinthefirstgroupwhoseestimated probabilitiesfallintherangefrom0to0.1;thesubjectsareinthesecondgroupwhose

26 estimatedprobabilitiesfallintherangefrom0.1to0.2,othergroupshavethesame groupingpolicy.Thenumberofsubjectsisnotalwaysthesameamonggroups.Inmany cases,therangeofestimatedprobabilitiescanonlycoverasmallsubsetof(0,1),which resultedinthegroupnumberslessthan10.

TheHosmerandLemeshow Hˆ teststatisticcanbeobtainedbycomputingthe

Pearsonchisquarestatisticfromagby2frequencytableconsideredinthe Cˆ test.It hasexactlythesameformas Cˆ test:

g (o − n' π )2 ˆ k k k (2.14) H = ∑ ' k=1 nkπ k 1( − π k )

' where ok , π k and nk havethesamedefinitionasin(2.13).Forlargen,thedistribution canbeapproximatedbyaChisquaredistributionwithg2degreesoffreedomunder thenullhypothesis.

ThesimulationstudyconductedbyHosmerandLemeshow(Lemeshowand

Hosmer1982)comparetheir Cˆ and Hˆ tests.Theresultsseemtosuggestthatthe

Hˆ testismorepowerfulthan Cˆ test,andthus, Hˆ testwasthepreferredtest.However, additionalstudyfromHosmer,Lemeshow,andKlar(1988)showedthat Cˆ testisbetter than Hˆ ,especiallywhentherearealotofestimatedprobabilitiesthatarelessthan0.2

(HosmerandLemeshow2000).

From(2.13)and(2.14),theHosmerLemeshow’s Cˆ and Hˆ testcanbe consideredasextensionsofPearsonchisquaretestonthebasisofmergingmultiple covariatepatternsintoonegroup,whichmakesthedistributionofthePearsonresiduals approximatelynormal.

27

2.3OsiusandRojekNormalApproximationTest ThismethodderivedbyOsiusandRojek(OsiusandRojek1992),canbeapplied notonlytobinarycasesbutalsotomultinomialcases.Theteststatisticisobtainedby modificationofPearsonChisquareteststatistic,anditisapproximatelynormally distributedwhenthenumberofsubjectsislarge.

Theproceduretoobtainethisteststatisticisdescribedforthetypetwocovariate pattern(thenumberofcovariatepatternsarelessthanthenumberofsubjects).Letthe subjectshaveJcovariatepatterns,andlettheestimatedprobabilityofthej th covariate

patternbeπˆ j basedontheassumedmodel,j=1,2,…J,thenthevarianceofnumberof

th successesinj covariatepatternis v j = m jπˆ j 1( −πˆ j ) ,where m j isthenumberof subjectsinthej th covariatepattern.

1( − 2πˆ j ) Forj=1,2,…J,let c j = .The v j sareusedastheweightstoperforman v j

ordinarylinearregressionof c j (j=1,2,…J)onthecovariates x j (j=1,2,…J),and calculatetheresidualsumsquaresRSS.Inthisordinaryweightedlinearregression, totalsamplesizeequalstonumberofcovariatespatternsJinsteadoftotalsubjectsn.

Theteststatisticzisdenotedas

[χ 2 − (J − p −1)] z = (2.15) A + RSS

28 J 1 where A = (2 J − ∑ ) isthecorrectionfactorforthevarianceand χ 2 isthePearson j=1 m j

Chisquareteststatisticgivenin(2.8).TheteststatisticZapproximatelyfollowsthe standardnormaldistributionwhenthesamplesizeislarge.

Thismethodisapplicabletothetypeonecovariatepattern(J=n)andthetype twocovariatepattern(J

Chisquarecanbeinflatedbytheverysmallorlargeestimatedprobabilities(Windmeijer

1990),thustheteststatisticZisaffectedbythischaracteristicaswell.Windmeijer

(Windmeijer1990)suggestedthatthesubjectswithextremeestimatedprobabilities shouldbeexcludedinordertoconstructasuitableteststatistic.

29 2.4Stukel’sScoreTest Stukel’sscoretestisbasedonthecomparisonbetweentheassumedlogistic regressionmodelandamoregenerallogisticregressionmodel.Thisgenerallogistic regressionmodelhastwoadditionalparameters(Stukel1988).Thus,thistestiscalled atwodegreeoffreedomtest(HosmerandLemeshow,2000).Eachoneofthetwo additionalparametersindependentlyaffectsthebehaviorofoneofthetailsofthe probabilityofsuccesscurve.

Lettheassumedlogisticregressionmodelisthesameas(1.3).Letthemaximum

likelihoodestimatesof π i = π (xi ) and ηi =η(xi ) basedontheassumedmodelbe

πˆi and ηˆ(xi ) i = 3,2,1 ...,n ,respectively.Twonewcovariatesarecreatedasfollow:

z1i = 5.0 *ηˆ(xi *) I(πˆi ≥ )5.0 and z2i = − 5.0 *ηˆ(xi *) I(πˆi < )5.0 ,i = 3,2,1 ...,n ,where I isan indicatorfunction.

Thegeneralizedlogisticregressionmodelisobtainedbyaddingthetwo

covariates z1i and z2i inthelogitoftheassumedmodel.Thatis,

logit(π i ) =η(xi ) +α1z1i +α 2 z2i (2.16)

Thenullhypothesisisexpressedas H 0 :α1 = α 2 = 0.If α1,α 2 arelargerthan zero,theestimatedtailofthesuccessesprobabilitiescurveofmodel(2.16)converges totheirrespectiveasymptotes( π = ,0 π = )1 morequicklythantheassumedmodel(1.3), otherwise,estimatedtailofsuccessesprobabilitiescurvereachitsasymptotemore

slowlythanthatofassumedmodel.If α1 = α 2 ,thecurveofestimatedprobabilitiesfor thegeneralizedlogisticregressionmodelwillbesymmetricaboutlogit=0and,

30 probability=0.5.Bythisproperty,thenatureoflackoffitontheassumedlogistic regressionmodelcanbeviewedbyplottingofthefittedprobabilityofsuccesscurve.

Figure21thePlotof π (x) versusη(x) forStukel’sModel

InFigure21,theReddotlinerepresentstheassumedmodelwith α1 =α2 = 0, thebluediamondlinerepresentsmodel(2.16)withα1 =α2 = 2.0 andthegreencircle linerepresentsthemodel(2.16)withα1 =α2 =− 2.0 . Let l(X ) bethemaximumloglikelihoodfromtheassumedmodel(1.3),and

l(X ,Z) bethatfromthegeneralizedlogisticregressionmodel(2.16).Theteststatistic

31 is ST = −2l(X ) − (−2l(X ,Z)) UnderH 0,theteststatistic ST hasalimitingchisquare distributionwith2degreesoffreedomassamplesizeincreasesto ∞ .

HosmerandLemeshow(1997)indicatedthatthismethodstrictlyspeakingisnot agoodnessoffittest,sincetheteststatisticisnotbasedonthecomparisonofthe observedandexpectedvalues.However,theydoagreethatthismethodingeneralis morepowerfulindetectinglackoffitthantheknownmethodsinmanysituationsandit controlsthetypeIerrorrate(Hosmeretal1997).

32

2.5.AnIllustrativeExample ThedataaregiveninAppendixConthesurvivalof33leukemiapatients,which werealsoanalyzedbyFeiglandZelen(1965),CookandWeisberg(1982)andJohn

(1985)usingthelogisticregressionmodel.Inthisdataset,thebinaryresponseis survivalstatus52weeksafterthetimeofdiagnosis.“1”isusedtodenotethatthe patientisalive,otherwise,“0”isused.Twoimportantcovariatesofinterestarelog transformofthewhitebloodcellcountandactionofthepresenceorabsenceofcertain morphologicalcharacteristicdenotedbythetwolevels(AG+,AG).Alogistic regressionmodelwiththefollowfunctionisfittedtothedata:

logit(π (x)) = β 0 + β1 (log(cell)) + β 2 (AG) (2.17)

EstimatesofthemodelparametersaregiveninTable22,andthegoodnessof fittestresultsfromdifferentmethodsareshowedinTable23.

Table22ParameterEstimatesofLeukemiaData

AnalysisofMaximumLikelihoodEstimates

Standard Wald Parameter DF Estimate Error ChiSquare Pr>ChiSq

Intercept 1 9.4001 4.2076 4.9911 0.0255

Log(Cell) 1 2.5653 1.0654 5.7981 0.0160

AG 1 1.2622 0.5462 5.3409 0.0208

33

Table23ResultfromSixGoodnessofFitTestsonLeukemiaData Test df statistic Pvalue HLĈ 9 8.0289 0.5312 HLĤ 8 9.9491 0.2686 Deviance 27 22.9544 0.6875 Pearson 27 19.74 0.8415 Osius&Rojek 0.4357 0.6630 StukelScore 2 0.4158 0.8123 FromTable23,thesesixdifferentgoodnessoffittestsyieldthesame conclusion,

logit(π(x)) = .9 4001− .2 5653*(log(cell)) + .1 2622* AG (2.18)

whichsuggeststhatmodel(2.18)fitsthedataadequately.Clearly,differenttestshave differentpvalues.HosmerLemeshow’sĤtestyieldsthesmallestpvaluewith0.2686 andthePearsonchisquaretestgivesthelargestpvaluewith0.8415.Itisworthnoting thatHosmerLemeshow Cˆ groupsthedatapointsinto11groupsinsteadof10groups inordertogetequalnumberofsubjectswithineachgroupusingSASsoftware.The groupingschemeisshowedasTable24.

34 Table24GroupSchemeofHosmerLemeshow’s Cˆ testwithSASSoftware onLeukemiaData PartitionfortheHosmerandLemeshowTest

y=1 y=0 Group Total Observed Expected Observed Expected

1 3 0 0.03 3 2.97

2 3 0 0.11 3 2.89

3 3 0 0.15 3 2.85

4 3 1 0.31 2 2.69

5 3 0 0.42 3 2.58

6 3 1 0.68 2 2.32

7 3 1 0.87 2 2.13

8 3 1 1.53 2 1.47

9 3 3 1.91 0 1.09

10 3 1 2.27 2 0.73

11 3 3 2.72 0 0.28

35

CHAPTER3TheProposedMethod

HosmerandLemeshow’s(1980)andLemeshowandHosmer(1982)proposed twogoodnessoffittests:the Cˆ testandthe Hˆ testbasedonthegroupingofestimated probabilitiesobtainedfromtheassumedlogisticregressionmodel.Hosmerand

Lemeshow’s Cˆ testwhichisbasedonthegroupingisbetterthanHosmer andLemeshow’s Hˆ testwhichisbasedonthepredeterminedcutoffpointespecially whenmanyestimatedprobabilitiesaresmall.(HosmerLemeshowandKlar1988).

Stukel’sscoretestwasbasedonthecomparisonbetweentheassumedlogistic regressionmodelandagenerallogisticmodelwithtwoadditionalparameters(Stukel,

1988).ButthepowerwasnotstudiedbyStukel.HosmerandLemshow(Hosmerand

Lemshow,2000)commentedthatStukel’stestwasagoodoverallassessmentmethod, besidesHosmerandLemeshowĈtest,andOusisandRojekapproximatelynormal distributiontest.

PulkstenisandRobinson(PulkstenisandRobinson,2002)proposedtwo goodnessoffittests,whichareverysimilartotheDevianceandPearsonchisquare tests.Theirdifferentgroupingmethodwasbasedoncovariatepattern:covariate patternsaredeterminedonlybythecategoricalcovariates.PulkstenisandRobinson’s methodsarenotapplicabletothecompletelysparsedatasetinwhicheachobservation

36 hasitsowncovariatepattern(2002),althoughtheyshowedtheirproposedmethodis morepowerfulthanHosmerandLemeshow’sĈtestunderthetypetwocovariate pattern.

Theknowngoodnessoffittestsforlogisticregressionmodelarenotperfect eventhoughtheymightbeadoptedmethodsincommercialsoftware.Benderand

Grouven(1996)suggestedthatmedicaljournalsmightpublishpapersaboutmisleading resultsandmisinterpretationofstatisticalinferencesduetolackoffitofthelogistic regressions.Thismotivatesustosearchforabettergoodnessoffittesttoassessthe adequacyofthelogisticregressionmodelinexplainingandpredictingtheresponses.

Weproposedapartitionlogisticregressionmodel,whichcanbeusedtodetect theoveralllackoffit,betweengroupslackoffitandwithingroupslackoffit.These conceptswillbedescribedinthelatersectionsofthechapter.Itisrecommendedthat theoverallgoodnessoffittestshouldbeperformedfirst,andifthenullhypothesisisnot rejected,wesimplyconcludethatwefailtodetectanylackoffitfortheassumedmodel; otherwise,thebetweenandwithingroupgoodnessoffittestshouldbecarriedoutin ordertofigureoutwhichtypeoflackoffitispresentintheassumedmodel.

37 3.1DescriptionoftheProposedTest Theresponsevariablecouldbemultinomialcaseorbinarycaseinthelogistic regressionmodel.Here,wewillconsideronlythebinarycase.Supposewehavenpairs

ofobservations (xi , yi ) , i = 2,1 ,...,n ,wherey ifollowsaBernoullidistributionandx iisa setofcovariatevalueassociatedwithy i.Theassumedlogisticregressionmodelis

' logit(π (xi )) = xi β i = 2,1 ,...,n ,(3.1)

' where β = (β0 ,β1,β 2 ,...,β p ) denotesp+1regressionparametersand

' th xi = ,1( x1i , x2i ,..., x pi ) representsasetofvaluesofthep+1covariatesforthei subject.

Theestimatesoftheparametersareobtainedbythemaximumlikelihoodmethodand

ˆ ' ˆ ˆ ˆ ˆ denotedby β = (β0 , β1,β 2 ,...,β p ) .Theassumedmodel(3.1)mayormaynotfitthedata verywell.Wesaythatlackoffitispresentinthemodel(3.1)ifthe“true”unknown modelforthedatais

' ' logit(π (xi )) = xi β + wiδ i = 2,1 ,...,n ,(3.2)

' Ofcourse, wiδ isnotknowntous.Weproposetoapproximatethetruemodelby apartition(segmented)logisticregressionmodel.Theapproximatelytruemodelis constructedasfollow

PartitiontheprobabilityofsuccessintoMmutuallydisjointintervals:

Sm = (π m−1,π m ),m = 2,1 ,...,M (M ≥ )2 ,where π M = 1,and π 0 = 0 .

Partitionthedatapoints D = {(xi , yi ),i = 2,1 ,...,n}intoMmutuallydisjointgroups:

th Dm = {(xmj , ymj ), j = 2,1 ,...,nm ,π (xmj )∈ Sm (m = 2,1 ,...,M )},where xmj isthej setof

38 th covariatevalueinthem group.Ofcourse,wedonotknow π (xmj ) .Hence,we

estimate π (xmj ) bythemaximumlikelihoodmethodfromtheassumedmodel(3.1).

Thefollowingfamilyofpartitionlogisticregressionmodelisusedtoapproximate theunknowntruemodel(3.2).

' ' logit(π (xmj )) = xmj β + zmjα m m = 2,1 ,...,M , j = 2,1 ,..., nm (3.3)

M where zmj = xmj I((xmj , ymj )∈ Dm ) and ∑nm = n m=1

' ' The xmj inthedefinitionof zmj canbereplacedbythevectorwhosecomponentsare

squaredorthecrossproductsofthecomponentsof xmj oranyfunctionofthe

components xmj . β and α i arevectorsoftheregressioncoefficientsofthecomponents

' ' ' of xmj and zmj ,respectively. zmj contains‘1’functioningasthecovariatesassociated withtheinterceptforthem th group.

X 1  xm1    X  x Let X =  2  where X =  m2  and m = 2,1 ,...,M .  m .      X x  M   mnm 

' matrixZconsistsof zmj definedsimilarlyasmatrixX.Ideally,wewantthecolumn spaceof(XZ)tocontainthecolumnspaceof(XW),i.e., C(XW ) ⊆ C(XZ) .Generally,

(XZ)isnotoffullcolumnrank.WeassumethatforsufficientlylargeM,thefullmodel

(3.3)shouldapproximatetheunknowntruemodel(3.2),thatis, C(XW ) isapproximately equalto C(XZ) .Hence,inprincipalwewouldliketochooseMaslargeaspossiblewith therestrictionthatthegroupsizeislargeenoughtofiteachsubmodelof(3.3).

39 Forthelogisticregressionmodelwithonlycontinuouscovariates,M=2or3, seemstobesufficientforthedatawehaveconsidered.Ifthemodelcontainsboth continuousandcategoricalcovariates,wepartitioneachcategorygroupdefinedbythe categoricalvariablesintotwotothreesubgroups.

Let L(X ,Z) and L(X ) bethemaximumlikelihoodobtainedfromthepartition model(3.3)andtheassumedmodel(3.1),respectively.Iftheassumedmodel(3.1)is thetruemodelthatis, δ = 0inthetruemodel(3.2),then − 2log L(X ) − (−2log L(X , Z)) followsanasymptoticChisquaredistributionwithdegreesoffreedom

df = rank(XZ) − rank(X ) .Thisisanoverallgoodnessoffittestfortheassumedlogistic regressionmodel(3.1).

Considerapartitionmodelforwhichmodelsfromdifferentgroupsapartfrom havingdifferentintercepts,theyallhavethesameregressioncoefficients

' logit(π (xmj )) = xmj β + um m = 2,1 ,...,M , j = 2,1 ,..., nm (3.4)

Let L(X ,u) bethemaximumlikelihoodofthemodel(3.4).Writetheoveralllack offitteststatisticas

− 2log L(X ) − (−2log L(X ,Z)

= − 2[ log L(X ) − 2log L(X ,u)]+{− 2[ log L(X ,u) − 2log L(X , Z)]}

Wecallthefirsttermtheloglikelihoodofbetweengrouplackoffitandthe secondtermtheloglikelihoodofwithingrouplackoffit.Iftheassumedmodelis correct,thenlackofthesetermshaveapproximatelyaChisquaredistributionwith degreesoffreedom df = rank(X ,u) − rank(X ) and df = rank(X ,u) − rank(X ,Z) , respectively.Iftheoveralllackoffittestissignificant,wecancarryoutthebetween groupandwithingrouplackoffitteststodeterminewhetherthelackoffitisdueto

40 betweengrouporwithingroup.Forexample,iftheformerissignificantbutthelatteris not,wemayconcludethatthelackoffitmaybeduetodifferenceoflevelsbetween groupsandmodel(3.4)maybesufficientforfittingthedata.However,ifthelatteris significantbuttheformerisnot,thenitisanindicationthatmodel(3.4)isnotsufficient toexplainthedataandweneedaseparatemodelforeachgroup—thatis,apartition model.

Theproposedmethodisapplicabletothetypeonecovariatepattern(J=n)and typetwocovariatepattern(J

41

Table31SummaryTableforKnownandProposedTests Nameofthetest TestStatistic Distribution df

Pearson J 2 ˆ 2 χ = ∑ r ( y j1 ,π ( x j )) j =1 ChiSquare np1

J ˆ 2 D = ∑ d ( y j1 ,π ( x j )) j =1 DevianceD ChiSquare np1

g ' 2 ˆ (o k − n k π k ) C = ∑ ' k =1 n k π k 1( − π k ) HLĈ ChiSquare g2

g (o − n' π )2 Hˆ = k k k ∑ n' π 1( − π ) HLĤ k =1 k k k ChiSquare g2

Osius&Rojek [ χ 2 − ( J − p − 1)] Normal z = A + RSS

Stukel’sScore ST = −2l(X ) − (−2l(X ,Z)) ChiSquare 2

New_Overall − 2l(X ) − (−2l(X , Z)) ChiSquare rank(XZ)rank(X)

New_Between − 2l(X ) − (−2l(X ,u)) ChiSquare rank(X,u)rank(X)

New_Within − 2l(X ,u) − (−2l(X ,Z)) ChiSquare rank(X,Z)rank(X,u)

42 3.2TheFirstExample ThebeetledatafromBliss(1935)givesthenumberofbeetleskilledafter5hours exposuretogaseouscarbondisulphideat8differentconcentrations.Inthistoxicological experiment,theconcentrationswerelogtransformed.ThedatasetisgiveninAppendix D. Inthisdateset,thereare481subjects,and8uniquecovariatepatterns,thatis,

J<

π log( ) = β + β x i = 2,1 ,...,481(3.5) 1−π 0 1 i Table32ResultsfromtheKnownandProposedMethodsforBeetleData Method df Statistic pvalue AIC Deviance 6 11.2322 0.0815 376.471(AssumedModel) Pearson 6 10.0253 0.1236 376.471 Ĉ 6 10.0253 0.1236 376.471 Ĥ 4 8.3506 0.0795 376.471 O.S. 0.6918 0.4891 376.471 ST. 2 8.1863 0.0167 372.284(Full) New_overall 2 8.399 0.0150 372.072(Fullmodel) New_within 1 3.723 0.0537 New_between 1 4.676 0.0306 Thetwogrouppartition(bytheoftheestimatedprobabilities)modelwas used.Alltests(Table32)exceptStukel’sscoretestandtheproposedmethodcannot rejectthenullhypothesisthattheassumedmodelfitandexplainthedataadequately. PearsonchisquaretestandHosmerandlemeshow’sĈtesthavethesameresults.P

43 valuesfromDeviancetestandPearsonChisquaretestareclose.PvalueofStukel’s testislessthan0.05,whichindicatesabettermodelisrequiredforthisdata.The proposedoverallgoodnessoffittestshowedthattheassumedmodelisnotadequate forthebeetledata.Betweengroupandwithingrouptestresultsshowedthatthelackof fitwasfrombetweengroupandwithingroup. The95%predictionintervalsonthenumberofkilledbeetleswereusedtoshowthe proposedpartitionlogisticregressionmodeldoesabetterjobinpredictingthenumber ofkilledbeetlesthantheassumedmodeldoes.

Table33PredictionintervalofNumberofBeetlesKilledbyCS 2

#ofKilled 95%ConfidenceIntervalforNumberofBeetlesKilled n jπˆ j AssumedModel ProposedModel 6 2.02 5.81 3.40 10.57 13 6.96 13.61 8.52 15.81 18 18.50 26.73 16.32 24.61 28 30.36 37.25 20.82 33.10 52 46.53 53.05 43.82 55.65 53 50.72 55.12 52.18 56.77 61 57.40 60.34 58.07 61.52 60 57.63 59.34 57.71 59.91 Fortheassumedmodel,fiveoutofeightcovariatepatternshavetheobserved numberofdeadbeetlesfallingoutsidethe95%confidenceintervals.However,forthe proposedmethod,onlythelastcovariatepatternliesoutsideof95%C.I.(Table33). Theestimatedprobabilitiesfromtheassumedmodelandproposedmodelare showedinFigure31.Thelineconnectedbluetrianglesrepresentstheproposed partitionlogisticregressionmodel.Thelineconnectedtheredasterisksrepresentsthe assumedmodel.Theobserveddataarerepresentedbygreendots.Figure31indicates thattheupperpartofbothmodelsfitthedataverywell.Theestimatedprobabilitiesof

44 theupperpartoftheassumedmodelandthefullmodeloftheproposedmethodare verysimilar.Figure31alsoindicatesthattheproposedmodelseemstofitthedata betterthantheassumedmodelwhenlog(dosage)<1.8. Figure31PlotofEstimatedprobabilitiesfromtheAssumedand ProposedModelsfortheBeetleData

Prentice(1976)showedthereisanasymmetriccurvedeparturefromthefitted modelandsuggestedthatacomplementarylogloglinkfunctionshouldbeusedin fittingthisdata.Stukel(1988)usedoneadditionalparametertoshowthatan asymmetricprobabilitycurveismoreplausible.

45 3.3TheSecondExample ThisdataisfromMilicerandSzczotka(1966)ontheageofmenarchein3918 Warsawgirls.ThedataaregiveninAppendixEandtheobservedprobabilityversus ageinFigure34.TheWarsawgirlsarefrom9.21to17.58.Ifshereachedmenarche, denote1,otherwise,denote0. Figure32theObservedProbabilityofMenstruatingonWarsawGirls

Theproblemofinterestistofitamodeltreatingtheageasthepredictorvariable andthestatusofmenstruating(binary)astheresponsevariable.Theassumedmodel isthefollowingform: π log( ) = β + β x i = 2,1 ,...3918(3.6) 1−π 0 1 i TheresultsfromtheknownmethodsaredisplayedinTable34.

46 Table34ResultsfromtheKnownforWarsawGirlsData Method df Statistic pvalue AIC Deviance 23 26.7035 0.2688 1643.305 Pearson 23 21.8684 0.5282 Ĉ 6 9.7756 0.1344 Ĥ 8 8.4069 0.3948 O.S. 0.0067 0.9884 ST. 2 11.282 0.0035 1636.012 FromtheTable34,thepvalueofStukel’sscoretestislessthan0.05forthe knowntests,whichindicatesabettermodelisneededforthisdataset.Osiusand Rojek’sapproximatenormalitymethodprovidesaverybigpvalue.BasedonAIC value,itispossibletoimprovethefitbyStukel’smodel. Figure33thePlotofResidualversusAge

47 Theresidualplot(Figure33)alsoshowsthatanimprovementoffitoverthe assumedmodelispossible. Fortheproposedtest,thefollowingfivedifferentgroupingschemesusedtoform thepartitionmodelareconsidered.ForgroupingschemeI,thedatapointsare partitionedintotwogroupswithboundaryat25 th percentileoftheestimatedprobabilities fromfittingtheassumedmodel.GroupingschemeIIandIIIareconstructedthesimilar waywithboundaryat35 th percentileand50th percentile,respectively.Forgrouping schemeIV,thedatapointsarepartitionedintothreegroupsbythegroupboundaries 35 th percentileand65 th percentileoftheestimatedprobabilitiesfromfittingtheassumed model.GroupingschemeVisconstructedthesamewaywithboundariesat25 th percentileand75 th percentile. InTable35,thepvaluesofallfiveoverallproposedtestsarelessthan0.05, whichindicatesthatlackoffitispresentintheassumedmodel.Thelackoffitmay comefromwithingrouporbetweengrouporbothwithdifferentgroupingschemes.The proposedoveralltestisnotsensitivetothegroupingschemes.

48 Table35ResultsfromDifferentGroupingSchemesoftheProposedMethod grouping df Statistic pvalue AIC I_overall 2 11.401 0.0033 1635.940 I_bewteen 1 8.697 0.0032 I_within 1 2.722 0.9897 II_overall 2 10.807 0.004501 1636.498 II_bewteen 1 1.134 0.2869 II_within 1 9.673 0.00197 III_overall 2 8.5943 0.0136 1638.710 III_bewteen 1 3.827 0.05043 III_within 1 4.768 0.02899 IV_overall 4 11.795 0.0189 1639.510 IV_bewteen 2 1.202 0.5483 IV_within 2 10.597 0.005 V_overall 4 12.949 0.0115 1638.356 V_bewteen 2 9.726 0.0077 V_within 2 3.223 0.1996 ThemodelwithgroupingschemeIhasthesmallestAICvalueamongthe assumedmodel,Stukel’smodelandtheproposedpartitionmodelswithdifferent groupingschemes.Theestimatedprobabilitiesfromtheassumedmodelandproposed modelwithgroupingschemeIareintheFigure34.Thelineconnectedorangetriangles representstheassumedlogisticregressionmodel.Thelineconnectedthebluecircles representstheproposedmodel.Theobserveddataarerepresentedbyasterisks. Figure34showsthattheupperpartsofbothmodelsfitthedataverywell.The estimatedprobabilitiesupperpartoftheassumedmodelandfullmodeloftheproposed methodareveryclose.TheFigure34alsoshowsaslightimprovementofmodelwith groupingschemeIinfittingthelowerpartoftheproposedmodel.Fromabove,two

49 grouppartitionmodelwithgroupingschemeIismoresuitableforthisdataandthe modelobtainedfromTable36is

− 20.0488 + .1 5447* x x ∈G1 logit(π (x)) =  (3.6) − 54.7125 + .4 6185* x x ∉G1 Table36theParameterEstimatesforModelwithGroupingSchemeI

AnalysisofMaximumLikelihoodEstimates

Standard WaldChi Parameter DF Estimate Error Square Pr>ChiSq

grp1 1 20.0488 0.8424 566.4574 <.0001

g1x1 1 1.5447 0.0639 583.9186 <.0001

grp2 1 54.7125 27.6778 3.9076 0.0481

g2x1 1 4.6185 2.5265 3.3416 0.0675

Table37ModelFitStatisticsofModel3.6

ModelFitStatistics

AIC 1635.940

SC 1661.033

2LogL 1627.940

Stukel(1988)alsoshowedthepoorfitoftheassumedmodelduetothedeviation fromthelogisticcurveonthelowertail.Aprobitlinkfunctionprovidesamild improvementonthesedatabyFinney(1971)andArandaOrdaz(1981).Themodelwith probitlink(AIC1639.489)isnotbetterthanpartitionmodels(Table35)andStukel’s generallogisticregressionmodel(Table34).

50 Figure34ProbabilityversusAgeonWarsawGirlData

FromTable38,the95%predictionintervalfortheobservedcountsindicatesthat animprovementovertheassumedmodelmadebytheproposedpartitionmodelis possible,particularlyonthelowertail.Whenthe95%criticallimitsdonotincludethe observedcount,theproposedpartitionmodelgivesamuchcloserboundthanthe assumedmodeldoes.

51 Table38ObservedCountsandConfidenceInterval(AssumedModeland ProposedMethod)fortheWarsawGirlData

#of 95%ConfidenceIntervalforNumberofmenstruating n jπˆ j menstruating AssumedModel ProposedModel(GroupingI) 0 0.48 1.21 0 11.15 0 1.46 2.91 0.002 4.6 0 1.28 2.35 0.03 2.13 2 2.54 4.40 0.34 3.4 2 2.90 4.75 0.8 7.7 5 4.30 6.65 5.02 8.10 10 7.70 11.25 8.79 13.31 17 12.05 16.65 13.46 19.13 16 15.74 20.64 17.22 23.02 29 20.68 25.81 22.15 27.80 39 30.36 36.31 31.89 38.37 51 42.98 49.62 44.39 51.30 47 49.40 55.50 50.29 56.39 67 63.44 69.79 63.87 70.08 81 72.37 78.28 72.29 78.06 88 89.69 95.62 89.90 94.56 79 81.24 85.52 80.15 95.05 90 85.08 88.59 84.31 88.01 113 109.55 113.03 108.60 112.39 95 95.78 98.07 95.04 97.62 117 116.82 118.91 116.06 118.48 107 107.74 109.16 107.17 108.87 92 92.10 92.99 91.71 92.79 112 112.41 113.20 112.04 113.03 1049 1047.97 1048.65 1047.48 1048.51

52 3.4TheThirdExample Thedataofthisexamplearefromtwogeneralsocialsurveyscarriedoutbythe NationalOpinionResearchCenter,UniversityofChicago,Illinois,in1974and1975. Partofthesetwosurveyswasconcernedwiththerelationshipofeducationandgender withtheattitudestowardstheroleofwomeninsociety.Eachrespondentwasaskedif heorsheagreedordisagreedwith‘Womenshouldtakecareofrunningtheirhomes andleaverunningthecountryuptomen.’Thedatawerecombinedfromtwosets,since noindividualwasinvolvedtwosurveysandshorttimeintervalbetweentwosurveys. Among2927participators,threedidnotgivetheireducationlevelsandfiftythreewere notsurewhethertheyagreedornotthestatementprovided.Theresponsesfrom1305 malesand1566femalesweregivenbyHaberman(1978)andshowedinAppendixE. Theproblemofinterestistofitamodeltreatingtheyearsofeducationand genderasthepredictorvariablesandtheattitudeofthestatement(binary)asthe responsevariable,where“1”isusedtodenotetheagreementonthestatementinthe survey.Theassumedmodelisofthefollowingform: π log( ) = β + β x + β x i = 2,1 ,...2871(3.6) 1−π 0 1 i1 2 i2 Table39ResultsfromtheKnownandProposedMethodsforWomen’sRoleData Method df Statistic pvalue AIC Deviance 38 64.0066 0.0052 3354.330 Pearson 38 72.6678 0.0006 3354.330 Ĉ 6 2.9756 0.8142 3354.330 Ĥ 8 12.444 0.01345 3354.330 O.S. 2.4770 0.0067 3354.330 ST. 2 10.1506 0.0062 3348.179 New_overall 6 15.5117 0.0166 3348.818 New_within 3 5.3832 0.1458 New_between 3 10.085 0.01786

53 Inthisexample,fourgroupswereusedinthepartitionmodel,thedatawere partitionedintotwogroupsbygender,andtheneachgroupwasdividedintotwosub groupsbythemedianofestimatedprobabilities.FromTable39,alltestsshowedthat theassumedmodelisnotadequateforthedataexceptHosmerLemeshow’sĈtests. Theproposedtestshowedthepresenceoflackoffitbetweengroup.Theproposed partitionmodelandtheStukel’smodelgivesimilarAICvalues. Collett(1991)showedtheassumedmodelisnotadequatetothedataand suggestedthattwodifferentlogisticregressionmodelsformalesandfemales, respectively,shouldbeusedtofitmodel: π Males: log( ) = .2 098 − .0 2346 (* yearsedu.) 1−π π Females: log( ) = .3 003 − .0 315 (* yearsedu.) 1−π

54 3.5TheFourthExample Thedata(AppendixG)ofthisexamplewasfrom LuigiBocconi,acuradiR. Piccarreta(1993) ThesubjectsofthisexamplewererandomlyselectedinItalianin ordertostudytherelationbetweentheannualincomeandwhetheronepossessesa travelcreditcard.Inthisdataset,thenumberofcasesrepresentsthenumberof subjectsattheincomelevel.Ifthesubjecthasatleastonetravelcreditcard,thecredit cardwasdenotedas“1”,otherwise,“0”. Inthisdateset,therearetotal100subjects,and31uniquecovariatepatterns, thatis,J

π log( ) = β + β x i = 2,1 ,...,100 (3.7) 1−π 0 1 i Table310ResultsfromtheKnownTestsforCreditCardData Method df Statistic pvalue AIC Deviance 29 45.9211 0.0239 100.963 Pearson 29 41.0674 0.0679 Ĉ 7 8.4355 0.2958 Ĥ 8 17.9802 0.0214 O.S. 1.6364 0.1018 ST. 2 0.261 0.8776 104.702 Inthisexample,Stukel’sscoretestgivesthelargestpvalueamongsixknown tests.PvaluesofDeviancetestandHosmerLemeshowĤtestarelessthan0.05,

55 whichindicatethepresenceoflackoffitintheassumedmodel.HosmerLemeshowĤ testandHosmerLemeshowĈtestgivecontradictingconclusion,HosmerLemeshowĈ testindicatestheabsenceoflackoffitintheassumedmodel.ThepvalueofPearson chisquareisjustalittlebitlagerthan0.05. Sincedifferentconclusionsareobtainedfromdifferenttests,itisworthyto investigatethenatureoflackoffit.Therearethreeparts—uppertail(above75 th percentileofestimatedprobabilitiesfromtheassumedmodel),middlepart(between 25 th percentileand75 th percentile)andlowertail(below25 th percentileoftheestimated probabilitiesfromtheassumedmodel)willbeconsidered.Thedataarepartitionedinto threegroupsasbelow:

th G1 = {(xi , yi :) πˆ(xi ) < 25 percentile} th th G2 = {(xi , yi :) 25 percentile ≤ πˆ(xi ) ≤ 75 percentile} th G3 = {(xi , yi :) πˆ(xi ) > 75 percentile} First,wewilldetectwhetherthelackoffitoccursatthelowertail,middlepartor uppertailof πˆ(x) byfittingrespectivelythefollowingtwogrouppartitionmodels:

x'β + z'α i x ∈Gi logit(π (x)) =  (i=1,2,3)(3.8) x'β x ∉Gi Table311GoodnessoffitTestBasedonModel(3.8) Model df Teststatistic pvalue Model1of3.8(withoutsecondorder) 2 0.998 0.6071 Model10f3.8(withsecondorder) 3 2.508 0.4738 Model20f3.8(withoutsecondorder) 2 6.152 0.04614 Model2of3.8(withsecondorder) 3 13.376 0.00389 Model3of3.8(withoutsecondorder) 2 4.838 0.089

56 Theparameterestimatesofmodel3.8underdifferentcasesconsideredisshown intheTable312. Table312ParameterEstimatesofModel(3.8) Parameter Estimate Std.err pvalue Intercept 3.6308 0.9793 0.0002 G1 X 0.0544 0.0164 0.0009 (lowertail) grp1 4.5688 7.8076 0.5584 X_low 0.2194 0.2648 0.4073 G1 Intercept 3.6308 0.9793 0.0002 (lowertail) X 0.0544 0.0164 0.0009 grp1 137.6 180.9 0.4468 X_low 9.6927 12.3771 0.4336 X_low*x_low 0.1721 0.2115 0.4158 G2 Intercept 3.3142 0.8143 <.0001 (middle X 0.0423 0.0122 0.0005 part) grp2 6.6457 1.8299 0.0003 X_middle 0.1178 0.0346 0.0007 G2 Intercept 3.3142 0.8143 <.0001 (middle X 0.0423 0.0122 0.0005 part) grp2 17.3259 9.5534 0.0697 X_mid 0.8878 0.4096 0.0302 X_mid*X_mid 0.0101 0.0042 0.0165 Intercept 4.9787 1.0884 <.0001 G3 X 0.0877 0.0226 0.0001 (uppertail) grp3 5.0788 2.7945 0.0691 X_upper 0.0612 0.0316 0.0529

57 FromTable311,formodel2of3.8withfirstorder,theteststatisticofthe proposedmethodis6.512with2degreesoffreedomandgivesthepvalue=0.04614, whichindicatesthatabettermodelisneededforthisdataset.Formodel2of3.8with firstandsecondorder,theteststatisticoftheproposedmethodis13.376with3 degreesoffreedomandgivesthepvalue=0.00389,whichindicatesthattheassumed modelisnotadequateforthisdataset. Table313ModelFitStatisticsfromTwoCasesofModel(3.8) i=2

Withfirstand Criteria Withfirstorder secondorder

AIC 98.811 93.587

SC 109.232 106.883

2LogL 90.811 83.587

FromTable313,wemayconcludemodel2of3.8withfirstandsecondorderis moresuitablethanthemodelwithoutsecondorder,sincethemodelwithfirstand secondorderhasthesmallerAICandSC. Second,thetwothreegrouppartitionmodelswillbeusedtodetectfurther onthelackoffitandmodelbuilding.Thethreegrouppartitionmodelsareexpressed as:

x'β + z'α 2 x ∈G2  logit(π (x)) = x'β + z'α1 x ∈G1 (3.9)  x'β x ∈G3

x'β + z'α 2 x ∈G2  and logit(π (x)) = x'β + z'α 3 x ∈G3 (3.10)  x'β x ∈G1

58 WeareinterestedintestingH 0: α 2 = 0 versusHa: α 2 ≠ 0 . Theteststatisticwas calculated f rommodel3.9andmodel1of3.8withsecondorderis13.499alongwith df =3,whichyieldthepvalue=0.0367.Wecanconcludethatthelackoffitoccursinthe middlepart.Similarly,forthetestingonH 0: α1 = 0 versus Ha: α1 ≠ 0,theteststatisticwas calculatedfrommodel3.9andmodel2of3.8withsecondorderis2.631with df =3, whichyieldthepvalue=0.4521.Thus,wecanconcludethatthelackoffitoccursinthe middlepart. Table314ParameterEstimatesofModel(3.9)

Standard Wald Parameter Estimate Error ChiSquare Pr>ChiSq

grp1 137.6 180.9 0.5787 0.4468

X_low 9.6927 12.3771 0.6133 0.4336

X_low*x_low 0.1721 0.2115 0.6620 0.4158

grp2 17.3262 9.5535 3.2892 0.0697

X_mid 0.8878 0.4096 4.6986 0.0302

X_mid*X_mid 0.0101 0.00420 5.7478 0.0165

grp3 5.0788 2.7945 3.3031 0.0691

X_upper 0.0612 0.0316 3.7470 0.0529

Forthemodel3.10,hereisanote:

WARNING: There is possibly a quasi-complete separation of data points. The maximum likelihood estimate may not exist. WARNING: The LOGISTIC procedure continues in spite of the above warning. Results shown are based on the last maximum likelihood iteration. Validity of the model fit is questionable. Thus,wecandeclarethatthemodel3.10isnotapplicableforthisdataset.

59 Fromfirstandsecondstep,wemayclaimthatthefinalmodelismodel2of(3.8) withfirstandsecondorder:

2 17.3259 − .0 8878* x + .0 0101x x ∈G2 logit(π (x)) =  − .3 3142 − .0 0423* x x ∉G2

60

CHAPTER4SimulationStudy

Inthischapter,fourdifferentsimulationstudieswereconductedtoevaluatethe adequacyoftheproposednulldistributionsinapproximatingthesamplingdistributionof ourteststatisticswhentheassumedmodelisthecorrectmodelandtocomparethe poweroftheproposedtestwithsixknownteststodetectavarietyofdeparturesfrom thetruemodels.Thesixknowngoodnessoffitteststatisticsusedtocomparedwiththe proposedteststatisticinthesimulationstudyarePearsonChisquarestatistic, χ 2 ;

Devianceteststatistic,D;HosmerandLemeshow’sdecileofriskstatistic,thatisthe teststatisticCˆ with10groups;HosmerandLemeshow’spredeterminedcutoffpoint statistic, Hˆ ,withupto10groups;theOsiusandRojeknormalapproximationtest statistic,Z OR ;andStukel’sscoreteststatistic, ST .Allsimulationswereperformedona

DellInspiron6000PCusingSASVersion9.1.

InthisChapter,allsimulationstudiesconsideredherewillincludetypeone covariatepattern(J=n)toexaminetheperformanceoftheproposedtest,sincethe standardgoodnessoffittestsareunsatisfactoryforthiscovariatepattern.Furthermore, datawithtypeonecovariatepatternarefrequentlyseeninapplication.Thecovariates inthefirst,third,andthefourthsimulationstudyarecontinuous,andthecovariatesin thesecondsimulationareamixtureofcontinuousandcategoricalcovariates.

61 4.1TheFirstSimulationStudy Inthissection,wewilluseasimplelogisticregressionmodelasourassumed modelinwhichonlyonepredictorvariableisused.Wewillfirstcheckwhetherthe proposedmodelcontrolsthetypeIerrorrate,whenthedataaregeneratedfromthe followinglogisticmodel

π log( ) = β + β x (4.1) 1− π 0 1 1

where β 0 = − 3.0 and β1 = 3.1 ,

Inthissimulationstudy,1000randomsamplesofsizen=100,200or500were respectivelygeneratedfromtheabovemodelwithcovariatexindependentlygenerated fromanuniformdistributionovertheinterval(2,2).Theresponsevariableyassociated withthecovariatexwasgeneratedasfollow:Arandomvariableuisgeneratedfroma uniformdistributionovertheinterval(0,1).Theresponseyassociatedwithxwas assignedavalue1,if π (x) ≥ u ,and0otherwise.

Theproposed2grouppartitiontestwithcutoffpointsetat50 th percentile,3 groupspartitiontestwithcutoffpointssetat25th percentileand75 th percentile,and thesixknowntestsmentionedabovewereappliedtotherandomsamplesgenerated frommodel(4.1)atsignificancelevelsetat α = .0 05 1.0, .Theobservedrejectionrates arepresentedinTable41,whereĈistheHosmerandLemeshow’sĈtest;Ĥisthe

HosmerandLemeshow’sĤtest;DistheDeviancetest;PisthePearsonChisquare test;O.S.istheOsiusandRojek’snormalapproximatelynormaltest;STistheStukel’s

62 scoretest;New2istheproposedmethodwith2groups;New3istheproposedmethod with3groups.

Table41ObservedTypeIErrorRateforSimulationStudyone Sample Size Method α=0.05 α=0.10 Ĉ 0.037 0.082 Ĥ 0.043 0.079 D 0.05 0.031 100 P 0.014 0.023 O.S. 0.06 0.098 ST. 0.054 0.102 New2 0.063 0.104 New3 0.06 0.101 Ĉ 0.036 0.087 Ĥ 0.052 0.092 D 0.006 0.029 200 P 0.008 0.016 O.S. 0.041 0.084 ST. 0.047 0.102 New2 0.052 0.104 New3 0.06 0.102 Ĉ 0.036 0.086 Ĥ 0.052 0.085 D 0.006 0.041 500 P 0.008 0.006 O.S. 0.041 0.078 ST. 0.047 0.106 New2 0.052 0.101 New3 0.055 0.105

Giventhespecifiedsignificancelevelαandsamplesizen,the95%likelyinterval fortypeIerrorrateis:

α 1( −α) α 1( −α) (α − .1 96* ,α + .1 96* ) n n

63 Table42the95%ConfidenceIntervalfortheTypeIErrorRate Samplesize Lowerlimit Upperlimit α=0.05 0.0365 0.0635 α=0.10 0.0814 0.1186 BasedontheTable42,thetypeIerrorratesofStukel’sscoretestandthe proposedtestsallfallwithin95%confidenceinterval,underdifferentsamplesizeand differentsignificancelevels.TypeIerrorratesofPearsonChisquaretestarelessthan lowerlimitof95%confidenceinterval.SometypeIerrorratesofDeviancetest,

HosmerLemeshow’stestsandOsiusandRojek’stestfalloutside95%confidence interval.

Next,therandomsamplesweregeneratedfromthefollowingmodel:

π log( ) = β + β x + β x 2 (4.2) 1−π 0 1 1 2 1

where β2 takesonthevalues0,0.2,0.4,0.6,and0.8,respectively.Theproposed2 groupand3grouppartitiontestsandthesixknowntextswereappliedtotherandom samplesgeneratedfrom(4.2)totestthegoodnessoffitoftheassumedmodel(4.1)at levelofsignificance α = .0 05 .TherejectionratesofthesetestswerepresentedinTable

43andgraphicallyinFigure41to43.

64 Table43RejectionRatesfortheKnownandProposedTestsforStudyOne

size β2 Ĉ Ĥ D P O.S. ST. New2 New3 0 0.037 0.043 0.005 0.014 0.061 0.054 0.063 0.06 0.2 0.06 0.057 0.007 0.014 0.104 0.106 0.11 0.1 100 0.4 0.119 0.143 0.012 0.012 0.13 0.292 0.272 0.239 0.6 0.271 0.328 0.057 0.003 0.097 0.604 0.55 0.498 0.8 0.519 0.595 0.138 0 0.089 0.876 0.829 0.778 0 0.036 0.052 0.006 0.008 0.041 0.047 0.052 0.06 0.2 0.101 0.085 0.01 0.006 0.091 0.171 0.163 0.13 200 0.4 0.273 0.301 0.027 0.004 0.114 0.556 0.517 0.448 0.6 0.646 0.682 0.137 0 0.116 0.903 0.872 0.808 0.8 0.896 0.919 0.383 0 0.397 0.991 0.986 0.969 0 0.045 0.039 0.011 0 0.035 0.042 0.047 0.055 0.2 0.172 0.152 0.019 0.007 0.117 0.345 0.332 0.265 500 0.4 0.716 0.709 0.081 0.001 0.125 0.914 0.887 0.836 0.6 0.984 0.985 0.453 0 0.261 0.999 0.998 0.996 0.8 1 1 0.849 0 0.904 1 1 1

Figure41PlotsofRejectionRateforStudyOne(n=100)

1 0.9 0.8 Ĉ 0.7 Ĥ 0.6 D 0.5 P 0.4 O.S.

RejectionRatem 0.3 ST. 0.2 New2 0.1 New3 0 0 0.2 0.4 0.6 0.8 beta2

65 Figure42PlotsofRejectionRateforStudyOne(n=200)

1 0.9 0.8 Ĉ 0.7 Ĥ 0.6 D 0.5 P 0.4 O.S.

RejectionRatem 0.3 ST. 0.2 New2 0.1 New3 0 0 0.2 0.4 0.6 0.8 beta2

Figure43PlotsofRejectionRateforStudyOne(n=500)

1 0.9 0.8 Ĉ 0.7 Ĥ 0.6 D 0.5 P 0.4 O.S.

RejectionRatem 0.3 ST. 0.2 New2 0.1 New3 0 0 0.2 0.4 0.6 0.8 beta2

66

Thesimulationresultssuggestthat,therejectionratesofthePearsonChisquare testandOsiusandRojeknormalapproximatetestdecreaseastheassumedmodel departsfurtherawayfromthetruelinearlogisticregressionmodelwhenn=100.When samplesizeare200and500,therejectionratesofalltestsexceptthePearsonchi squaretestincreaseasthedepartureoftheassumedmodelfromthetruemodel increases(Figure42,43).TheHosemerandLemshowĈandĤtestshavesimilar powerfunctionsfordifferentlevelofsamplesizes.Theproposed(twogroupandthree group)partitiontestsandStukel’sscoretesthavenearlythesamerejectionratewith thelatterhavingslightlyhigherpowerwhentheassumedmodeldepartsfromthetrue model.WiththeexceptionofPearsonsquaretest,theperformancesofalltestsimprove

whensamplesizeincreases.Forexample,when β 2 = 4.0 ,theproposedtest,Stukel’s scoretest,HosmerLemeshowĈtest,HosmerLemeshowĤtest,Deviancetesthave

61.5,62.2,59.7,56.5,6.9percentmorechanceofrejectingtheassumedmodelwhen n=500thanthatwhenn=100.ThesimulationresultsinvestigatedbyHosmer,Hosmer, leCessieandLemeshow(1997)indicatedthatalloftheoverallgoodnessoffittestsare notpowerfulforsmalltomoderatesamplesizes(n<400).Table43andFigure41,42 and43showedthatStukel’sscoretestismorepowerfulthantheothertests,followed bythenewproposedmethod,andtheHosemerandLemshowĈandĤtests.Pearson

Chisquaretesthasverypoorperformance,therejectionrateremainsatverylowlevel regardlessofhowbigthesamplesizeisandhowfartheassumedmodelisawayfrom thetruemodel.

67 4.2TheSecondSimulationStudy Inthissection,wewilluseamixturelogisticregressionmodelasourassumed modelinwhichonepredictorisacontinuousvariableandtheotherisacategorical variable.WewillfirstcheckwhethertheproposedmethodcontrolsthetypeIerrorrate, whenthedataaregeneratedfromthefollowinglogisticregressionmodel

π log( ) = β + β x + β d (4.3) 1− π 0 1 1 2

where β0 = − .0 25 , β1 = 6.0 and β2 = 3.0 ,x 1anddaredefinedasbelow

Inthissimulationstudy,1000randomsamplesofsizen=100,200,500were respectivelygeneratedfrommodel(4.3)withcovariatex 1independentlygeneratedfrom anuniformdistributionovertheinterval(3,3),andthecovariatedindependently generatedfromaBernoullidistributionwithprobability0.5.Theresponsevariabley associatedwiththecovariatex 1anddwasgeneratedasfollow.Arandomvariableuis generatedfromauniformdistributionovertheinterval(0,1).Theresponseywas assignedavalue1,if π (x) ≥ u ,and0otherwise.

Theproposed4grouppartitiontestpartitionseachofthetwocategoricalgroup definedbydintotwogroupsatcutoffpointssetatthe50 th percentiles.Thesixknown testsmentionedbeforewereappliedtotherandomsamplesgeneratedfrommodel(4.3) atthelevelofsignificance α = .0 05 1.0, .Theobservedrejectionratesarepresentedin

Table44,whereĈistheHosmerandLemeshow’sĈtest;ĤistheHosmerand

Lemeshow’sĤtest;DistheDeviancetest;PisthePearsonChisquaretest;O.S.is

68 theOsiusandRojek’snormalapproximatelynormaltest;ST.istheStukel’sscoretest,

Newistheproposedtestwith4groups.

Table44ObservedTypeIErrorRateforSimulationStudyTwo SampleSize Methods α=0.05 α=0.10 Ĉ 0.04 0.089 Ĥ 0.042 0.09 D 0.221 0.454 100 P 0.003 0.006 O.S. 0.154 0.212 ST. 0.064 0.138 New 0.065 0.128 Ĉ 0.047 0.106 Ĥ 0.063 0.107 D 0.492 0.731 200 P 0 0 O.S. 0.093 0.134 ST. 0.064 0.109 New 0.064 0.126 Ĉ 0.059 0.119 Ĥ 0.062 0.119 D 0.929 0.981 500 P 0 0 O.S. 0.037 0.079 ST. 0.06 0.106 New 0.052 0.11

Inthissimulationstudy,theDeviancetestcannotcontroltypeIerrorrate.

Whentheassumedmodeliscorrectmodel,thechanceofrejectingthenullhypothesis increasesasthesamplesizegetslargerandlarger,whichindicatethatthelarge samplesizedoesnothelpDeviancetesttocontroltypeIerrorrate.Inaddition,alltypeI errorratesofDeviancetestarelargerthantheupperboundof95%confidenceinterval.

TypeIerrorratesofPearsonChisquaretestaresmallerthanthelowerboundof95% confidenceintervalunderdifferentsamplesizes,evenzeropercentchancetoreject

69 nullhypothesiswhentheassumedmodelistruewithn=200,500.Theabilityof controllingtypeIerrorrateofOsiusandRojek’snormalapproximationtestcanbe improvedbylargersamplesize,forexample,underthenullhypothesisusingα=0.05,it has3.7percenttorejectthenullhypothesiswhenn=500insteadof15.4percentwhen n=100.TypeIerrorrateofOsiusandRojek’snormalapproximatelynormaltestare greaterthantheupperboundof95%confidenceintervalunderα=0.05n=100,α=0.05 n=200,α=0.10n=100.BasedonTable42,almostalltypeIerrorratesofHosmerand

Lemeshow’sĈtest,HosmerandLemeshow’sĤ,Stukel’sscoretestandtheproposed testfallwithin95%confidenceinterval,underdifferentsamplesizeanddifferent significancelevels.

Next,therandomsamplesweregeneratedfromthefollowingmodel

π log( ) = β + β x + β d + β x d (4.4) 1−π 0 1 1 2 3 1

where β3 takesonthevalues0,0.1,0.2,…,0.8,respectively.Theproposed4group partitiontestandthesixknowntestswereappliedtotherandomsamplegenerated from(4.4)totestthegoodnessoffitoftheassumedmodel(4.3)atthelevelof significance α = .0 05.TherejectionratesofthesetestswerepresentedinTable45and graphicallyshowninFigure44to46.

70 Table45RejectionRatesfortheKnownandProposedTestsforStudyTwo Sample Size β3 Ĉ Ĥ D P O.S. ST. New 0 0.04 0.042 0.221 0.003 0.154 0.064 0.065 0.1 0.044 0.054 0.132 0.003 0.114 0.072 0.088 0.2 0.045 0.05 0.066 0.005 0.088 0.076 0.099 0.3 0.045 0.045 0.05 0.01 0.08 0.074 0.125 100 0.4 0.046 0.048 0.031 0.017 0.072 0.071 0.156 0.5 0.048 0.044 0.018 0.025 0.07 0.081 0.21 0.6 0.056 0.05 0.008 0.031 0.071 0.09 0.261 0.7 0.06 0.045 0.001 0.037 0.073 0.093 0.301 0.8 0.068 0.055 0 0.046 0.081 0.096 0.381 0 0.047 0.063 0.492 0 0.093 0.064 0.064 0.1 0.049 0.051 0.329 0 0.076 0.061 0.079 0.2 0.047 0.046 0.183 0.003 0.074 0.067 0.117 0.3 0.052 0.054 0.089 0.005 0.058 0.07 0.174 200 0.4 0.05 0.058 0.055 0.007 0.056 0.076 0.232 0.5 0.058 0.06 0.036 0.011 0.069 0.079 0.333 0.6 0.061 0.056 0.024 0.016 0.072 0.088 0.422 0.7 0.066 0.059 0.013 0.022 0.079 0.082 0.537 0.8 0.073 0.065 0.01 0.025 0.089 0.082 0.623 0 0.059 0.062 0.929 0 0.037 0.06 0.052 0.1 0.067 0.064 0.787 0 0.033 0.061 0.068 0.2 0.08 0.063 0.529 0 0.036 0.074 0.147 0.3 0.078 0.076 0.304 0 0.033 0.077 0.324 500 0.4 0.081 0.075 0.16 0 0.04 0.076 0.546 0.5 0.087 0.103 0.063 0.002 0.053 0.09 0.738 0.6 0.092 0.1 0.026 0.004 0.063 0.099 0.861 0.7 0.093 0.094 0.014 0.005 0.075 0.114 0.941 0.8 0.1 0.099 0.008 0.014 0.092 0.143 0.979

71

Figure44PlotsofRejectionRateforStudyTwo(n=100)

1

0.9

0.8 Ĉ 0.7 Ĥ 0.6 D 0.5 P

0.4 O.S.

RejectionRatem ST. 0.3 New 0.2

0.1

0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Beta3

Figure45PlotsofRejectionRateforStudyTwo(n=200)

1

0.9

0.8 Ĉ 0.7 Ĥ 0.6 D 0.5 P

0.4 O.S.

RejectionRatem ST. 0.3 New 0.2

0.1

0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Beta3

72 Figure46PlotsofRejectionRateforStudyTwo(n=500)

1

0.9

0.8 Ĉ 0.7 Ĥ 0.6 D 0.5 P

0.4 O.S.

RejectionRatem ST. 0.3 New 0.2

0.1

0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Beta3

Thissimulationstudyresultssuggestthat,thepowerofDeviancetestisgetting poorerandpoorerwhentheassumedmodeldeparturesfurtherandfurtherfromthetrue model.ForPearsonChisquaretest,biggersamplesizeandfurtherdeparturefromtrue modelcannotenhanceitspowertodetectthelackoffit.Thissimulationstudyshowed thattheDeviancetestandPearsonchisquaretestarenotapplicabletothetypeone covariatepattern(J=n).ForOsiusandRojek’snormalapproximationtest,largersample sizesimprovetheabilitytocontrolthetypeoneerrorrate.However,neitherlarger samplesizesnorfurtherdeparturefromthetruemodelcanimprovethepowerof detectinglackoffit.Stukel’sscoretestandHosmerandLemeshow’sĈandĤtests haveverysimilarperformance:TheycontroltypeIerrorrate,butthepowerofdetecting lackoffitcannotbeimprovedmuchbylargersamplesizeandfurtherdepartureaway fromthetruemodel.Theproposedtesthasthebestperformanceamongthesetestsat

73 differentsamplesizesanddegreeofdeparturefromthetruemodel.Theabilityof controllingtypeIerrorrateandpowerofdetectinglackoffitareimprovedbyincreasing thesamplesizes.Insummary,theproposedmethodisthebesttestinthissimulation study.

74 4.3TheThirdSimulationStudy Inthissection,wewilluseamorecomplicatedlogisticregressionmodelthanthe previoustwoinwhichthreepredictorvariablesusedinthemodel.Wewillfirstcheck whethertheproposedtestcontrolsthetypeIerrorrate,whenthedataaregenerated fromthefollowinglogisticregressionmodel

π log( ) = β + β x + β x + β x (4.5) 1−π 0 1 1 2 2 3 3

where β0 = − 3.1 , β1 = .0 26 , β 2 = .0 26, β3 = .0 23

Inthissimulationstudy,1000randomsamplesofsizen=100,200,500were respectivelygeneratedfrommodel(4.5)withcovariatex 1independentlygeneratedfrom anuniformdistributionovertheinterval(2,2),thecovariatex 2independentlygenerated fromthestandardnormaldistributionwithmean0andstandarddeviation1,andthe covariatex 3independentlygeneratedfromtheChisquaredistributionwithdegreesof freedom4.Theresponsevariableyassociatedwiththecovariatex 1,x 2andx3 was generatedasfollow:Arandomvariableuisgeneratedfromauniformdistributionover theinterval(0,1).Theresponseywasassignedavalue1,if π (x) ≥ u ,and0otherwise.

Theproposed2grouppartitiontestwithcutoffpointsetat50 th percentileofthe estimatedprobabilityfromtheassumedmodelandthesixknowntestsmentioned beforewereappliedtotherandomsamplesgeneratedfrommodel(4.5)atlevelof significance α = .0 05 1.0, .TheobservedrejectionratesarepresentedinTable46,where thesamelabelsusedtoidentifyingvarioustestsinsection4.2areusedhere.

75 Table46ObservedTypeIErrorRateforSimulationStudyThree Sample Size Methods α=0.05 α=0.10 Ĉ 0.04 0.095 Ĥ 0.072 0.119 D 0.537 0.771 100 P 0.006 0.007 O.S. 0.436 0.478 ST. 0.087 0.146 New 0.064 0.127 Ĉ 0.041 0.089 Ĥ 0.054 0.096 D 0.894 0.972 200 P 0.001 0.004 O.S. 0.288 0.351 ST. 0.066 0.119 New 0.061 0.128 Ĉ 0.044 0.095 Ĥ 0.074 0.116 D 1 1 500 P 0.001 0.001 O.S. 0.139 0.189 ST. 0.052 0.105 New 0.055 0.108

FromTable46,whentheassumedmodelisthecorrectmodel,theDeviance testcannotcontroltypeIerrorratewiththesethreedifferentsamplesizes,andthe rejectionrateincreasesasthesamplesizeincreases.Forexample,whenn=500,there are100percentchancetorejectthenullhypothesiswithα=0.05andα=0.10.The largersamplesizeshelpOsiusandRojek’sapproximatelynormaltesttoreducethe rejectionrateunderthenullhypothesis.Unfortunately,OsiusandRojek’sapproximately normaltestcannotcontrolthetypeIerrorrateinthissimulationstudy.TypeIerror ratesofPearsonChisquaretestarelessthanthelowerboundof95%confidence

76 interval(Table42)withdifferentlevelofsignificancelevelandsamplesizes.TypeI errorrateofHosmerandLemeshow’sĤtest,HosemerLemeshow’sĈ,Stukel’sscore testandproposedtestareveryclosetoorfallwithin95%confidenceintervalwhen samplesizesare100,200and500.

Next,therandomsamplesweregeneratedbythefollowingmodel:

π log( ) = β + β x + β x + β x + β x x x (4.6) 1−π 0 1 1 2 2 3 3 4 1 2 3

where β 4 takesthevalues0,0.2,0.4,0.6,0.8,respectively.Theproposed2group partitiontestandthesixknowntestswereappliedtotherandomsamplegenerated from(4.6)totestthegoodnessoffitoftheassumedmodel(4.5)atthelevelof significance α = .0 05.TherejectionratesofthesetestswerepresentedintheTable47 andgraphicallyinFigure44to46.

Table47RejectionRatesfortheKnownandProposedTestsforStudyThree Sample Size β Ĉ Ĥ D P O.S. ST. New 0 0.04 0.072 0.537 0.006 0.436 0.087 0.064 0.2 0.051 0.097 0.669 0.001 0.628 0.135 0.239 100 0.4 0.092 0.156 0.792 0.003 0.785 0.217 0.483 0.6 0.154 0.196 0.865 0.002 0.844 0.279 0.607 0.8 0.186 0.232 0.901 0 0.88 0.337 0.673 0 0.041 0.054 0.894 0.001 0.288 0.066 0.061 0.2 0.074 0.12 0.959 0.002 0.633 0.128 0.354 200 0.4 0.146 0.209 0.984 0.004 0.799 0.242 0.638 0.6 0.203 0.251 0.995 0.002 0.874 0.324 0.75 0.8 0.251 0.284 0.997 0 0.916 0.379 0.81 0 0.044 0.074 1 0.001 0.139 0.052 0.055 0.2 0.085 0.181 1 0.001 0.573 0.178 0.642 500 0.4 0.178 0.285 1 0 0.819 0.336 0.885 0.6 0.267 0.347 1 0 0.905 0.386 0.905 0.8 0.308 0.373 1 0 0.932 0.439 0.906

77 Figure47PlotsofRejectionRateforStudyThree(n=100)

1 0.9 0.8 0.7 Ĉ 0.6 Ĥ 0.5 D P 0.4 O.S.

RejectionR0.3 atem ST. 0.2 New 0.1 0 0 0.2 0.4 0.6 0.8 beta2 Figure48PlotsofRejectionRateforStudyThree(n=200)

1 0.9 0.8 0.7 Ĉ 0.6 Ĥ 0.5 D P 0.4 O.S.

R ejectionR0.3 atem ST. 0.2 New 0.1 0 0 0.2 0.4 0.6 0.8 beta2

78 Figure49PlotsofRejectionRateforStudyThree(n=500)

1 0.9 0.8 0.7 Ĉ 0.6 Ĥ 0.5 D P 0.4 O.S.

RejectionRatem 0.3 ST. 0.2 New 0.1 0 0 0.2 0.4 0.6 0.8 beta2 ThesimulationresultssuggestthatthepowerofdetectinglackoffitforPearson Chisquaretestispoorfordifferentsamplesizesanddegreeofdeparturefromthetrue model.SinceDeviancetesthasveryhightypeIerrorrate,itisnotnecessaryto compareitspowerwithothertests.Onceagain,thissimulationstudygivesastrong evidencethatthePearsonChisquaretestandDeviancetestarenotapplicabletothe Typeonecovariatepattern(J=n).OsiusandRojek’sapproximatelynormaltestis powerfultorejectthenullhypothesiswhentheassumemodelisnotcorrectone.Inthis simulationstudy,therejectionrateofStukel’sscoretest,HosmerLemeshowĤandĈ testsarealmostsameornearlyclosewhentheassumedmodelisnotthetruemodel. Theproposedtestisthebesttestamongtheseventestsbecauseitcontrolsthetype oneerrorrateandhasstrongpowertorejecttheassumedmodelwhenitisnottrue one.Inaddition,thepowerincreaseswhenthesamplesizeincreases.

79 4.4TheFourthSimulationStudy Inthepreviousthreesimulationstudies,thetermsomittedfromthegenerating modelareassociatedwiththecovariatesintheassumedmodel.Inthissimulation study,thecovariateintheassumedmodelisnotrelatedtotheaddedtermsinthe generatingmodel. Thenullhypothesisisthatthefollowingmodeladequatelyfitsthedata.

π log( ) = β + β x (4.7) 1− π 0 1 1

where β0 = − 3.0 , β1 = 3.1 , x1 ~ u(− )6,6

Letthegeneratingmodelbe

π log( ) = β + β x + β x (4.8) 1− π 0 1 1 2 2

Where x2 ~ Bernulli )5.0( and β 2 takesonthevalues0,2,…,10.

Inthissimulationstudy,1000randomsamplesofsizen=100,200,500were respectivelygeneratedfrommodel(4.5)withcovariatex1independentlygeneratedfrom auniformdistributionovertheinterval(6,6),thecovariatex 2independentlygenerated fromtheBernoullidistributionwithprobability0.5.Theresponsevariableyassociated withthecovariatex 1,x 2wasgeneratedthesamewayasintheprevioussimulation studies.

Theproposed2grouppartitiontestwithcutoffpointsetatthe50 th percentileof theestimatedprobabilityfromtheassumedmodelandthesixknowntestsmentioned beforewereappliedtotherandomsamplesgeneratedfromassumedmodel(4.7)at

80 levelofsignificance α = .0 05 1.0, .TheobservedrejectionratesarepresentedinTable4

7,thelabelsofvarioustestsaresameasthoseusedintheprevioussimulationstudies.

Table48ObservedTypeIErrorRateforSimulationStudyFour Sample Size Method α=0.05 α=0.10 Ĉ 0.04 0.067 Ĥ 0.041 0.096 D 0 0 100 P 0.082 0.093 O.S. 0.002 0.004 ST. 0.081 0.154 New 0.063 0.131 Ĉ 0.078 0.099 Ĥ 0.036 0.085 D 0 0 200 P 0.14 0.15 O.S. 0.005 0.007 ST. 0.064 0.128 New 0.058 0.106 Ĉ 0.087 0.107 Ĥ 0.057 0.118 D 0 0 500 P 0.193 0.204 O.S. 0.006 0.01 ST. 0.073 0.12 New 0.067 0.116 TheresultsinTable48indicatethatunderthenullhypothesis,therejectionrate ofPearsonChisquaretestincreasesasthesamplesizeincreaseswhichindicateitcan notcontroltypeIerrorrate.TypeIerrorratesofChisquaretestaregreaterthanthe upperboundof95%confidenceinterval(Table42)whenn=200andn=500.The rejectionrateofdeviancetestis0percentwhenthenullhypothesisistrueregardless ofthesamplesizeandlevelofsignificance.ThetypeIerrorratesofStukel’sscoretest arehigherthanthenominalvalueexceptn=200andα=0.05.AlltypeIerrorratesof OsiusandRojek’sapproximatelynormaltestarelowerthanthelowerboundof95% confidenceintervalinthissimulationstudy.AllthetypeIerrorratesoftheproposedtest

81 andHosmerLemeshow’sĤtestliewithinthe95%ofconfidenceintervalorveryclose tothelimits. Table49RejectionRatesfortheKnownandProposedTestsforStudyFour

size β4 Ĉ Ĥ D P O.S. ST. New 0 0.053 0.041 0 0.082 0.002 0.081 0.063 2 0.044 0.036 0 0.084 0.002 0.095 0.066 100 4 0.023 0.052 0 0.041 0.001 0.154 0.079 6 0.028 0.096 0 0.009 0 0.237 0.164 8 0.08 0.194 0 0.002 0.002 0.41 0.395 10 0.126 0.289 0 0.001 0.016 0.559 0.544 0 0.078 0.036 0 0.141 0.005 0.064 0.058 2 0.037 0.037 0 0.123 0.001 0.08 0.055 200 4 0.02 0.065 0 0.042 0 0.16 0.079 6 0.072 0.169 0 0.011 0.001 0.4 0.275 8 0.21 0.389 0 0 0.037 0.732 0.692 10 0.397 0.6 0 0 0.19 0.876 0.842 0 0.087 0.057 0 0.193 0.006 0.073 0.067 2 0.037 0.055 0 0.136 0.004 0.084 0.057 500 4 0.05 0.148 0 0.029 0.001 0.309 0.166 6 0.309 0.447 0 0.001 0.002 0.787 0.646 8 0.76 0.858 0 0 0.475 0.986 0.982 10 0.943 0.969 0 0 0.881 0.999 0.998 Figure410PlotsofRejectionRateforStudyFour(n=100)

1 0.9 0.8 0.7 Ĉ 0.6 Ĥ 0.5 D P 0.4 O.S.

RejectionRatem 0.3 ST. 0.2 New 0.1 0 0 2 4 6 8 10 beta2

82 Figure411 PlotsofRejectionRateforStudyFour(n=200)

1 0.9 0.8 0.7 Ĉ 0.6 Ĥ 0.5 D P 0.4 O.S.

RejectionRatem 0.3 ST. 0.2 New 0.1 0 0 2 4 6 8 10 beta2 Figure412 PlotsofRejectionRateforStudyFour(n=500)

1 0.9 0.8 0.7 Ĉ 0.6 Ĥ 0.5 D P 0.4 O.S.

RejectionRatem 0.3 ST. 0.2 New 0.1 0 0 2 4 6 8 10 beta2 TheresultsinTable49indicatethatthepowerofPearsonchisquaretest Deviancetestarepoor.Inaddition,theirpowerofdetectinglackoffitcannotbe

83 improvedbylargersamplesizesorfurtherdeparturefromthetruemodel.TheOsius andRojek’sapproximatelynormaltesthaspoorpowerofdetectingthelackoffit,when n=100andn=200.Thepowerisimprovedbythelargersamplesizeandfurther departurefromthetruemodel.TheperformanceofHosmerLemeshowĤtestisbetter thanthatofHosmerLemeshow’sĈtest.HosmerLemeshowĤtestcontroltypeIerror ratewellandhasahigherpowerofdetectingthelackoffitwhenn=100,n=200and500 underthealternativehypothesis.Stukel’sscoretestfollowedbytheproposedtesthas thehighestpowerofdetectingthelackoffitunderthealternativemodel.Theproposed methodhadgoodperformanceinthissimulationincontrollingtypeIerrorratewelland indetectinglackoffitwhenitispresentintheassumedmodel.

84 4.5SummaryonSimulationStudies Thesefoursimulationscoverfourdifferentsituations.Thesefourdifferent simulationstudiesprovideevidenceagainthatthegoodnessoffittestsofPearsonchi squareanddeviancearenotsuitablewhenthenumberofuniquecovariatepatternsis equaloralmostequaltothenumberofsubjects. HosmerLemeshowĤtestandproposedtestalwayscontroltypeIerrorratewell inthesefourstudies.HosmerLemeshowĈtestandStukel’sscoretestcontroltypeI errorinthefirstthreesimulationstudies;inthefourthstudy,theycannotcontroltypeI errorratewhenα=0.05andn=500.TheOsiusandRojek’sapproximatelynormaltest controlstypeIerrorrateinthefirstsimulationstudy.Intheotherthreestudies,the abilityofcontrollingtypeIerrorrateoftheOsiusandRojek’sapproximatelynormaltest isaffectedbythesamplesizeandthedegreeofdeparturefromthetruemodel. Thefirstandforthsimulationsinvolveasimplelogisticregressionmodel (assumedmodelhasonlyonepredictorvariable).Whentheassumedmodelisa simplemodel,Stukel’sscorehashigherpowerofdetectinglackoffitthanothers.The orderofpoweris,Stukel>porposedtest>HosmerLemeshowtests>OsiusandRojek’s approximatelynormaltest.HosmerLemeshowĈtestisbetterthanHosmerLemeshow Ĥtestinthefirstsimulation;however,HosmerLemeshowĤtestisbetterthanHosmer LemeshowĈtestinthefourthsimulation. Thesecondandthirdsimulationsconsideredmultiplelogisticregressionmodel (assumedmodelhasmorethanonepredictorvariables).Theproposedtestperforms bestamongalltestsconsidered.ItcontrolstypeIerrorratewellandhashigherpower todetectlackoffit.

85 4.6ConvergenceProblemintheSimulationStudies Theparametersoflogisticregressionmodelsareestimatedbythemaximum likelihoodmethod.Theloglikelihoodisastrictlyconcavefunctionandthemaximum likelihoodestimatesoftheparametersexistandareunique(Wedderburn1976).Two generaliterativealgorithmsareusuallyusedtoobtainthemaximumlikelihoodestimates andareavailableinSASforalogisticregressionmodel:theNewtonRaphsonalgorithm andtheFisherscoringalgorithm.TheFisherscoringalgorithmisthedefaultmethodin

SASPROCLOGISTIC,whichisequivalenttofittingthemodelbyiterativelyreweighed leastsquares.Sameparameterestimatesandaslightlydifferentestimated matricesaregivenbythesetwoalgorithms,thereasonisthattheFisherscoring algorithmisbasedontheexpectedinformationmatrixandtheNewtonRaphson algorithmisbasedontheobservedinformationmatrix.

Letthefirstderivativesandsecondderivativesoftheloglikelihoodfunctionbe, respectively

∂l(β) U(β ) = = ∑xi yi − ∑xi yi ∂β i i

2 ∂ l(β) ' I(β ) = = ∑xi xi yi 1( − yi ) ∂β∂β' i

ThentheiterativeequationoftheNewtonRaphsonalgorithmandFisherScoring algorithmare,respectively,

β(t+ )1 = β(t) − I −1 (β(t) )U(β(t) )

β(t+ )1 = β(t) + E[I −1 (β(t ) )]U(β(t ) )

86 Forlargeiterationtandj th (j=1,2,…,p)parameter,theconvergencesatisfies,

(t+ )1 ˆ (t) ˆ β j − β j ≤ c β j − β j forsomec>0

Forthelogisticregression,fortunately,itsloglikelihoodisgloballyconcave, whichindicateithasatmostonemaximum(Amemiya,1985).Infact,convergence worksmostofthetime,butnoteverytime.IftheHessianmatrix(thepartialsecond derivatives)issingularornearsingular,aconvergenceproblemoccurs,theestimated logisticregressionmodelisquestionableandnotreliable(Sherrod2003).Whenthe convergenceproblemoccurs,TianandLiu(2006)believethatthereexistsnotonlya numericalproblembutalsoanindicationthatthemodelisnotsuitableforfittingthe data.

AlbertandAnderson(1984)andSantnerandDuffy(1985)pointedoutthe existenceofmaximumlikelihoodestimatesforthelogisticmodeldependsonhowthe samplepointsaredistributed.Theexistenceofdataseparationwillleadtofailureto converge(PrusseeuwandChristmann,2003,Altman,GillandMcDonald,2004).Data separationcanbecategorizedintothreetypes:completeseparation,quasicomplete separation,andoverlap.Thedataarecompletelyseparated,ifthereexistsavector b thatallocatestheobservationstotheirtworesponsegroupsinthefollowingmanner:

Ifb’xi>0thenyi=1,

If b’xi<0thenyi=0.

Underthiscase,themaximumlikelihoodestimateforanycovariatesandcovariate patternsdoesnotexist(inanotherwords,thelikelihoodequationdoesnothaveafinite

87 solution).Thedataisquasicompletelyseparated,ifthereexistsacoefficientvector b suchthat

Ifb’xi≥0thenyi=1,

If b’xi<0theny i=0.

Underthiscase,themaximumlikelihoodestimatealsodoesnotexist.Underthecase ofquasicompleteseparation,asthenumberofiterationsincreases,theloglikelihood doesnotreachto0asinthecompleteseparationcaseandthedispersionmatrixis unbounded.Completeseparationandquasicompleteseparationalsoleadto convergencefailurewithotherlinkfunctionforbinaryresponsevariable,suchprobit link,logloglink.Thedatawhicharenotofcompleteorquasicompleteseparationtype iscalledoverlapdata.Themaximumlikelihoodestimateexistsandisuniqueforoverlap data.

TheempiricalmethodofAlbertandAnderson(1984)isbuiltinthePROC

LOGISTICinSAS.Itcanhelpusdetectthecompleteseparationandquasicomplete separationdata.AlbertandAnderson(1984)gavethefollowingthreestepsindetecting dataseparation:

1. Iftheconvergencecriteriaissatisfiedwitheightiteration,onedeclares

thatthereisnoproblem.

2. Aftereightiterations,theprobabilityofobservedresponsepredictedfor

theith subjectisobtainedby

1 yˆi = ˆ 1+ e[(2 yi − )1 βxi ]

Ifthepredictedprobabilityis1forallsubjectsafterthe8 th iteration,wedeclarethat completeseparationoccursandstoptheiteration.

88 3.Iftheobservedprobabilitiesforsomesubjectsarelargethan0.95,then examineestimatestandarderrorsforthatiteration.Iftheyexceedsomespecifiedvalue, wedeclarethatquasicompleteseparationoccursandstoptheiteration.

ThefollowingexampleillustratesthattheNewtonRaphsonalgorithmfailto convergeforacompleteseparationdatawithelevenseparationdatapoints(Table4

10).yistheresponsevariableandx 1andx 2aretwocovariates.

Table410CompleteSeparationData obs x1 x2 x22 b'x y 1 15 56 26 30 0 2 16 62 28 34 0 3 17 70 30 40 0 4 18 65 32 33 0 5 19 44 34 10 0 6 20 30 36 6 1 7 21 30 38 8 1 8 22 26 40 14 1 9 23 35 42 7 1 10 24 41 44 3 1 11 25 39 46 7 1 Figure413showsthatthevectorb=(4,2,1)’completelyseparatesthedata pointsintotworesponsegroups;thatis,allobservationswiththesameresponselieon thesamesideofthelinex 22=2x 14.

89 Figure413ScatterPlotSamplePointswithCompleteSeparationData

Theiterativehistoryoffittingalogisticregressionmodelontheabovedatais shownintheTable410.NoticethattheLoglikelihooddecreasesastheiteration increases.Theestimatedcovariancematricesforiterations0,5,15,and25areshown intheTable411whichindicatesthatthelikelylargervarianceofpseudoestimates mayoccurwiththenumberofiterationincreases.

90 Table411PartialLogisticIterationStepsPrintout

IterationHistoryForParameterEstimates Iter Ridge LogLikelihood Intercept X1 X3 0 0 1.8635644 3.1567224 0.342496 0.0771645 1 0 1.0049775 6.0528044 0.56796 0.1163513 2 0 0.5248162 9.2794008 0.832715 0.172829 3 0 0.2087828 11.199218 1.124201 0.2791172 4 0 0.0759306 12.549511 1.419777 0.400694 5 0 0.0279972 14.076113 1.720906 0.5193476 6 0 0.0103793 15.755734 2.028493 0.6368277 7 0 0.0038496 17.541144 2.341719 0.7541899 8 0 0.0014261 19.397439 2.659346 0.8718078 9 0 0.0005275 21.300264 2.980215 0.9897722 10 0 0.0001949 23.233159 3.303393 1.108065 11 0 0.0000719 25.185276 3.628187 1.2266328 12 0 0.0000265 27.149593 3.954098 1.3454174 13 0 9.7666E6 29.121624 4.280775 1.4643671 14 0 3.5969E6 31.09852 4.607978 1.58344 15 0 1.3243E6 33.078479 4.935542 1.7026037 16 0 4.8745E7 35.060364 5.263352 1.8218338 17 0 1.7939E7 37.043459 5.591331 1.941112 18 0 6.6014E8 39.027313 5.919427 2.0604251 19 0 2.429E8 41.011641 6.247603 2.1797634 20 0 8.937E9 42.996265 6.575835 2.2991199 21 0 3.2881E9 44.981071 6.904105 2.4184894 22 0 1.2097E9 46.965989 7.232402 2.5378684 23 0 4.45E10 48.950975 7.560718 2.6572541 24 0 1.637E10 50.936002 7.889046 2.7766446 25 0 6.023E11 52.921053 8.217383 2.8960387

WARNING: Convergence not attained in 25 iterations. WARNING: The procedure is continuing but the validity of the model fit is questionable. WARNING: The specified model did not converge. WARNING: Iteration limit exceeded.

91 Table412DispersionMatricesontheSelectedIterations EstimatedCovarianceMatrix Iter=0Loglikelhood= 1.8635644 Intercept X1 X2 Intercept 136.81 4.88128 0.88115 X1 4.88128 0.18724 0.02601 X2 0.88115 0.02601 0.008331 Iter=5Loglikelhood= 0.0279972 Intercept 9143.30 351.02 54.06806

X1 351.02 15.69193 0.95600 X2 54.06806 0.95600 0.90934 Iter=15Loglikelhood= 1.3243E6 Intercept 162328548 6318660 910109

X1 6318660 295466 10448.52 X2 910109 10448.52 18198.23 Iter=25Loglikelhood= 6.023E11 Intercept 5.72E13 5.075E11 3.55E10

X1 6.023E11 1.2061E9 2.3201E9 X2 1.2061E9 2.4307E8 4.6367E8

Completeseparationandquasicompleteseparationoftenoccurinsmallsparse dataset.Thecompleteseparationandquasicompleteseparationdatabelongtosparse datawhereeachcovariatepatternhasveryfewsubjects(Derr2000,Kuss2002).In simulationstudies,wedidencounterthenonconvergenceproblem.Forexample,inthe

92 firstsimulation,ifweusen=50with1000replications,nonconvergenceexistin17 replications;ifweusen=100,thenonconvergenceproblemdoesnotoccuranymore.

Thesmallerthedataset,thehigherthechanceofoccurrenceofcompleteseparationor quasicompleteseparation.

93

CHAPTER5Summary

Mostknowntestsperformwellindetectingtheoveralllackoffitforthetypetwo covariatepattern(J<

ChisquaretestandDeviancetestperformpoorlyforwhichtheyeithercannotcontrol typeIerrororhaveweakpowerindetectingthelackoffitoftheassumedmodel.

HosmerLemeshowtestsarerecommendedtosolvethisproblembycombiningmultiple uniquecovariatepatternsintoonegroup.Forthesimplelogisticregressionmodelinthe firstsimulationstudy,ourworkconfirmthatalltestswiththeexceptionofPearson squaretestandDeviancetesthavegoodperformance.Forthesimplelogistic regressionmodelinthefourthsimulationstudy,theproposedpartitiontest,Stukel’s scoretestandHosmerLemeshow’stestshavesimilarperformanceasinthefirst simulationstudy.OsiusandRojek’sapproximatelynormaltestcannotcontrolthetypeI errorratewithsmalldataset.Stukel’sscoretestisalittlebitbetterthantheproposed testforthesimplelogisticregressionmodel.

Forthemultiplelogisticregressionmodel(thesecondandthirdsimulation studies),theproposedmethodhasgoodcontroloftheTypeIerrorrate,andithas higherpowerindetectinglackoffitthantheknowntestsmentionedearlierunder

94 varioussettingsconsidered.Theproposedmethodismoresensitivethanotherknown testsindetectingthedepartureoftheassumedmodelfromthetruemodel.

Theproposedtesthasthebestoverallperformance.Itseemstoperformwell withoverallsteadyrejectionrate,withthetypeIrateslyingwithin95%confidence intervalinallsituationsconsidered.ForJ=nandmultiplelogisticregression,theresultof otherknowntestsseemednotreliable,theyareunabletocontroltypeIerrorrateor havepoorpowerindetectinglackoffit.

Inchapter3,theillustrativeexamplesshowedthattheproposedmethod performsfairlywellindetectingoveralllackoffit.Iftheoverallgoodnessoffittestis significant,wecanalsodeterminethenatureoflackoffit,forexample,checkingwhich partofthemodelof π (x) fittingthedatainadequately.Thiscouldbeusefulforthe researcherswhowanttobuildabettermodelandwanttoknowwhichpartsofhis/her modelfitthedataandwhichpartsdonot.Inthisdissertationwealsoproposeaforward stepwiseproceduretobuildapartitionlogisticregressionmodel,whichcanimprovethe fitofthestandardlogisticregressionmodel.

Theproposedmethodhassomeweakness,althoughitisgenerallyperforms betterthanotherknowntests.Theremaybeconvergeproblemwiththenumberof partitiongroupsincreases.Iftheassumedmodelistotallyincorrectandthereishuge differenceinthesuccessprobabilitiesbetweentheassumedandthetruemodel,the partitionmethodmaynotproduceamodelthatfitsbetterthantheassumedmodel.

95

CHAPTER6ExtensionandFutureStudy

Inthenearfuture,wewilltrytodothefollowing: (1) Extend the proposed idea of testing goodnessoffit to other generalized

linearmodels,suchas,loglinearmodels,ormultinomiallogisticregression

models.

(2) Provethatthesamplingdistributionoftheproposed test statistics can be

approximated by a chisquare distribution with appropriate degrees of

freedomwhenthesamplesizeislarge.

(3) Extendtheproposedideaoftestinggoodnessoffittocorrelateddatasets

for logistic regression and other generalized linear models, such as, log

linearmodels,multinomiallogisticregressionmodels.

96

CHAPTER7References

Agresti,A.,(1990).Categoricaldataanalysis.Wileyinterscience. AlbertA.andAnderson,J.A.(1984),Ontheexistenceofmaximumlikelihood estimatesinlogisticregressionmodels.Biometrika 71 ,110. Altman,M.,Gill,JandMcDonald,M.P.(2004)NumericalissuesinStatistical ComputingfortheSocialScientist.JohnWiley&Sons,Inc. Akaike,Hirotugu(1974).Anewlookatthestatisticalmodelidentification. IEEE TransactionsonAutomaticControl 19 (6):716–723. Coull,B.A.andAgresti,A.(2000)Randomeffectsmodelingofmultiplebinary responsesusingthemultivariatebinomiallogitnormaldistribution, Biometrics 56:7380.

Amemiya,Y.,1985Whatshouldbedonewhenanestimatedbetweengroup covariancematrixisnotnonnegativedefinite. Am.Stat. 39: 112–117.

ArandaOrdaz,F.J.(1981).Ontwofamiliesoftransformationstoadditivityfor binaryresponsedata. Biometrics 68,357363. Azzalinni,A.,Bowman,A.W.,Härdle.,W(1989).Ontheuseofnonparametric regressionformodelchecking. Biometrika76:112.

97 Bedrick,E.J.,andHill,J.R.,(1996).Assessingthefitoflogisticsmodelto individualmatchedsetsofcasecontroldata .Biometrics52,19. Berkson,J.(1944)Applicationoflogisticfunctiontobioassay. Journalofthe AmericanStatisticalAssociation 39,357365. Bender,R,Grouven,U.,(1996)Logisticregressionmodelsusedinmedical researcharepoorlypresented[letter].BMJ,313,628.

Bertolini,G.etal.(2000).Onemdel,severalresults:theparadoxoftheHosmer Lemeshowgoodnessoffittestforlogisticregressionmodel. Journalof and 5,251253.

Bliss,C.I.(1935),thecalculationoftheDosageMortalitycurve. Annalsof AppliedBiology 22 ,134167. Brown,C.C.(1982).Onagoodnessoffittestforthelogisticmodelbasedon scorestatistics. Communicationsinstatistics 11 , 10871105. Christensen,R.(1997).Loglinearmodelsandlogisticregression.2 nd ed.NY: Springer. Collet,D.(1991).Modelingbinarydata.ChapmanandHall,London. Cook,R.D.andWeisberg,S.(1982).Residualsandinfluenceinregression.New York:ChapmanandHall. Copas,J.B.(1983).PlottingPagainstx. ApliedStatsitics 32:2531.

98 Dalal,S.R.,Fowlkes,E.B.,andHoadley,B.(1989)Riskanalysisofthespace shuttle:Pre—Challengerpredicationoffailure. JournaloftheAmericanStatistical Association 84,954957. Derr,R.E.(2000).Performingexactlogisticregressionwiththe SAS system, SAS PaperP25425,1–10. Diggle,P.J.,Liang,K.Y.andZeger,S.L.(1994).Analysisoflongitudinaldata. NewYork:OxfordUniversityPress. Dreiseitl,S.etal.(2005).Nomographicrepresentationoflogisticregression models:acasestudyusingpatientselfassessmentdata. JournalofBiomedical Informatics 38,389394 Evans, SR,andLi,L.(2005).AComparisonofGoodnessofFitTestsforthe LogisticGEEModel, StatisticsinMedicine 24 :12451261. Fiegl,P.andZelen,M.(1965).Estimationofexponentialprobabilitieswith concomitantinformation. Biomertics 21 ,826838. Finney,D.J.(1941).Theestimationfromindividualrecordsoftherelationship betweendoseandquantalresponse. Biometrika 34 ,320324. Finney,D.J.(1971).Probitanalysis(3 rd ed.),Cambridge,U.K.:Cambridge Universitypress. Fowlkes,E.B.(1987).Somediagnosticsforbinarylogisticregressionvia smoothing. Biometrika 74:503515. Haberman,S.J.(1978)AnalysisofQualitativeData,1:IntroductoryTopics, AcademicPress,NewYork.

99 Hosmer,D.W.andLemeshow,S.(1989).Appliedlogisticregression.1 st ed.NY: WileyandSons. Hosmer,D.W.andLemeshow,S.(2000).Appliedlogisticregression.2 nd ed.NY: WileyandSons. Hosmer,D.W.,hosmer,T.,leCessie,S.,andLemeshow,S.(1997).A comparisonofgoodnessoffittestsforlogisticregressionmodel. Statisticsin medicine 16:9,96580. Hosmer,D.W.,Lemeshow,S.,andKlar,J.(1988).Goodmessof–fittestingfor themultiplelogisticsregressionanalysiswhentheestimatedprobabilitiesare small. BiometricalJourna, 30, 911924. Hosmer,D.W.,Lemeshow,S.(1980).Agoodness–of–fittestforthemultiple logisticregressionmodel. CommunicationsinStatistics A10, 10431069. Johnson,W.(1985).Influencemeasurementforlogisticregression:Anotherpoint ofview. Biometricka72 ,5965. Kuss,O.(2002).Globalgoodnessoffittestsinlogisticregressionwithsparse data. StatisticsinMedicine 21,37893801. Landwehr,J.M.,Pregibon,D.,andShoemaker,A.C.(1984).Graphicalmethods forassessinglogisticregressionmodels(withdiscussion). Journalofthe AmericanStatisticalAssociation 79:6183. Lavine,M.(1991),Problemsinextrapolationillustratedwithpaceshuttleoring data(withdiscussion), JournaloftheAmericanStatisticalAssociation86 ,9191 921.

100 LeCessie,S.,andvanHouwelingen,J.C.(1991).Agoodnessoffittestforbinary regressionmodelsbasedonsmoothingmethods. Biometrics 47: 12671282. Lemeshow,S.,andHosmer,D.W.(1982).Theuseofgoodness–of–fitstatistics inthedevelopmentoflogisticsregressionmodels.AmericanJournalof Epidemiology 115 ,92106. LuigiBocconi,acuradiR.Piccarreta.(1993).CategoricalDataAnalysis. QuadernidelCorsoEstivodiStatisticaeCalcolodelleProbabilita;,n.4.,Istituto diMetodiQuantitativi,Universita. Martz,H.F.andZimmer,W.J.,(1992),Theriskofcatastrophicfailureofthesolid rocketboosteronthespaceshuttle. TheAmerican 46 ,4247. McCullagh,P.andNelder,J.A.(1989).Generalizedlinearmodel.London: ChapmanandHall. Milicer,H.,andSzczotka,F.(1996),AgeatMenarcheinWarsawGirlsin1965. Humanbiology 38,199203. Nelder,J.,andR.W.M.Wedderburn.(1972).Generalizedlinearmodels. J.Roy. Statist.Soc . A135 :370384. Osborne,M.R.(1992).Fisher’smethodofscoring. InternationalStatistical Review/RevueInternationaledeStatistique ,60:99117. Osius,G.,andRojek,D.(1992).NormalGoodnessoffittestsformultinomial modelswithlargedegreesoffreedom. JournaloftheAmericanStatistical Association 87 :11451152.

101 Pearson,K.(1900).Onacriterionthatagivensystemofdeviationsfromthe probableinthecaseofacorrelatedsystemofvariablesissuchthatitcanbe reasonablysupposedtohavearisenfromrandomsampling. Philos.Mag.,series 5, 50 :157175. Pregibon,Daryl(1981).Logisticregressiondiagnostics. AnnalsofStatistics9, 705724. Prentice,R.L.(1976).Ageneralizationoftheprobitandlogitmethodsfordose responsecurves. Biometrics 32 :761768. Pulkstenis,E.,Robinson,T.J.(2002)Twogoodnessoffittestsforlogistic regressionmodelswithcontinuouscovariates. StatisticsinMedicine21 ,7993. Rousseeuw,P.J.,Christmann,A.(2003).Robustnessagainstseparationand outliersinlogisticregression. ComputionalStatistics&DataAnalysis43,315 332. SAS/STATsoftware(2003).SASInstitute,Cary,NC. SASdocumentv8 http://v8doc.sas.com/sashtml/ SantnerT.J.andDuffy,E.D.(1986).AnoteonA.AlbertandJ.A.Anderson’s conditionsfortheexistenceofmaximumlikelihoodestimatesinlogistic regressionmodels.Biometrika73 ,pp.755758. Schwarz,G.,(1978).Estimatingthedimensionofamodel. AnnalsofStatistics6, 461464.

102 Sherrod,P.H.,DTREGpredictivemodelingsoftware(2003),DTREG.inc. Stukel,T.A.(1988).Generalizedlogisticmodels. JournalofAmericanStatistical Association83 ,426431. Tabachnick,B.,andFidell,L.(1996).Usingmultivariatestatistics,thirdedition. HarperCollins. Tian,LandLiu,L(2006).ALettertotheEditorRE:"EASYSAS CALCULATIONSFORRISKORPREVALENCERATIOSANDDIFFERENCES" AmericanJournalofEpidemiology 163(12):11571158. Tan,Q.,et.al(2004).Haplotypeeffectsonhumansurvival:logisticregression modelsappliedtounphasedgenotypedata. Annalsofhumangenetics68,168 175. Tsiatis,A.A.(1980).Anoteonagoodnessoffittestforthelogisticsregression model. Biometrika67 ,250251. Wedderburn,R.W.M.(1976).Ontheexistenceanduniquenessofthemaximum likelihoodestimatesforcertaingeneralizedlinearmodels. Biometrika 63 :2732. Whittaker,E.T.andWatson,G.N.(1990).Acourseinmodernanalysis.4thed. Cambridge,England:CambridgeUniversityPress.

103 AppendixADataonORingFailure

Case Flight Failure Success Temperature 1 14 1 0 53 2 9 1 0 57 3 23 1 0 58 4 10 1 0 63 5 1 0 1 66 6 5 0 1 67 7 13 0 1 67 8 15 0 1 67 9 4 0 1 68 10 3 0 1 69 11 8 0 1 70 12 17 0 1 70 13 2 1 0 70 14 11 1 0 70 15 6 0 1 72 16 7 0 1 73 17 16 0 1 75 18 21 1 0 75 19 19 0 1 76 20 22 0 1 76 21 12 0 1 78 22 20 0 1 79 23 18 0 1 81

104

AppendixBDataonVasoconstriction

Constriction Volume Rate 1 0.825 3.7 1 1.09 3.5 1 2.5 1.25 1 1.5 0.75 1 3.2 0.8 1 3.5 0.7 0 0.75 0.6 0 1.7 1.1 0 0.75 0.9 0 0.45 0.9 0 0.57 0.8 0 2.75 0.55 0 3 0.6 1 2.33 1.4 1 3.75 0.75 1 1.64 2.3 1 1.6 3.2 1 1.415 0.85 0 1.06 1.7 1 1.8 1.8 0 2 0.4 0 1.36 0.95 0 1.35 1.35 0 1.36 1.5 1 1.78 1.6

105 0 1.5 0.6 1 1.5 1.8 0 1.9 0.95 1 0.95 1.9 0 0.4 1.6 1 0.75 2.7 0 0.03 2.35 0 1.83 1.1 1 2.2 1.1 1 2 1.2 1 3.33 0.8 0 1.9 0.95 0 1.9 0.75 1 1.625 1.3

106 AppendixCDataonLeukemiaSurvival

Survival Cellcount Log(cellcount) AG 1 2,300 3.36 + 1 750 2.87 + 1 4,300 3.63 + 1 2,600 3.41 + 0 6,000 3.78 + 1 10,500 4.02 + 1 10,000 4 + 0 17,000 4.23 + 0 5,400 3.73 + 1 7,000 3.84 + 1 9,400 3.97 + 0 32,000 4.51 + 0 35,000 4.54 + 0 52,000 4.71 + 0 100,000 5 + 0 100,000 5 + 1 100,000 5 + 1 4,400 3.63 _ 1 3,000 3.48 _ 0 4,000 3.6 _ 0 1,500 3.18 _ 0 9,000 3.95 _ 0 5,300 3.72 _ 0 10,000 4 _ 0 19,000 4.28 _ 0 27,000 4.43 _ 0 28,000 4.45 _

107 0 31,000 4.49 _ 0 26,000 4.41 _ 0 21,000 4.32 _ 0 79,000 4.89 _ 0 100,000 5 _ 0 100,000 5 _

108 AppendixDBeetleDataSet

Concentration Killed Exposed 1.6907 6 59 1.7242 13 60 1.7552 18 62 1.7842 28 56 1.8113 52 63 1.8369 53 59 1.861 61 62 1.8839 60 60

109

AppendixEWarsawGirlData

Numberof Numberof Age Menstruating Interviewed 9.21 0 376 10.21 0 200 10.58 0 93 10.83 2 120 11.08 2 90 11.33 5 88 11.58 10 105 11.83 17 111 12.08 16 100 12.33 29 93 12.58 39 100 12.83 51 108 13.08 47 99 13.33 67 106 13.58 81 105 13.83 88 117 14.08 79 98 14.33 90 97 14.58 113 120 14.83 95 102 15.08 117 122 15.33 107 111 15.58 92 94 15.83 112 114 17.58 1049 1049

110 AppendixFDatasetForIllustrativeExample3

year Gender agree disgree year Gender agree disgree 0 1 4 2 0 2 4 2 1 1 2 0 1 2 1 0 2 1 4 0 2 2 0 0 3 1 6 3 3 2 6 1 4 1 5 5 4 2 10 0 5 1 13 7 5 2 14 7 6 1 25 9 6 2 17 5 7 1 27 15 7 2 26 16 8 1 75 49 8 2 91 36 9 1 29 29 9 2 30 35 10 1 32 45 10 2 55 67 11 1 36 59 11 2 50 62 12 1 115 245 12 2 190 403 13 1 31 70 13 2 17 92 14 1 28 79 14 2 18 81 15 1 9 23 15 2 7 34 16 1 15 110 16 2 13 115 17 1 3 29 17 2 3 28 18 1 1 28 18 2 0 21 19 1 2 13 19 2 1 2 20 1 3 20 20 2 2 4 Note:gender“1”denotethemaleand“2”denotethefemale.

111 AppendixGDatasetforIllustrativeExample4

Income(MillionsofLira) NumberofCases CreditCards 24 1 0 27 1 0 28 5 2 29 3 0 30 9 1 31 5 1 32 8 0 33 1 0 34 7 1 35 1 1 38 3 1 39 2 0 40 5 0 41 2 0 42 2 0 45 1 1 48 1 0 49 1 0 50 10 2 52 1 0 59 1 0 60 5 2 65 6 6 68 3 3 70 5 3 79 1 0 80 1 0 84 1 0 94 1 0 120 6 6 130 1 1

112 AppendixHSASProgramCodeforSimulation Study

/*********************************************************************** ThefollowingSAScodewasusedinthefirstsimulationstudyanditwasusedtodetect theTypeIerrorrateatthelevelofsignificance0.05withsamplesize200.TheSAScodefor othercasesinthefirstsimulationstudyandthesecond,third,andfourthsimulationstudyare omittedduetosimilarities. *********************************************************************/ options nodate pageno=1 linesize=80 pagesize=60; options nonotes nosource; /*output format*/

/* define macro LOFtest*/

%macro LOFtest (howmany, quantile, condition); %do iter = 1 %to &howmany;

data set1; /* create covariates*/ do i =1 to 200; beta0=-0.3; beta1=1.3;beta2=0; x1=-2+4*ranuni(&iter+100); x2=x1*x1; output; end; run;

data set2; set set1; /*create the true probability*/ p=(exp(beta0+beta1*x1+beta2*x2))/(1+exp(beta0+beta1*x1+beta 2*x2)); do i =1 to 200; yy=ranuni(&iter+100); end; output; run;

data set3 ;set set2; /*create the response variable*/ if p>=yy then y=1; if p

113 proc logistic data=set3 desc; /*fit the assumed model*/ model y=x1/scale=none aggregate lackfit; output out=pha p=phat ; ods output FitStatistics=rLL2; ods output GlobalTests=dfr; ods output LackFitChiSq=HL; ods output goodnessoffit= pearchi; ods listing exclude all; run;

data HL1; set HL; /*hosmer-lemeshow’s c hat method*/

rename chisq= statistic probchisq=pvalue;run; data HL2; set HL1; cri=cinv(&quantile, df); if &condition then reject=1; else reject=0; pvalue=1-probchi(statistic, df); keep statistic df pvalue reject; run; proc append base=HLall data=HL2 force; run; data hlhat;set pha; /*hosmer-lemeshow h hat method*/ qhat=1-phat; if (phat ge 0.0 and phat le 0.1) then decile='D01'; if (phat ge 0.1 and phat le 0.2) then decile='D02'; if (phat ge 0.2 and phat le 0.3) then decile='D03'; if (phat ge 0.3 and phat le 0.4) then decile='D04'; if (phat ge 0.4 and phat le 0.5) then decile='D05'; if (phat ge 0.5 and phat le 0.6) then decile='D06'; if (phat ge 0.6 and phat le 0.7) then decile='D07'; if (phat ge 0.7 and phat le 0.8) then decile='D08'; if (phat ge 0.8 and phat le 0.9) then decile='D09'; if (phat ge 0.9 and phat le 1.0) then decile='D10'; run; proc sort data=hlhat; by decile; run; proc summary data=hlhat; by decile; var y phat qhat; output out=hlhat1 sum=ysm phatsum qhatsum n; run; data hlhat2; set hlhat1; yysum=_freq_-ysm;

114 o1=(ysm-phatsum)**2/phatsum; o2=(yysum-qhatsum)**2/qhatsum; run; proc summary data=hlhat2; var o1 o2; output out=hlhat3 sum= o1sum o2sum n;run; data hlhat4; set hlhat3; df=_freq_-2; statistic=o1sum+o2sum; if statistic>cinv(&quantile, df) then reject=1; else reject=0; pvalue=1-probchi(statistic, df); run; data HLhat5; set hlhat4; keep statistic df pvalue reject;run; proc append base=Hhatall data=HLhat5 force; run;

data Deviance; set pearchi; /*Deviance test*/ rename chisq=statistic; run; data definal; set deviance; _obs_=_n_; if _obs_='2' then delete; cri=cinv(&quantile, df); if &condition then reject=1; else reject=0; pvalue=1-probchi(statistic, df); keep statistic df pvalue reject; run; proc append base=Deall data=definal force; run;

data pefinal; set deviance; /*pearson chisquare*/ _obs_=_n_; if _obs_='1' then delete; cri=cinv(&quantile, df); if &condition then reject=1; else reject=0; pvalue=1-probchi(statistic, df); keep statistic df pvalue reject; run; proc append base=PEall data=pefinal force; run;

data pearchis; set pearchi; /*OS method*/ _obs_=_n_; if _obs_='1' then delete;

115 keep chisq df; run; run; data os1; set pha; v=phat*(1-phat); c=(1-2*phat)/v; run; proc reg data=os1; model c=x1; output out=os2 r=res; run; data os3; set os2; rss=v*res**2; run; proc data=os3; var rss; output out=os4 mean=rssi n=m; run; data os5; set os4; rsstot=rssi*m; run; data os6; merge os5 pearchis;run; data os7; set os6; z=(chisq-df)/sqrt(rsstot); statistic=abs(z); df=0; pvalue=2*(1-probnorm(statistic)); if pvalue< 1-&quantile then reject=1; else reject=0; keep statistic df pvalue reject ; run; proc append base=OSall data=OS7 force; run;

data reduce; /*stukel method*/ merge rLL2 dfr; keep criterion interceptandcovariates df; rename interceptandcovariates=r2ll df=rdf ; run; data reduce1; set reduce; obs=_n_; if obs<3 then delete;run; data phat ; set pha; g=log(phat/(1-phat)); if phat>=0.5 then z1=0.5*g*g; else z1=0; if phat<0.5 then z2=-0.5*g*g; else z2=0; run;

116 proc logistic data=phat desc; model y=x1 z1 z2 /scale=none aggregate; ods output FitStatistics=fLL2s; ods output GlobalTests=dffs; ods listing exclude all; run; data fulls; merge fLL2s dffs; keep criterion interceptandcovariates df; rename interceptandcovariates=f2ll df=fdf ; run; data full1s;set fulls; obs=_n_; if obs<3 then delete; run; data finalST; merge reduce1 full1s; statistic=r2ll-f2ll; df=2; cri=cinv(&quantile, df); if &condition then reject=1; else reject=0; pvalue=1-probchi(statistic, df); keep statistic df pvalue reject; run; proc append base=STall data=finalST force; run;

proc summary data=pha; /*proposed method*/ var phat; output out=medout median=mdphat;run; proc print data=medout; run; data medp; set medout; mdphat=mdphat; do i=1 to 200; output; end;run; data medpall; merge medp pha;run; data ready; set medpall; if phat<=mdphat then g1x1=x1; else g1x1=0; if phat<=mdphat then grp1=1; else grp1=0; if phat> mdphat then g2x1=x1 ; else g2x1=0;

117 if phat>mdphat then grp2=1; else grp2=0;run;

proc logistic data=ready desc; /*the proposed method*/ model y=grp1 grp2 g1x1 g2x1 / noint scale=none aggregate lackfit; ods output FitStatistics=fLL2; ods output GlobalTests=dff; ods listing exclude all; run; data full; merge fLL2 dff; keep criterion withcovariates df; rename withcovariates=f2ll df=fdf ; run; data full1;set full; obs=_n_; if obs<3 then delete; run; data finalYL; merge reduce1 full1; statistic=r2ll-f2ll; df=fdf-rdf-1; cri=cinv(&quantile, df); if &condition then reject=1; else reject=0; pvalue=1-probchi(statistic, df); keep statistic df pvalue reject; run; proc append base=YLall data=finalYL force; run;

%end; %mend LOFtest; /* end macro LOG test*/

%LOFtest (1000, 0.95, statistic>cri); /* test lack of fit*/

118 /*another macro to find the reject rate*/

%macro prob (inputname, outputname); proc means data=&inputname noprint; var statistic df pvalue reject; output out =&outputname mean=N=&inputname std=ss1 dd1 pp1 rr1; run; proc print data=&outputname; run; %mend prob;

%prob (HLall, out1) /* call macro prob for results */ %prob(Hhatall, out2) %prob (Deall, out3) %prob(Peall, out4) %prob (OSall, out5) %prob (Stall, out6) %prob (YLall, out7)

119