ebook img

Regression Models for Categorical Dependent Variables Using Stata PDF

311 Pages·2001·8.612 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Regression Models for Categorical Dependent Variables Using Stata

REGRESSION MODELS FOR CATEGORICAL DEPENDENT VARIABLES USING STATA J. SCOTT LONG Department of Sociology Indiana University Bloomington, Indiana JEREMY FREESE Department of Sociology University of Wisconsin-Madison Madison, Wisconsin This book is for use by faculty, students, staff, and guests of UCLA, and is not to be distributed, either electronically or in printed form, to others. A Stata Press Publication STATA CORPORATION College Station, Texas StataPress,4905LakewayDrive,CollegeStation,Texas77845 Copyright(cid:1)c 2001byStataCorporation Allrightsreserved TypesetusingLATEX2ε PrintedintheUnitedStatesofAmerica 10 9 8 7 6 5 4 3 2 1 ISBN1-881228-62-2 Thisbookisprotectedbycopyright. Allrightsarereserved. Nopartofthisbookmaybereproduced,stored in a retrieval system, or transcribed, in any form or by any means—electronic, mechanical, photocopying, recording,orotherwise—withoutthepriorwrittenpermissionofStataCorporation(StataCorp). Stata is a registered trademark of Stata Corporation. LATEX is a trademark of the American Mathematical Society. This book is for use by faculty, students, staff, and guests of UCLA, and is not to be distributed, either electronically or in printed form, to others. To our parents This book is for use by faculty, students, staff, and guests of UCLA, and is not to be distributed, either electronically or in printed form, to others. This book is for use by faculty, students, staff, and guests of UCLA, and is not to be distributed, either electronically or in printed form, to others. Contents Preface xv I GeneralInformation 1 1 Introduction 3 1.1 Whatisthisbookabout? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 Whichmodelsareconsidered? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3 Whoisthisbookfor? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.4 Howisthebookorganized?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.5 Whatsoftwaredoyouneed? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.5.1 UpdatingStata7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.5.2 InstallingSPost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.5.3 Whatifcommandsdonotwork? . . . . . . . . . . . . . . . . . . . . . . . 10 1.5.4 UninstallingSPost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.5.5 Additionalfilesavailableonthewebsite . . . . . . . . . . . . . . . . . . 11 1.6 WherecanIlearnmoreaboutthemodels? . . . . . . . . . . . . . . . . . . . . . . 11 2 IntroductiontoStata 13 2.1 TheStatainterface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.2 Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.3 Howtogethelp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.3.1 On-linehelp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.3.2 Manuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.3.3 Otherresources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.4 Theworkingdirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.5 Statafiletypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 This book is for use by faculty, students, staff, and guests of UCLA, and is not to be distributed, either electronically or in printed form, to others. viii Contents 2.6 Savingoutputtologfiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.6.1 Closingalogfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.6.2 Viewingalogfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.6.3 ConvertingfromSMCLtoplaintextorPostScript . . . . . . . . . . . . . 21 2.7 Usingandsavingdatasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.7.1 DatainStataformat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.7.2 Datainotherformats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.7.3 Enteringdatabyhand . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.8 Sizelimitationsondatasets∗ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.9 do-files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.9.1 Addingcomments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.9.2 Longlines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.9.3 Stoppingado-filewhileitisrunning. . . . . . . . . . . . . . . . . . . . . 25 2.9.4 Creatingdo-files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.9.5 Arecommendedstructurefordo-files . . . . . . . . . . . . . . . . . . . . 26 2.10 UsingStataforseriousdataanalysis . . . . . . . . . . . . . . . . . . . . . . . . . 27 2.11 ThesyntaxofStatacommands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.11.1 Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 2.11.2 Variablelists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 2.11.3 ifandinqualifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.11.4 Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.12 Managingdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.12.1 Lookingatyourdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.12.2 Gettinginformationaboutvariables . . . . . . . . . . . . . . . . . . . . . 33 2.12.3 Selectingobservations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.12.4 Selectingvariables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.13 Creatingnewvariables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.13.1 generatecommand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.13.2 replacecommand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 2.13.3 recodecommand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 2.13.4 CommontransformationsforRHSvariables . . . . . . . . . . . . . . . . . 39 2.14 Labelingvariablesandvalues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 2.14.1 Variablelabels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 This book is for use by faculty, students, staff, and guests of UCLA, and is not to be distributed, either electronically or in printed form, to others. Contents ix 2.14.2 Valuelabels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 2.14.3 notescommand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.15 Globalandlocalmacros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.16 Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 2.16.1 Thegraphcommand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 2.16.2 Printinggraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 2.16.3 Combininggraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 2.17 Abrieftutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3 Estimation,Testing,Fit,andInterpretation 63 3.1 Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3.1.1 Stata’soutputforMLestimation . . . . . . . . . . . . . . . . . . . . . . . 64 3.1.2 MLandsamplesize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 3.1.3 ProblemsinobtainingMLestimates . . . . . . . . . . . . . . . . . . . . . 65 3.1.4 Thesyntaxofestimationcommands . . . . . . . . . . . . . . . . . . . . . 66 3.1.5 Readingtheoutput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 3.1.6 Reformattingoutputwithoutreg . . . . . . . . . . . . . . . . . . . . . . . 72 3.1.7 Alternativeoutputwithlistcoef. . . . . . . . . . . . . . . . . . . . . . . . 73 3.2 Post-estimationanalysis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 3.3 Testing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 3.3.1 Waldtests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 3.3.2 LRtests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 3.4 Measuresoffit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 3.5 Interpretation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 3.5.1 Approachestointerpretation . . . . . . . . . . . . . . . . . . . . . . . . . 90 3.5.2 Predictionsusingpredict . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 3.5.3 Overviewofprvalue,prchange,prtab,andprgen . . . . . . . . . . . . . . 91 3.5.4 Syntaxforprchange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 3.5.5 Syntaxforprgen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 3.5.6 Syntaxforprtab. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 3.5.7 Syntaxforprvalue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 3.5.8 Computingmarginaleffectsusingmfxcompute . . . . . . . . . . . . . . . 96 3.6 Nextsteps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 This book is for use by faculty, students, staff, and guests of UCLA, and is not to be distributed, either electronically or in printed form, to others. x Contents II ModelsforSpecificKindsofOutcomes 97 4 ModelsforBinaryOutcomes 99 4.1 Thestatisticalmodel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 4.1.1 Alatentvariablemodel . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 4.1.2 Anonlinearprobabilitymodel . . . . . . . . . . . . . . . . . . . . . . . . 103 4.2 Estimationusinglogitandprobit . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 4.2.1 Observationspredictedperfectly . . . . . . . . . . . . . . . . . . . . . . . 107 4.3 Hypothesistestingwithtestandlrtest . . . . . . . . . . . . . . . . . . . . . . . . 107 4.3.1 Testingindividualcoefficients . . . . . . . . . . . . . . . . . . . . . . . . 108 4.3.2 Testingmultiplecoefficients . . . . . . . . . . . . . . . . . . . . . . . . . 110 4.3.3 ComparingLRandWaldtests . . . . . . . . . . . . . . . . . . . . . . . . 112 4.4 Residualsandinfluenceusingpredict. . . . . . . . . . . . . . . . . . . . . . . . . 112 4.4.1 Residuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 4.4.2 Influentialcases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 4.5 Scalarmeasuresoffitusingfitstat . . . . . . . . . . . . . . . . . . . . . . . . . . 117 4.6 Interpretationusingpredictedvalues . . . . . . . . . . . . . . . . . . . . . . . . . 119 4.6.1 Predictedprobabilitieswithpredict . . . . . . . . . . . . . . . . . . . . . 120 4.6.2 Individualpredictedprobabilitieswithprvalue . . . . . . . . . . . . . . . 122 4.6.3 Tablesofpredictedprobabilitieswithprtab . . . . . . . . . . . . . . . . . 124 4.6.4 Graphingpredictedprobabilitieswithprgen . . . . . . . . . . . . . . . . . 125 4.6.5 Changesinpredictedprobabilities . . . . . . . . . . . . . . . . . . . . . . 127 4.7 Interpretationusingoddsratioswithlistcoef . . . . . . . . . . . . . . . . . . . . . 132 4.8 Othercommandsforbinaryoutcomes . . . . . . . . . . . . . . . . . . . . . . . . 136 5 ModelsforOrdinalOutcomes 137 5.1 Thestatisticalmodel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 5.1.1 Alatentvariablemodel . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 5.1.2 Anonlinearprobabilitymodel . . . . . . . . . . . . . . . . . . . . . . . . 141 5.2 Estimationusingologitandoprobit. . . . . . . . . . . . . . . . . . . . . . . . . . 141 5.2.1 Exampleofattitudestowardworkingmothers . . . . . . . . . . . . . . . . 142 5.2.2 Predictingperfectly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 5.3 Hypothesistestingwithtestandlrtest . . . . . . . . . . . . . . . . . . . . . . . . 145 5.3.1 Testingindividualcoefficients . . . . . . . . . . . . . . . . . . . . . . . . 146 This book is for use by faculty, students, staff, and guests of UCLA, and is not to be distributed, either electronically or in printed form, to others. Contents xi 5.3.2 Testingmultiplecoefficients . . . . . . . . . . . . . . . . . . . . . . . . . 147 5.4 Scalarmeasuresoffitusingfitstat . . . . . . . . . . . . . . . . . . . . . . . . . . 148 5.5 Convertingtoadifferentparameterization∗ . . . . . . . . . . . . . . . . . . . . . 148 5.6 Theparallelregressionassumption . . . . . . . . . . . . . . . . . . . . . . . . . . 150 5.7 Residualsandoutliersusingpredict . . . . . . . . . . . . . . . . . . . . . . . . . 152 5.8 Interpretation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 5.8.1 Marginalchangeiny∗ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 5.8.2 Predictedprobabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 5.8.3 Predictedprobabilitieswithpredict . . . . . . . . . . . . . . . . . . . . . 156 5.8.4 Individualpredictedprobabilitieswithprvalue . . . . . . . . . . . . . . . 157 5.8.5 Tablesofpredictedprobabilitieswithprtab . . . . . . . . . . . . . . . . . 158 5.8.6 Graphingpredictedprobabilitieswithprgen . . . . . . . . . . . . . . . . . 159 5.8.7 Changesinpredictedprobabilities . . . . . . . . . . . . . . . . . . . . . . 162 5.8.8 Oddsratiosusinglistcoef . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 5.9 Lesscommonmodelsforordinaloutcomes . . . . . . . . . . . . . . . . . . . . . 168 5.9.1 Generalizedorderedlogitmodel . . . . . . . . . . . . . . . . . . . . . . . 168 5.9.2 Thestereotypemodel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 5.9.3 Thecontinuationratiomodel . . . . . . . . . . . . . . . . . . . . . . . . . 170 6 ModelsforNominalOutcomes 171 6.1 Themultinomiallogitmodel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 6.1.1 Formalstatementofthemodel . . . . . . . . . . . . . . . . . . . . . . . . 175 6.2 Estimationusingmlogit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 6.2.1 Exampleofoccupationalattainment . . . . . . . . . . . . . . . . . . . . . 177 6.2.2 Usingdifferentbasecategories . . . . . . . . . . . . . . . . . . . . . . . . 178 6.2.3 Predictingperfectly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 6.3 Hypothesistestingofcoefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 6.3.1 mlogtestfortestsoftheMNLM . . . . . . . . . . . . . . . . . . . . . . . 181 6.3.2 Testingtheeffectsoftheindependentvariables . . . . . . . . . . . . . . . 181 6.3.3 Testsforcombiningdependentcategories . . . . . . . . . . . . . . . . . . 184 6.4 Independenceofirrelevantalternatives . . . . . . . . . . . . . . . . . . . . . . . . 188 6.5 Measuresoffit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 6.6 Interpretation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 6.6.1 Predictedprobabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 This book is for use by faculty, students, staff, and guests of UCLA, and is not to be distributed, either electronically or in printed form, to others. xii Contents 6.6.2 Predictedprobabilitieswithpredict . . . . . . . . . . . . . . . . . . . . . 192 6.6.3 Individualpredictedprobabilitieswithprvalue . . . . . . . . . . . . . . . 193 6.6.4 Tablesofpredictedprobabilitieswithprtab . . . . . . . . . . . . . . . . . 194 6.6.5 Graphingpredictedprobabilitieswithprgen . . . . . . . . . . . . . . . . . 195 6.6.6 Changesinpredictedprobabilities . . . . . . . . . . . . . . . . . . . . . . 198 6.6.7 Plottingdiscretechangeswithprchangeandmlogview . . . . . . . . . . . 200 6.6.8 Oddsratiosusinglistcoefandmlogview . . . . . . . . . . . . . . . . . . . 203 6.6.9 Usingmlogplot∗ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 6.6.10 Plottingestimatesfrommatriceswithmlogplot∗ . . . . . . . . . . . . . . 209 6.7 Theconditionallogitmodel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 6.7.1 Dataarrangementforconditionallogit . . . . . . . . . . . . . . . . . . . . 214 6.7.2 Estimatingtheconditionallogitmodel . . . . . . . . . . . . . . . . . . . . 214 6.7.3 Interpretingresultsfromclogit . . . . . . . . . . . . . . . . . . . . . . . . 215 6.7.4 Estimatingthemultinomiallogitmodelusingclogit∗ . . . . . . . . . . . . 217 6.7.5 Usingclogittoestimatemixedmodels∗ . . . . . . . . . . . . . . . . . . . 219 7 ModelsforCountOutcomes 223 7.1 ThePoissondistribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 7.1.1 FittingthePoissondistributionwithpoisson . . . . . . . . . . . . . . . . . 224 7.1.2 Computingpredictedprobabilitieswithprcounts . . . . . . . . . . . . . . 226 7.1.3 Comparingobservedandpredictedcountswithprcounts . . . . . . . . . . 227 7.2 ThePoissonregressionmodel . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 7.2.1 EstimatingthePRMwithpoisson . . . . . . . . . . . . . . . . . . . . . . 230 7.2.2 ExampleofestimatingthePRM . . . . . . . . . . . . . . . . . . . . . . . 231 7.2.3 Interpretationusingtherateµ . . . . . . . . . . . . . . . . . . . . . . . . 232 7.2.4 Interpretationusingpredictedprobabilities . . . . . . . . . . . . . . . . . 237 7.2.5 Exposuretime∗ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 7.3 Thenegativebinomialregressionmodel . . . . . . . . . . . . . . . . . . . . . . . 243 7.3.1 EstimatingtheNBRMwithnbreg . . . . . . . . . . . . . . . . . . . . . . 244 7.3.2 ExampleofestimatingtheNBRM . . . . . . . . . . . . . . . . . . . . . . 245 7.3.3 Testingforoverdispersion . . . . . . . . . . . . . . . . . . . . . . . . . . 246 7.3.4 Interpretationusingtherateµ . . . . . . . . . . . . . . . . . . . . . . . . 247 7.3.5 Interpretationusingpredictedprobabilities . . . . . . . . . . . . . . . . . 248 7.4 Zero-inflatedcountmodels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 This book is for use by faculty, students, staff, and guests of UCLA, and is not to be distributed, either electronically or in printed form, to others.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.