资源描述:
《A Modern Approach to Regression with R-StataPrimer.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、CharlesLindseyAModernApproachtoRegressionwithRStataPrimerMarch17,20091.Introduction1.1BuildingValidModelsStatacanbeusedtoperformanalysisintwoways.Inthefirstmethod,weentercommandsinteractivelyatthecommandline(orwindow).AfterwepressENTER,theenteredcommandisexecuted.Thism
2、ethodcanbeuse-fulwhenusersarefirstlearningStata,becausetheycanseepreciselywhateachcommanddoes.Alternatively,wemayentercommandsintoaseparatedocument,anddirectStatatoexecuteaportionofthatdocument.Thisdocumentshouldbesavedwitha“.do”fileextension.Toallowforthereplicationan
3、dad-justmentofanalysisatalaterdate,thisistherecommendedmethod.PreciselyhowbothmethodsareperformedwilldependonwhetherawindowedorcommandlineversionofStataisused.Inthisprimer,weas-sumethatthereaderexecuteseachcommandseparately(oratleastcare-fullylooksattheseparateoutputof
4、eachcommand).Itisnotrelevantwhethertheyusea“.do”fileorthecommandlineTheusershouldensurethatStata’scurrentdirectorycontainsthe“data”and“graphics”folders,thesupplied“.ado”files,andthe“scheme-ssccl.scheme”file.Therearecertaincommandsthatshouldbeexecutedatthestartofanewana
5、lysissessioninStata.Thisisthefirstoneweuse:setversion10.0Thisisthemostimportantcommand,andthefirstthatshouldbeex-ecuted.IttellsStatathatthefollowingcommandsshouldbeexecutedasifwewereusingthespecifiedversionofStata(version10inthiscase).So,whenwesaveourworkandre-executet
6、hesamecommandsatalaterdate(andpotentiallyadifferentversion),theywillbehaveastheydidoriginal-ly.All“.do”filesshouldhavethiscommandatthebeginning.clearallThenextcommandweexecutecompletelyclearsStata’smemory.Stataisverycarefulaboutmaintainingthecontentsofmemory,sothatwedo
7、121.Introductionnotaccidentallyoverwritedata,programs,etc.thatwewillstillneed.Byexecutingthiscommand,wetellStatathatwearecertainthatwenolongerneedanythinginmemory.setschemesscclThiscommandchangestheformatofStata’sgraphicstomatchthespe-cifiedscheme.The“ssccl”schememakes
8、graphicslookssimilartothoseinthetext.Asmentionedonthepreviouspage,weassumethatthe“scheme-ssccl.scheme”fileislocatedin