You are on page 1of 11

ROBLESbono2502 Friday February 25 19:19:50 2022 Page 1

___ ____ ____ ____ ____(R)


/__ / ____/ / ____/
___/ / /___/ / /___/
Statistics/Data Analysis

User: ROBLES

1 . do "C:\Users\57350\AppData\Local\Temp\STD6074_000000.tmp"

2 . **** BONO 25 DE FEBRERO 2022****


3 . **JENNY ALEJANDRA ROBLES POVEDA***
4 .
5 .
6 . clear

7 . set obs 65300


number of observations (_N) was 0, now 65,300

8 . set seed 65300

9 .
10 .
11 . gen genero=rnormal(10000,20000)

12 .
13 . replace genero=1 if genero <0
(20,170 real changes made)

14 . replace genero=0 if genero >1


(45,129 real changes made)

15 .
16 . gen marital=runiformint(1,7)

17 .
18 . gen w = runiform(800, 50000)

19 . gen eda = runiform(10, 40)

20 . gen educ = runiform(5, 20)

21 . gen exp = eda-educ+6

22 . gen exp2 =(exp^2)/100

23 .
24 .
25 . gen negro=runiformint(0,1)

26 . gen south=runiformint(0,1)

27 . gen urb=runiformint(0,1)

28 . gen lnw = log(w)

29 .
30 . *w eda educ exp exp2
31 .
32 .
33 .
34 .
35 . *PUNTO 1*
36 . *Con submuestra aleatoria de 30700, estimar probit y logit*
37 . bsample 30700

38 .
ROBLESbono2502 Friday February 25 19:19:50 2022 Page 2

39 . *se unen edad y genero para eliminar variables hombres


40 . sort genero eda

41 . drop if genero==1
(9,386 observations deleted)

42 .
43 . *Se dejan datos de mayores de 18 años
44 . drop if eda<18
(5,634 observations deleted)

45 .
46 . *se estipula el estado marital de mujeres casadas con mas de 18 añ
> os
47 . replace marital=0 if marital ==1
(2,267 real changes made)

48 . replace marital =0 if marital==2


(2,197 real changes made)

49 . replace marital =0 if marital==3


(2,283 real changes made)

50 . replace marital =0 if marital==5


(2,324 real changes made)

51 . replace marital =0 if marital==6


(2,239 real changes made)

52 . replace marital =0 if marital==7


(2,205 real changes made)

53 . replace marital =1 if marital==4


(2,165 real changes made)

54 .
55 .
56 . *OLS*
57 . regress marital eda

Source SS df MS Number of obs =


> 15,680
F(1, 15678) =
> 0.93
Model .110265147 1 .110265147 Prob > F =
> 0.3358
Residual 1865.95957 15,678 .119017704 R-squared =
> 0.0001
Adj R-squared =
> -0.0000
Total 1866.06983 15,679 .119017146 Root MSE =
> .34499

>
marital Coef. Std. Err. t P>|t| [95% Conf.
> Interval]

>
eda -.000415 .0004311 -0.96 0.336 -.0012601
> .0004301
_cons .1501184 .012813 11.72 0.000 .1250034
> .1752335

>
ROBLESbono2502 Friday February 25 19:19:50 2022 Page 3

58 .
59 . *probit con margins
60 .
61 . probit marital eda

Iteration 0: log likelihood = -6294.7632


Iteration 1: log likelihood = -6294.2998
Iteration 2: log likelihood = -6294.2998

Probit regression Number of obs =


> 15,680
LR chi2(1) =
> 0.93
Prob > chi2 =
> 0.3357
Log likelihood = -6294.2998 Pseudo R2 =
> 0.0001

>
marital Coef. Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda -.0018826 .0019556 -0.96 0.336 -.0057156
> .0019504
_cons -1.034452 .0579972 -17.84 0.000 -1.148124
> -.9207794

>

62 . margins , dydx (eda) atmeans

Conditional marginal effects Number of obs =


> 15,680
Model VCE : OIM

Expression : Pr(marital), predict()


dy/dx w.r.t. : eda
at : eda = 29.02422 (mean)

