kkxxxy22110),0(2~Niid寻找回归关系graphboxvarlist建立回归方程,进行计算regressvar(independentvariable)varlist(dependentvariables)残差及其相关信息predict,(residual/rsstudent/xb/stdp/cooksd/leverage/)回归拟合图twoway残差及模型适合性检验残差:rvfplot(aresidual-versus-fittedplot)rvpplot(aresidual-versus-predictorplot)lvr2plot(aleverage-versus-squared-residualplot)正态性:pnorm;kdensity,normal;histogram,normal;sktest;swilk;多重共线性:vif异方差性:estathettest;estatimtest(峰度、偏度)outregestimatestore,estimatetablexml_tab;outreg2;estout;modltbl;mktab;outtex;est2texsysuseauto,cleargraphmatrixweightlengthdisplacementregressweightlengthdisplacementregressweightlengthpredictwhpredicte,residualtwowayscatterweightlength||linewhlengthscatterewhrvfplotrvpplotlengthpnormesktesteswilkekdensitye,normalhistograme,normalestathettestestatimtest为了研究回归关系的预测性,在回归分析中,并不是将所有的数据都用于模型参数估计,而是一部分用于估计,剩下一部分用于预测,检测预测值和真是值的关系。Stata中,运用e(sample)进行部分回归和预测。clearsysuseautosortmakeregmpgweightdisplacementheadroomifforeign==0predictr1ife(sample),rpredictr2if~e(sample),rpredictmpg_hat,xbsumr2clearsysuseautoregmpgweightoutregusingd:\temp.txt,replace3asterbdec(4)tdec(4)nolregmpgdisoutregusingd:\temp.txt,append3asterbdec(4)tdec(4)nolregmpgheadroomoutregusingd:\temp.txt,append3asterbdec(4)tdec(4)nolregmpgweightdisheadroomoutregusingd:\temp.txt,append3asterbdec(4)tdec(4)nolregmpgweightdisheadroomforeignoutregusingd:\temp.txt,append3asterbdec(4)tdec(4)nolclearsysuseautoregmpgweightoutregweightusingd:\temp.txt,replace3asterbdec(4)tdec(4)nolregmpgweightdisheadroomoutregweightusingd:\temp.txt,append3asterbdec(4)tdec(4)nolregmpgweightdisheadroomforeignoutregweightusingd:\temp.txt,append3asterbdec(4)tdec(4)nolclearsysuseautoregmpgweightoutregusingd:\temp.txt,replace3asterbdec(4)tdec(4)noladjr2regmpgdisoutregusingd:\temp.txt,append3asterbdec(4)tdec(4)noladjr2regmpgheadroomoutregusingd:\temp.txt,append3asterbdec(4)tdec(4)noladjr2regmpgweightdisheadroomoutregusingd:\temp.txt,append3asterbdec(4)tdec(4)noladjr2regmpgweightdisheadroomforeignoutregusingd:\temp.txt,append3asterbdec(4)tdec(4)noladjr2clearsysuseautotableforeigntableforeign,nolsummpgifforeign==0summpgifforeign==1tabstatmpg,s(Nmeanmediansdminmax)by(foreign)c(s)regmpgforeignclearsysuseautoregmpgweightgear_ratiolengthheadroomifforeign==0outregusingd:\temp.txt,replace3asterbdec(4)tdec(4)noladjr2regmpgweightgear_ratiolengthheadroomifforeign==1outregusingd:\temp.txt,append3asterbdec(4)tdec(4)noladjr2regmpgweightgear_ratiolengthheadroomforeignoutregusingd:\temp.txt,append3asterbdec(4)tdec(4)noladjr2clearwebuseunionprobitunionagegradenot_smsasouthlogitunionagegradenot_smsasouth