*
* UNION.PRG
* Manual example 14.2.
* Adapted from Johnston and DiNardo, pp 415-425
*
open data cps88.asc
data(format=prn,org=columns) 1 1000 age exp2 grade ind1 married lnwage occ1 partt potexp union weight high
*
disp 'Statistics for Union Members'
table(smpl=union) / potexp exp2 grade married high
disp 'Statistics for Non-Union Members'
table(smpl=.not.union) / potexp exp2 grade married high
*
* Fit a linear probability model. Do a histogram of the predicted "probabilities"
*
linreg union
# potexp exp2 grade married high constant
prj fitlp
density(type=histogram) fitlp / gx fx
scatter(style=bargraph,header='Histogram of Predicted Values from a LPM')
# gx fx
*
* Probit model. Show a scatter graph of the predicted probabilites of the
* probit vs the LPM. Include the 45 degree line on the graph.
*
ddv(dist=probit) union
# potexp exp2 grade married high constant
prj(dist=probit,cdf=fitprb)
scatter(style=dots,lines=||0.0,1.0||,header='Probit vs Linear Probability Model',$
 hlabel='Predicted Probability(Probit)',vlabel='Predicted Probability(LP)')
# fitprb fitlp
*
* Evaluate the predicted effect of switching industries on individuals
* currently in low union industries. This is done by evaluating the predicted
* probabilities with the value of "high" turned on for all the individuals, then
* knocking out of the sample those who were already in a high union industry.
* The predicted probabilities are obtained by "dotting" the coefficients with
* the required set of variables, then evaluating the normal cdf (%cdf) at those
* values.
*
set z = %dot(%beta,||potexp,exp2,grade,married,1,1||)
set highprb = %if(high,%na,%cdf(z))
scatter(style=dots,vmin=0.0,lines=||0.0,1.0||,$
  header='Effect of Industrial Affiliation on Workers in Low-Union Industries')
# fitprb highprb
*
* Logit model
*
ddv(dist=logit) union
# potexp exp2 grade married high constant
prj(dist=logit,cdf=fitlgt)
scatter(style=dots,lines=||0.0,1.0||,header='Probit vs Logit Model',$
 hlabel='Predicted Probability(Probit)',vlabel='Predicted Probability(Logit)')
# fitprb fitlgt

