clear
open "/Users/jcaceres/Google Drive/jcd/carlos3/2020_2021/AE/new_material/Smoking.gdt"
genr age2=age*age
list edu= hsdrop hsgrad colsome colgrad
list race=black hispanic
list demo=female age age2
#The educational binary indicators refer to the highest level attained and thus are mutually exclusive.
#An individual with a Masterâ€™s degree or higher has values of 0 for hsdrop, hsgrad, colsome, and colgrad
#Linear probability model
#What is the probability of smoking for someone in the sample?; for workers facing smoking bans?; what about the workers who are not facing smoking bans
#What is the difference in the probability of smoking between the workers facing this restriction and the rest of individuals?
ols smoker const smkban --robust
#Are workers in jobs with smoking bans similar to the ones to those in other jobs? How do you explian this?
ols smkban const edu --robust
ols smkban const race --robust
ols smkban const demo --robust
#Conditional on education, race and other demographic controls, do smoking bans affect the probability of smoking?
#How do explain the difference respect to the unconditional model?
ols smoker const smkban edu race demo --robust
genr bl=$coeff
#Does education have an impact on the probability?
omit edu --quiet
#Does age effect is linear? How do you explain this relation?
genr age_aster=-bl[10]/(2*bl[11])
#What is the marginal effect of age for an individual that is 20 years of age?
genr mg20L=bl[10]+2*bl[11]*20
#Use a probit model to estimate the probability of smoking for an average 20 years old dropout white man who does not face smoking bans. Compare this probability
#How does the probability change for a similar worker facing smoking bans?
probit smoker const smkban edu race demo --robust
genr bp=$coeff
#Linear model
genr PL=bl[1]+bl[2]*0+bl[3]+bl[10]*20+bl[11]*400
#Probit model
genr zA0=bp[1]+bp[2]*0+bp[3]+bp[10]*20+bp[11]*400
genr PA0=cdf(N,zA0)
genr zA1=bp[1]+bp[2]*1+bp[3]+bp[10]*20+bp[11]*400
genr PA1=cdf(N, zA1)
#Effect smoking bans for Mr A
genr SB_IA=PA1-PA0
#Therefore the workplace bans would reduce the probability of smoking by 0.0623 (6.23%) for an individual with these characteristics.
#What would be the impact of smoking bans for a 40 years old black woman with a college degree (Mrs B)?
genr zB0=bp[1]+bp[6]+bp[7]+bp[9]+bp[10]*40+bp[11]*40*40
genr zB1=bp[1]+bp[2]+bp[6]+bp[7]+bp[9]+bp[10]*40+bp[11]*40*40
genr SB_IB=cdf(N, zB1)-cdf(N,zB0)
#The probability of Ms. B smoking without the workplace ban is 0.143 and the probability of smoking
#with the workplace ban is 0.110. Therefore the workplace bans would reduce the probability of smoking by .033 (3.3%).
#What is the impact of smoking bans for Mr A and Mrs B?
#Calculate the marginal effect of age for MrA and Mrs B with and without smoking bans
genr MgIA1=pdf(N, zA1)*(bp[10]+2*bp[11]*20)
genr MgIA0=pdf(N, zA0)*(bp[10]+2*bp[11]*20)
genr MgIB1=pdf(N, zB1)*(bp[10]+2*bp[11]*40)
genr MgIB0=pdf(N, zB0)*(bp[10]+2*bp[11]*40)