clear open "C:\Users\jcaceres\Google Drive\jcd\carlos3\2020_2021\AE\week7\JEC.dta" # i) Estimate by ols list seas_var=seas1 seas2 seas3 seas4 seas5 seas6 seas7 seas8 seas9 seas10 seas11 seas12 genr Lq=log(quantity) genr Lp=log(price) ols Lq const Lp ice seas_var --robust # ii) Show supply and demand equations of cereal. Simultaneous equations problem # iii) # Relevance condition should be fulfilled as the cartel adjusts supply which affect prices # Ideally for a demand instrument, a variable affecting only supply not demand is needed. # Cartel should not affect the demand equation # iv) First stage ols Lp const cartel ice seas_var omit cartel # v) TSLS tsls Lq const Lp ice seas_var ; const cartel ice seas_var # vi) Operate in elastic part? restrict --quiet b[Lp]=-1 end restrict clear # RD Class Size on Scholastic Achievement. open "/Users/jcaceres/Google Drive/jcd/carlos3/2014_2015/Aplicada/Week13/AngristLavy5.gdt" #OLS #MUESTRA QUE NO ES UTILIZADA genr sample=classize>44 || enrol<5 || mathsize==0 summary sample smpl sample==0 --restrict store "/Users/jcaceres/Google Drive/jcd/carlos3/2014_2015/Aplicada/Week13/temp.gdt" clear open "/Users/jcaceres/Google Drive/jcd/carlos3/2014_2015/Aplicada/Week13/temp.gdt" #subsample genr s_1=(enrol>=30 && enrol<=50) || (enrol>70 && enrol<=90) || (enrol>110 && enrol<=130) genr s1=(enrol>=36 && enrol<=45) || (enrol>76 && enrol<=85) || (enrol>116 && enrol<=125) genr s2=(enrol>=37 && enrol<=44) || (enrol>77 && enrol<=84) || (enrol>117 && enrol<=124) genr s3=(enrol>=38 && enrol<=43) || (enrol>78 && enrol<=83) || (enrol>118 && enrol<=123) genr s4=(enrol>=39 && enrol<=42) || (enrol>79 && enrol<=82) || (enrol>119 && enrol<=122) #genr z=(enrol>40 && enrol<=45) || (enrol>80 && enrol<=85) || (enrol>120 && enrol<=125) #ii) freq s1 summary s1 --simple #iii) # Percentiles for classize: loop foreach i 10 25 50 75 90 perc$i = quantile(classize,$i/100) endloop loop foreach i 10 25 50 75 90 printf "The percentile $i is %.8g \n", perc$i endloop #or print perc10 perc25 perc50 perc75 perc90 # Rest of the variables summary classize enrol tipuach avgverb avgmath --simple #For the Discontinuity Sample smpl s1 --restrict summary classize enrol tipuach avgverb avgmath --simple smpl --full #iv) ols avgmath const classize --robust ols avgmath const classize tipuach --robust ols avgmath const classize tipuach enrol --robust smpl --full #intuition genr z1=enrol>40 genr z2=enrol>80 genr z3=enrol>120 smpl s1==1 && z2==0 --restrict list X=classize tipuach avgmath ################################################ loop foreach i X summary $i --by=z1 ols $i const enrol z1 --robust endloop ################################################# tsls avgmath const classize tipuach enrol; const z1 tipuach enrol --robust smpl --full genr z=z1+2*z2+z3*3 tsls avgmath const classize tipuach enrol; const z tipuach enrol --robust #v) genr f=enrol/(int((enrol-1)/40)+1) #vi) ols classize const f tipuach enrol --robust ols avgmath const f tipuach enrol --robust #vii) tsls avgmath const classize tipuach enrol; const f tipuach enrol --robust #viii) genr d=enrol^2 tsls avgmath const classize tipuach enrol d; const f tipuach enrol d --robust #xi) smpl s1 --restrict tsls avgmath const classize tipuach; const f tipuach --robust tsls avgmath const classize tipuach enrol; const f tipuach enrol --robust tsls avgmath const classize tipuach enrol d; const f tipuach enrol d --robust