>
Delta-method
dy/dx Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda -.0004151 .0004311 -0.96 0.336 -.0012601
> .00043

>

63 .
64 .
65 . *logit con margins
66 .
67 . logit marital eda

Iteration 0: log likelihood = -6294.7632


Iteration 1: log likelihood = -6294.3
Iteration 2: log likelihood = -6294.2999

Logistic regression Number of obs =


> 15,680
LR chi2(1) =
> 0.93
Prob > chi2 =
> 0.3358
Log likelihood = -6294.2999 Pseudo R2 =
> 0.0001
ROBLESbono2502 Friday February 25 19:19:51 2022 Page 4

>
marital Coef. Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda -.0034871 .0036229 -0.96 0.336 -.0105879
> .0036137
_cons -1.730348 .1073058 -16.13 0.000 -1.940664
> -1.520033

>

68 . margins , dydx (eda) atmeans

Conditional marginal effects Number of obs =


> 15,680
Model VCE : OIM

Expression : Pr(marital), predict()


dy/dx w.r.t. : eda
at : eda = 29.02422 (mean)

>
Delta-method
dy/dx Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda -.0004149 .000431 -0.96 0.336 -.0012598
> .0004299

>

69 .
70 .
71 .
72 . *Sugerencias a mi modelo
73 . probit marital eda exp

Iteration 0: log likelihood = -6294.7632


Iteration 1: log likelihood = -6293.8935
Iteration 2: log likelihood = -6293.8935

Probit regression Number of obs =


> 15,680
LR chi2(2) =
> 1.74
Prob > chi2 =
> 0.4191
Log likelihood = -6293.8935 Pseudo R2 =
> 0.0001

>
marital Coef. Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda .0007474 .0035123 0.21 0.831 -.0061365
> .0076314
exp -.002616 .0029019 -0.90 0.367 -.0083036
> .0030717
_cons -1.052036 .0612014 -17.19 0.000 -1.171989
> -.9320836

>
ROBLESbono2502 Friday February 25 19:19:51 2022 Page 5

74 . probit marital eda exp educ

note: educ omitted because of collinearity


Iteration 0: log likelihood = -6294.7632
Iteration 1: log likelihood = -6293.8935
Iteration 2: log likelihood = -6293.8935

Probit regression Number of obs =


> 15,680
LR chi2(2) =
> 1.74
Prob > chi2 =
> 0.4191
Log likelihood = -6293.8935 Pseudo R2 =
> 0.0001

>
marital Coef. Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda .0007474 .0035123 0.21 0.831 -.0061365
> .0076314
exp -.002616 .0029019 -0.90 0.367 -.0083036
> .0030717
educ 0 (omitted)
_cons -1.052036 .0612014 -17.19 0.000 -1.171989
> -.9320836

>

75 . probit marital eda exp educ south

note: educ omitted because of collinearity


Iteration 0: log likelihood = -6294.7632
Iteration 1: log likelihood = -6293.4217
Iteration 2: log likelihood = -6293.4216

Probit regression Number of obs =


> 15,680
LR chi2(3) =
> 2.68
Prob > chi2 =
> 0.4431
Log likelihood = -6293.4216 Pseudo R2 =
> 0.0002

>
marital Coef. Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda .0007653 .0035125 0.22 0.828 -.006119
> .0076497
exp -.0026316 .0029021 -0.91 0.365 -.0083196
> .0030564
educ 0 (omitted)
south .0242865 .025003 0.97 0.331 -.0247184
> .0732915
_cons -1.064647 .0625775 -17.01 0.000 -1.187297
> -.9419972

>
ROBLESbono2502 Friday February 25 19:19:51 2022 Page 6

76 .
77 .
78 .
79 . *Al eliminar la variable de edad y dejar solo la experiencia nos p
> uede demostrar
80 . *que la variable no tiene una significacia relevante para indicar
> el modelo de
81 . *probabilidad para las mujeres.
82 .
83 . *Para probit con educ y south los niveles de significacia en este
> caso
84 . *aumentan la variable de edad.
85 .
86 .
87 . *PUNTO 2*
88 . *Repetir el punto 1 pero con un hombre mayor de edad de estar casa
> do con esposo
89 . *ausente no separado.
90 .
91 . clear

