FE-HW1
文章目录
Problem 1
sysuse nlsw88.dta, clear //调入第一问的数据
1-(1)
1-(1) 统计age grade wage hours ttl_exp tenure的平均值、标准差、中位数、最小值和最大值并输出为Excel 表格可以接受的格式
logout, save("$Out\Table01") excel replace: ///
tabstat age grade wage hours ttl_exp tenure, ///
stat(mean sd p50 min max) format(%7.2f) column(statistic)
** variable | mean sd p50 min max
**-------------+--------------------------------------------------
** age | 39.15 3.06 39.00 34.00 46.00
** grade | 13.10 2.52 12.00 0.00 18.00
** wage | 7.77 5.76 6.27 1.00 40.75
** hours | 37.22 10.51 40.00 1.00 80.00
** ttl_exp | 12.53 4.61 13.13 0.12 28.88
** tenure | 5.98 5.51 3.83 0.00 25.92
**----------------------------------------------------------------
**
1-(2)
1-(2) 产生新变量
gen age2 = age^2 //生成新变量age2等于age的平方
gen ln_wage = ln(wage) //生成新变量ln_wage等于wage的自然对数
egen wage_mean = mean(wage) //生成新变量wage_mean来表示wage的均值
gen dum = (wage>wage_mean) //生产新逻辑变量dum
1-(3)
1-(3) 绘制 ttl_exp 变量的直方图和密度函数图
histogram ttl_exp //绘制 ttl_exp 变量的直方图
graph export His_ttl.png
kdensity ttl_exp //绘制 ttl_exp 变量的密度函数图
graph export Kendi_ttl.png
由图形观察可知,ttl_exp的样本总体是一个右侧拖一个尾巴是正偏态分布
1-(4)
1-(4) 对industry做如下统计
1-(4)-(1)
1-(4)-(1) 每个行业的观察值个数
logout, save("$Out\1-(4)-1") excel replace: ///
tab industry
* tab industry
*
* industry | Freq. Percent Cum.
*------------------------+-----------------------------------
* Ag/Forestry/Fisheries | 17 0.76 0.76
* Mining | 4 0.18 0.94
* Construction | 29 1.30 2.24
* Manufacturing | 367 16.44 18.68
* Transport/Comm/Utility | 90 4.03 22.72
* Wholesale/Retail Trade | 333 14.92 37.63
*Finance/Ins/Real Estate | 192 8.60 46.24
* Business/Repair Svc | 86 3.85 50.09
* Personal Services | 97 4.35 54.44
* Entertainment/Rec Svc | 17 0.76 55.20
* Professional Services | 824 36.92 92.11
* Public Administration | 176 7.89 100.00
*------------------------+-----------------------------------
* Total | 2,232 100.00
1-(4)-(2)
1-(4)-(2) 各个行业妇女的平均工资(wage)、平均工作时数(hours)和平均年龄(age)
logout, save("$Out\1-(4)-2") excel replace: ///
bysort industry: tabstat wage hours age, ///
stat(mean) //分组统计
*-> industry = Ag/Forestry/Fisheries *-> industry = Mining
* stats | wage hours age * stats | wage hours age
*---------+------------------------------ *-