#delimit ;
clear all;
set more off;
set memory 200000;
set maxvar 32000;
capture: log close;
log using "c:\data\psid\eco 644\ex0.log", text replace; /*** <-- CHANGE PATH ***/
/*********************************************************************************/
/* Program: ex1_cons_lpm.do -- Stata do file to use the 1968-87 consumption data */
/* from the PSID in linear probability model analyses of food cons. */
/* */
/* Authors: D. Ribar October 2012 */
/*********************************************************************************/
/* Read/input data set */
use "c:\data\psid\eco 644\psid_cons_68_87.dta", clear; /*** <-- CHANGE PATH ***/
/* Just use data for 1987 */
keep if year==1987;
/* Adjust food needs variable for inflation; food needs reported in 1967 dollars;*/
/* also drop observations with food needs below $337 (lowest possible food */
/* needs for a household with adults */
drop if tvfdstd < 337;
generate tvcfdstd = tvfdstd*tcpifh/.351;
label var tvcfdstd "Annual food needs in current dollars";
/* Construct a dummy variable for food expenditures being greater than food needs*/
generate enuffood = (tvfhome + tvfaway) > tvcfdstd;
label var enuffood "Annual food expenditures sufficient (greater than needs)";
/* Construct a log family income variable (negative and zero incomes will be */
/* dropped */
drop if tvfaminc <= 0;
generate tvlfminc = log(tvfaminc);
label var tvlfminc "Log annual family income";
/* Summarize the data set for documentation purposes */
sum;
/* Run a linear probability model of whether the household had enough food */
reg enuffood tvlfminc tvcurmar tvnkids;
/* Construct predicted values */
predict lpm_ef;
label var lpm_ef "Predicted prob. of food expenditure sufficiency";
/* Show predictions that are out of range and show distribution of predictions */
generate lpm_ef_oor = (lpm_ef<0 | lpm_ef>1);
label var lpm_ef_oor "Predicted food expenditure sufficiency invalid";
sum enuffood lpm_ef lpm_ef_oor;
histogram lpm_ef, width(0.10) start(-1.0) frequency
subtitle("Distribution of predicted food expenditure sufficiency");
/* Run a linear probability model of whether the household had enough food */
/* adding demographic controls */
generate tvagesqr = tvage * tvage / 100;
reg enuffood tvlfminc tvcurmar tvnkids tvage tvagesqr tvblack;
estimates store reg21;
estat hettest tvlfminc tvcurmar tvnkids tvage tvblack, mtest;
/* Construct predicted values and residuals */
predict lpm_ef2;
label var lpm_ef2 "Predicted prob. of food expenditure sufficiency (spec 2)";
/* Show predictions that are out of range and show distribution of predictions */
generate lpm_ef2_oor = (lpm_ef2<0 | lpm_ef2>1);
label var lpm_ef2_oor "Predicted food expenditure sufficiency invalid (spec 2)";
sum enuffood lpm_ef lpm_ef2 lpm_ef_oor lpm_ef2_oor;
/* Re-run models with robust standard errors */
reg enuffood tvlfminc tvcurmar tvnkids tvage tvagesqr tvblack, robust;
estimates store reg22;
estimates table reg21 reg22, b(%9.4f) se stats(N);
log close;
clear;
#delimit cr