log using aidsdata.log, replace * aidsdata.do : demonstrate the regmsng program set more 1 * Define macros for the names of the right-hand-side variables * and the instruments. global RHS epiage lgnppci gini urbmf miltpop gaplit muslim lmstp90 global INST rgn1 rgn2 rgn3 rgn5 rgn6 rgn7 lifex imrt80 lgnppc2 lpop use aidsdata, clear describe sum * Note that 76 countries have both high risk and low risk observations, * while 27 have only one or the other. sort cn count if cn==cn[_n-1] * First estimate the equation with OLS, excluding all missing values. regress logitP hirisk $RHS * Demonstrate regmsng with -nmiss- set to 3, then to 1. * Replace missing values by means. Show the -steps- in constructing * the imputed values. regmsng logitP hirisk $RHS , nmiss(3) steps noaux * Replace missing values by zeros and construct auxiliary variables * containing the means. * Note that this option substantially improves the fit of the regression. regmsng logitP hirisk $RHS , nmiss(3) nohist notest * For -nmiss- = 1, test whether coefficients of auxiliary variables * equal those of original variables. regmsng logitP hirisk $RHS , nmiss(1) nohist * Now re-estimate the regression allowing for correlation between the * disturbance terms on the two observations from the same country. * Using regress restricts the sample to the 96 complete observations. regress logitP hirisk $RHS, cluster(cn) * Since regmsng does not accept the cluster option, use regmsng to * generate zero-filled RHS variables and the corresponding auxiliary * variables and then apply REGRESS. regmsng logitP hirisk $RHS, nmiss(1) nohist notest change * Now the estimates can be corrected for heteroskedasticity using the * cluster option. regress logitP hirisk $RHS A*, cluster(cn) * Repeat manually the same tests that regmsng does automatically, * but using heteroskedasticity-corrected variance-covariance matrix * of the coefficients. * F-tests of the significance of variables: for $RHS , nostop : test @ A@ * t-tests of the hypothesis that coefficients are equal: for $RHS , nostop : test @ == A@ * Joint test that all variable coefficients equal all corresponding * coefficients of auxiliary variables: quietly for $RHS , nostop : test @ == A@ , accum test * Finally, demonstrate use of the -fitted- option. use aidsdata, clear * Generate auxiliary variables for the regions: tab region, gen(rgn) * Make Latin America and the Caribbean (rgn4) the reference region: drop rgn4 regmsng logitP hirisk $RHS, nmiss(3) fitted inst($INST) nohist notest log close