92 . set obs 65300


number of observations (_N) was 0, now 65,300

93 . set seed 65300

94 .
95 .
96 . gen genero=rnormal(10000,20000)

97 .
98 . replace genero=1 if genero <0
(20,170 real changes made)

99 . replace genero=0 if genero >1


(45,129 real changes made)

100 .
101 . gen marital=runiformint(1,7)

102 .
103 . gen w = runiform(800, 50000)

104 . gen eda = runiform(10, 40)

105 . gen educ = runiform(5, 20)

106 . gen exp = eda-educ+6

107 . gen exp2 =(exp^2)/100

108 .
109 .
110 . gen negro=runiformint(0,1)

111 . gen south=runiformint(0,1)

112 . gen urb=runiformint(0,1)

113 . gen lnw = log(w)


ROBLESbono2502 Friday February 25 19:19:51 2022 Page 7

114 .
115 .
116 . bsample 30700

117 .
118 .
119 . gen maritalnuev=runiformint(1,7)

120 .
121 .
122 .
123 . replace maritalnuev =0 if maritalnuev==2
(4,376 real changes made)

124 . replace maritalnuev =0 if maritalnuev==3


(4,494 real changes made)

125 . replace maritalnuev =0 if maritalnuev==4


(4,331 real changes made)

126 . replace maritalnuev =0 if maritalnuev==5


(4,493 real changes made)

127 . replace maritalnuev =0 if maritalnuev==6


(4,312 real changes made)

128 . replace maritalnuev =0 if maritalnuev==7


(4,346 real changes made)

129 . replace maritalnuev =1 if maritalnuev ==1


(0 real changes made)

130 .
131 .
132 . gen nuevogene = rnormal(10000,20000)

133 . replace nuevogene=1 if nuevogene <0


(9,493 real changes made)

134 . replace nuevogene=0 if nuevogene >1


(21,207 real changes made)

135 .
136 . sort nuevogene eda

137 . drop if nuevogene==0


(21,207 observations deleted)

138 .
139 .
140 . sort genero eda // *organizar las variables de edad y genero

141 . keep if genero ==0 //mujeres


(2,899 observations deleted)

142 .
143 . *Se dejan datos de mayores de 18 años
144 . drop if eda<18
(1,775 observations deleted)
ROBLESbono2502 Friday February 25 19:19:51 2022 Page 8

145 .
146 .
147 . * OLS
148 . regress maritalnuev eda

Source SS df MS Number of obs =


> 4,819
F(1, 4817) =
> 0.13
Model .014119222 1 .014119222 Prob > F =
> 0.7226
Residual 539.475401 4,817 .111994063 R-squared =
> 0.0000
Adj R-squared =
> -0.0002
Total 539.489521 4,818 .111973749 Root MSE =
> .33466

>
maritalnuev Coef. Std. Err. t P>|t| [95% Conf.
> Interval]

>
eda .0002668 .0007515 0.36 0.723 -.0012065
> .0017402
_cons .1206947 .0223672 5.40 0.000 .0768447
> .1645447

>

149 .
150 . *Probit marginsplot
151 .
152 . probit maritalnuev eda

Iteration 0: log likelihood = -1847.746


Iteration 1: log likelihood = -1847.6828
Iteration 2: log likelihood = -1847.6828

Probit regression Number of obs =


> 4,819
LR chi2(1) =
> 0.13
Prob > chi2 =
> 0.7222
Log likelihood = -1847.6828 Pseudo R2 =
> 0.0000

>
maritalnuev Coef. Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda .0012748 .0035858 0.36 0.722 -.0057533
> .008303
_cons -1.170837 .1068772 -10.95 0.000 -1.380313
> -.9613619

>
ROBLESbono2502 Friday February 25 19:19:51 2022 Page 9

153 . margins , dydx (eda) atmeans

Conditional marginal effects Number of obs =


> 4,819
Model VCE : OIM

Expression : Pr(maritalnuev), predict()


dy/dx w.r.t. : eda
at : eda = 29.06253 (mean)

