version 6.0 #delimit; cap clear; cap log close; /********* MODIFY THESE VALUES ***************/ cd d:\data\nbhdeffects\mathematica; /* working directory */ local logfile "teenpregnb0v2matchmoves.log"; /* name of log file */ local file "..\..\results.dat"; /* name of input file */ scalar define ndelta = 5; /* number of unique delta values */ scalar define ngamma = 5; /* number of unique gamma values */ scalar define infl = 1.55; /* inflation factor for clustered stderrs */ /*********************************************/ log using `logfile', replace; /********************************************** July 22, 2002 takes sensitivity .dat file generated by mathematica and converts to stata to create sensitivity matrix using logit models 1) input file 2) create variables 3) run logit for each analysis, saving results 4) display sensitivity matrix **********************************************/ /* read file and create variables */ local max = ndelta*ngamma; infile wgt1-wgt`max' using "`file'"; gen r = 1; gen d = 1; gen u = 1; replace d = 0 in 1/4; replace r = 0 in 1; replace r = 0 in 2; replace r = 0 in 5; replace r = 0 in 6; replace u = 0 in 1; replace u = 0 in 3; replace u = 0 in 5; replace u = 0 in 7; list d r u; /* run logit models in for loop, recording output, then display */ cap program drop extract; program define extract; version 6.0; local ndelta = ndelta; local ngamma = ngamma; local i = 1; local j = 1; while `j' <= `ndelta' {; local k = 1; while `k' <= `ngamma' {; quietly logit r d u [iw=wgt`i']; scalar define b_`j'_`k' = exp(_coef[d]); scalar define cil_`j'_`k' = exp(_coef[d] - (1.96) * infl * _se[d]); scalar define cir_`j'_`k' = exp(_coef[d] + (1.96) * infl * _se[d]); local k = `k' + 1; local i = `i' + 1; }; local j = `j' + 1; }; display ""; display "Gamma varies by row, Delta varies by column"; display "Coefficient"; display "(CI)"; local j = 1; while `j' <= `ngamma' {; local k = 1; while `k' <= `ndelta' {; scalar define temp = b_`k'_`j'; display %-12.2f temp " " _continue; local k = `k' + 1; }; display ""; local k = 1; while `k' <= `ndelta' {; scalar define temp = cil_`k'_`j'; display "(" %4.2f temp "-" _continue; scalar define temp = cir_`k'_`j'; display %4.2f temp ") " _continue; local k = `k' + 1; } ; display ""; local j = `j' +1; }; end; extract; log close;