set more off capture log close clear // ***************** paths ******************************* local misenda = "/home/ricmora/AAOFICIN/CURSOS/MADE/materiales/slides" set seed 27031967 set obs 5000 matrix mu = (0,0) matrix sigma = (1,0.5\0.5,1) // generate variables gen u =uniform() gen kids = (u>0.25) + (u>0.75) gen educ=8*(u<=.15)+12*(u>.15)*(u<=.6)+16*(u>.6)*(u<=.9)+21*(u>.9) gen h_star= 5+0.5*educ-5*kids+7*rnormal() gen h=(h_star>0)*h_star // estimate with different models regress h educ kids test (educ=0.5) (kids=-5) regress h educ kids if h>0 test (educ=0.5) (kids=-5) tobit h educ kids, ll(0) test (educ=0.5) (kids=-5) mfx // estimate the marginal effect on average actual hours worked of an extra child predict x0b, xb replace kids=kids+1 predict x1b, xb gen Mg_kid=(x1b>0)*x1b - (x0b>0)*x0b su Mg_kid exit