Sei sulla pagina 1di 5

//generar lista de variables

global ylist mpg


global x1list weight1
global xlist weight1 price foreign

describe $ylist $xlist


summarize $ylist $xlist
//mas detalle estadistica descriptiva de una variable (mpg)
summarize $ylist, detail

* CORRELACION
correlate $ylist $xlist

*GRAFICO
graph twoway (scatter $ylist $x1list)

* REGRESION SIMPLE
reg $ylist $x1list

* Grafico linea regresion


graph twoway (scatter $ylist $x1list)(lfit $ylist $x1list)

* Valores predichos para la variable dependiente


predict y1hat, xb
summarize $ylist y1hat
graph twoway (scatter $ylist $x1list)(scatter y1hat $x1list)

* Residuos (errores) de la regresion


predict e1hat, resid
summarize e1hat
graph twoway (scatter e1hat $x1list)

* Test hipotesis (coeficiente significativamente distinto a cero)


test $x1list

* Efectos Marginales (no obligatorio en MCO, se verá mas adelante con


otros modelos distintos)
quietly reg $ylist $x1list
margins, dydx(*) atmeans
margins, dydx(*)

* Regresion Multiple
reg $ylist $xlist

* Valores predichos para la variable dependiente


predict yhat, xb
summarize $ylist yhat

* Residuos
predict ehat, resid
summarize ehat

* Test hipotesis (coeficiente significativamente distinto a cero)


test $xlist

* Efectos Marginales
margins, dydx(*) atmeans
margins, dydx(*)

//test heterocedasticidad (post estimacion)


estat imtest
estat imtest, white
estat hettest

______________________

global ylist ins


global xlist retire age hstatusg hhincome educyear married hisp

describe $ylist $xlist


summarize $ylist $xlist

tabulate $ylist

* Regresion lineal
reg $ylist $xlist
reg ins retire age hstatusg hhincome educyear married hisp

* Probit
probit $ylist $xlist
probit ins retire age hstatusg hhincome educyear married hisp

* Logit
logit $ylist $xlist

* Efectos marginales (at the mean and average marginal effect)


quietly reg $ylist $xlist
margins, dydx(*) atmeans
margins, dydx(*)
//normalmente mco no calcula efectos marginales...SON iguales a los
coeficientes

quietly logit $ylist $xlist


margins, dydx(*) atmeans
margins, dydx(*)

quietly probit $ylist $xlist


margins, dydx(*) atmeans
margins, dydx(*)

*Logistic model gives odds ratio


logistic $ylist $xlist
* PROBABILIDADES PREDICHAS
quietly logit $ylist $xlist
predict plogit, pr

quietly probit $ylist $xlist


predict pprobit, pr

quietly regress $ylist $xlist


predict pols, xb

summarize $ylist plogit pprobit pols

* PORCENTAJE DE VALORES PREDICHOS CORRECTAMENTE


quietly logit $ylist $xlist
estat classification

quietly probit $ylist $xlist


estat classification

//experiencia:

gen exp=edad-esc-6

//capacitacion (1 si se capacito en los ultimos 12 meses y 0 no se ha capacitado)

gen cap=.

replace cap=1 if o30==1

replace cap=0 if o30!=1

//ingreso no salarial:

//asociada a la ariable y3f, pueden tomarla como numero considerando ese mismo valor. o
transformala en dicotomica de la siguiente manera: 1 si tiene ingreso no salarial y 0 en otro caso

//ins: ingreso no salarial

gen ins=.
replace ins=1 if y3f>=1

replace ins=0 if y3f==0

// para los que tengan la variable sexo, y sea mas sencillo de ver se puede recodificar, ya que sin
hacerlo las mujeres tienen el valor 2 asigando.

//por lo tanto se puede reasignar el valor 0:

replace sexo=0 if sexo==2

//variable dependiente o10:

// si observan los datos, seria bueno asignar 0 a la gente que no respondio esa pregunta, dado que
no trabajan:

replace o10=0 if o10==.

//IMPORTANTE: toda la trasnformacion de variables deben hacerla antes de hacer MCO o


probit/logit

// para cuando quieren sacar estadistica descriptiva o hacer regresion se puede agregar filrtor por
region:

sum o10 edad if region==7

//el 7 corresponde al valor q toma cuando es la region del maule, a los que le toco santiago lo
reemplazam por el valor correspondiente.

//MCO:

reg 010 edad if region==7


//SI, la variable dependiente para MCO es 010, que señala las horas que trabajan

//obviamente deben adapatar los comandos a las variables que le tocaron a cada grupo.

//para el probit o logit deben transformar alguna variable que tome valor 1 si trabaja y 0 si no
trabaja, siguiendo la misma dinamica que la generacion de variables de arriba ,

//parecido a ingreso no salarial, pero considerando las variables correctas.

Potrebbero piacerti anche