>
Delta-method
dy/dx Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda .0002674 .0007522 0.36 0.722 -.0012069
> .0017418

>

154 .
155 .
156 . *logit margins
157 .
158 . logit maritalnuev eda

Iteration 0: log likelihood = -1847.746


Iteration 1: log likelihood = -1847.6829
Iteration 2: log likelihood = -1847.6829

Logistic regression Number of obs =


> 4,819
LR chi2(1) =
> 0.13
Prob > chi2 =
> 0.7225
Log likelihood = -1847.6829 Pseudo R2 =
> 0.0000

>
maritalnuev Coef. Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda .0023839 .0067127 0.36 0.722 -.0107728
> .0155406
_cons -1.984103 .200261 -9.91 0.000 -2.376607
> -1.591598

>

159 . margins , dydx (eda) atmeans

Conditional marginal effects Number of obs =


> 4,819
Model VCE : OIM

Expression : Pr(maritalnuev), predict()


dy/dx w.r.t. : eda
at : eda = 29.06253 (mean)
ROBLESbono2502 Friday February 25 19:19:52 2022 Page 10

>
Delta-method
dy/dx Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda .0002669 .0007514 0.36 0.722 -.0012059
> .0017396

>

160 .
161 .
162 . *sugerencias
163 . probit maritalnuev eda exp

Iteration 0: log likelihood = -1847.746


Iteration 1: log likelihood = -1847.423
Iteration 2: log likelihood = -1847.423

Probit regression Number of obs =


> 4,819
LR chi2(2) =
> 0.65
Prob > chi2 =
> 0.7239
Log likelihood = -1847.423 Pseudo R2 =
> 0.0002

>
maritalnuev Coef. Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda .0051833 .0065005 0.80 0.425 -.0075575
> .017924
exp -.0038945 .0054028 -0.72 0.471 -.0144839
> .0066948
_cons -1.196906 .1128668 -10.60 0.000 -1.418121
> -.9756908

>

164 . probit maritalnuev exp educ

Iteration 0: log likelihood = -1847.746


Iteration 1: log likelihood = -1847.423
Iteration 2: log likelihood = -1847.423

Probit regression Number of obs =


> 4,819
LR chi2(2) =
> 0.65
Prob > chi2 =
> 0.7239
Log likelihood = -1847.423 Pseudo R2 =
> 0.0002

>
maritalnuev Coef. Std. Err. z P>|z| [95% Conf.
> Interval]

>
exp .0012887 .003586 0.36 0.719 -.0057396
> .0083171
educ .0051833 .0065005 0.80 0.425 -.0075575
> .017924
_cons -1.228005 .1453 -8.45 0.000 -1.512788
> -.9432227
ROBLESbono2502 Friday February 25 19:19:52 2022 Page 11

>

165 . probit maritalnuev eda exp educ south

note: educ omitted because of collinearity


Iteration 0: log likelihood = -1847.746
Iteration 1: log likelihood = -1847.3973
Iteration 2: log likelihood = -1847.3973

Probit regression Number of obs =


> 4,819
LR chi2(3) =
> 0.70
Prob > chi2 =
> 0.8738
Log likelihood = -1847.3973 Pseudo R2 =
> 0.0002

>
maritalnuev Coef. Std. Err. z P>|z| [95% Conf.
> Interval]

>
eda .0051872 .0065005 0.80 0.425 -.0075535
> .017928
exp -.0039008 .0054031 -0.72 0.470 -.0144906
> .006689
educ 0 (omitted)
south .0104208 .0459749 0.23 0.821 -.0796884
> .1005299
_cons -1.202239 .1153013 -10.43 0.000 -1.428226
> -.9762529

>

166 .
167 .
168 .
169 .
170 . **PUNTO 3**
171 .
172 . *Explicar las diferenciasencontradas y proponer un modelo probit b
> ivariado
173 .
174 . biprobit (marital = w eda educ exp exp2) (maritalnuev = exp w sout
> h urb eda)
note: exp omitted because of collinearity
marital is never zero
r(2000);

end of do-file

r(2000);

175 .

You might also like