Download clear drop _all graph drop _all use "C:\POE4\cps4_small.dta", clear

Document related concepts
no text concepts found
Transcript
clear
drop _all
graph drop _all
use "C:\POE4\cps4_small.dta", clear
* Inciso a)
sum wage educ, detail
histogram wage, freq addlabels normal name(wage)
histogram educ, freq addlabels normal name(educ)
graph combine wage educ, title("Histogramas de Salario y Educación")
saving("C:\POE4\histogramas.GPH",replace)
* Inciso b)
regress wage educ
predict whatl
* Inciso c)
predict ehatl, residuals
matrix b=e(b)
gen efmargl=b[1,1]
format efmargl %4.2f
* Inciso d)
bysort female: regress wage educ
regress wage educ if black==1
regress wage educ if black==0 & asian==0
* Inciso e)
gen educ2=educ^2
regress wage educ2
predict whatc
predict ehatc, residuals
matrix b=e(b)
display "Efecto marginal de EDUC=12 a WAGE =", 2*b[1,1]*12
display "Efecto marginal de EDUC=14 a WAGE =", 2*b[1,1]*14
gen efmargc=2*b[1,1]*educ
* Inciso f)
sort educ
graph twoway (scatter wage educ) (line whatl educ) (line whatc educ), ytitle("Salario por hora")
title("Modelos estimados") legend(off) saving("C:\POE4\modelos.GPH",replace)
label var ehatl "Lineal"
label var ehatc "Cuadrático"
graph twoway (scatter ehatl educ, msymbol(Oh) msize(small)), ytitle("Residual") title("Residuales
modelo lineal") legend(off) saving("C:\POE4\residualesl.GPH",replace)
graph twoway (scatter ehatc educ,msymbol(+) msize(small)), ytitle("Residual") title("Residuales
modelo cuadrático") legend(off) saving("C:\POE4\residualesc.GPH",replace)
format efmargc %4.2f
graph twoway (scatter efmargl educ, mlabel(efmargl) mlabsize(vsmall) c(l)) (scatter efmargc educ,
mlabel(efmargc) mlabsize(vsmall) c(l) xlabel(0(2)22,grid)), ytitle("Salario por hora")
title("Cambios marginales") subtitle("Modelos lineal y cuadrático") legend(off)
saving("C:\POE4\efmarg.GPH",replace)
graph combine "C:\POE4\modelos.GPH" "C:\POE4\efmarg.GPH" "C:\POE4\residualesl.GPH"
"C:\POE4\residualesc.GPH", title("Modelos de regresión lineal simple Salario=f(Educación)")
saving("C:\POE4\resumen.GPH",replace)
* Inciso g)
gen lnwage=log(wage)
histogram lnwage, freq addlabels normal name(lnwage) title("Histograma del logaritmo del salario")
* Inciso h)
regress lnwage educ
predict whatlog
predict ehatlog, residuals
matrix b=e(b)
gen efmarglog=b[1,1]*exp(whatlog)
format efmarglog %7.4f
graph twoway (scatter efmarglog educ, mlabel(efmarglog) mlabsize(vsmall) c(l) xlabel(0(2)22,grid)),
ytitle("Salario por hora") title("Cambios marginales") subtitle("Modelo log(salario)=f(educación)")
legend(off) saving("C:\POE4\efmarglog.GPH",replace)
gen wagelog=exp(whatlog)
graph twoway (scatter wage educ) (line whatl educ) (line wagelog educ), ytitle("Salario por hora")
title("Modelos estimados") subtitle("Lineal y logarítmico") legend(off)
saving("C:\POE4\modelos2.GPH",replace)
graph twoway (scatter efmargl educ, mlabel(efmargl) mlabsize(vsmall) c(l)) (scatter efmargc educ,
mlabel(efmargc) mlabsize(vsmall) c(l)) (scatter efmarglog educ, mlabel(efmarglog) mlabsize(vsmall)
c(l) xlabel(0(2)22,grid)), ytitle("Salario por hora") title("Cambios marginales") subtitle("Modelos
lineal, cuadrático y logarítmico") legend(off) saving("C:\POE4\resumen_efm.GPH",replace)
400
150
Histogramas de Salario y Educación
132
328
300
121
100
110
106
Frequency
76
71
217
200
Frequency
88
171
50
49
100
109
35
30
28 29
2325
10
7 796 6
4 243
9
1
1
8
6
11811 16
26
0
11
0
7
88
0
20
40
60
earnings per hour
80
0
5
10
15
years of education
20
Modelos de regresión lineal simple Salario=f(Educación)
Cambios marginales
3.09
2.65
2.00
2.35
0.00
0
5
10
15
years of education
20
0
4
6
8 10 12 14 16 18 20 22
years of education
20 40 60
-40 -20
0
Residual
20 40 60
2
Residuales modelo cuadrático
-40 -20
0
1.98
0.00
Residuales modelo lineal
Residual
2.06
1.98 1.981.981.98
1.981.98
1.981.98
1.98
1.98 1.98 1.98
1.911.98
1.76
1.62
1.47
1.32
1.18
0.88
1.98
1.00
1.98
0.44
0
20
40
60
Salario por hora
80
3.00
Modelos estimados
0
5
10
15
years of education
20
0
5
10
15
years of education
20
100
Histograma del logaritmo del salario
98
83
80
82
77
72
65
60
60
56
57
65
59
40
49
38
37
20
18
18 18
13
3
1
1 2 2
4
0
1
10 11
1
2
3
lnwage
4
5
Cambios marginales
0.5000 1.0000 1.5000 2.0000 2.5000 3.0000
Modelo log(Salario)=f(Educación)
3.0180
2.3011
1.9204
1.6028
1.4642
1.3377
1.2220
1.1164
1.0199
0.9317
0.7776
0.5929
0.4520
0
2
4
6
8
10
12
14
years of education
16
18
20
22
Modelos estimados
0
20
40
60
80
Lineal y logarítmico
0
5
10
years of education
15
20
Cambios marginales
3.00
Modelos lineal, cuadrático y logarítmico
3.09
3.0180
2.65
2.00
2.35
1.98
1.98
2.06
1.98 1.98 1.98 1.98 1.98 1.98 1.98
1.91
1.98
1.98
1.9204
2.3011
1.98
1.98
1.76
1.00
1.62
1.6028
1.47
1.4642
1.3377
1.32
1.2220
1.18
1.1164
1.0199
0.9317
0.88
0.7776
0.5929
0.00
0.4520
0.44
0.00
0
2
4
6
8
10
12
14
years of education
16
18
20
22
Related documents