【2018年最新整理】第三讲多元线性回归模型检验及stata软件应用
The long-long form The wide-year long-sex form The wide-wide form The long-year wide-sex form Reshape命令详细解释:包括矩阵转置等 Reshape命令 *From long-long form to long-wide form reshape wide @inc, i(hid year) j(sex) string *From long-wide form to long-long form reshape long @inc, i(hid year) j(sex) string *From long-long form to wide-long form reshape wide inc, i(hid sex) j(year) *From wide-long form to long-long form reshape long inc, i(hid sex) j(year) *From long-wide form to wide-wide form reshape wide minc finc, i(hid) j(year) *From wide-wide form to long-wide form reshape long minc finc, i(hid) j(year) *From wide-long form to wide-wide form reshape wide @inc90 @inc91, i(hid) j(sex) string *From wide-wide form to wide-long form reshape long @inc90 @inc92, i(hid) j(sex) string @ :如果变量为字符型,如sex的值为f和m,要把inc变量生成finc和minc,则需要用@。 Collapse 命令 产生新的数据集 collapse (统计量) 变量, by (变量) collapse (mean) price, by(foreign) collapse (mean) mprice=price (sum) sprice=price, by(foreign) table foreign,c(mean price sum price) replace 统计功能 描述统计 交叉表格 估计 描述统计 Sum x Histogram twoway (histogram c, title("消费分析") xlabel(1000(500)6000) bfcolor(gs5)) scatter c y twoway(scatter c y) (qfit c y) twoway(scatter c y) (lfit c y) 调用数据库程序讲解(E:\panel) 作图 表格 Table 可以作四维表格 table foreign,c(n price mean price sd price max price min price) row table year region gender,c(mean price sd price max price min price) by(agegroup) row Tabulate tabulate vid,gen(vidumy) tabulate vid gender table year if (vcode~=vcode[_n+1]| vcode~=vcode[_n-1]) & vcow~=0,c(n vcode) do 文件的编写 编写do文件的作用 记录你的操作过程 减少命令的输入 do 文件的编写 Stata 中的do file编辑器 其它的软件:Textpad 其它一些常用命令 clear drop keep sum des list If 条件 bysort 变量 outreg ereturn list Outreg 生成像杂志那样的表格 Outreg using 文件名, coefastr p bdec(2) 3aster replace Outreg using 文件名, coefastr se 3aster append bdec(2): 留两位数 Coefastr:给系数加星号 P: 系数下面标P值 Se: 系数下面标标准误差 3aster: 加3个星号,1%,5%,10%。 outreg using table1, coefastr p bdec(2) 3aster repl