I have run a two stage spline model. Where the first stage controls for endogeinity in the number of antenatal care visits a pregnant woman makes. In my previous analysis I did find that antenatal care is only effective up to 4 visits in reducing low birth weight. So in the second stage I went to generate an spline at 4 visits of which I tried to interact with one of the antenatal care services; if a woman was given Malaria prophylaxis during the antenatal care visit as follows;
reg LBW c.prophylaxis##c.ANC4 c.prophylaxis##c.ANC1 uhat SS1 `varlist' . That's the second stage. I wanted to bootstrap the Wald test results from the interaction variable. But I keep getting an error.
The full code is as follows;
set more off
set seed 12345
cap program drop iv_wald
program define iv_wald, rclass
args varlist
reg ANC rain ib0.educ married miscarriage caesar ib1.SES age age2 ib1.birthorder wanted permission ib1.religion urban ib1.ethnic
cap drop uhat
predict uhat, res
return scalar b_iv = _b[rain]
reg LBW c.prophylaxis##c.ANC4 c.prophylaxis##c.ANC1 `varlist' uhat SS1
return scalar b1 = _b[c.prophylaxis##c.ANC4]
return scalar b2 = _b[c.prophylaxis##c.ANC1]
return scalar b_uhat = _b[uhat]
return scalar b_SS1=_b[SS1]
end
local controls = "gestation NDVI sex ib0.educ married twin miscarriage caesar ib1.SES age age2 ib1.birthorder wanted permission ib1.religion urban ib1.ethnic smoking"
bootstrap b_iv=r(b_iv) b1=r(b1) b2=r(b2) b_uhat = r(b_uhat) b_SS1=r(b_SS1), reps(1000): iv_wald `controls'
The error that I got is as follows;
invalid matrix stripe;
c.prophylaxis##c.ANC4
an error occurred when bootstrap executed iv_wald
r(198);
If anyone knows the reason why, please help.
Thanks
reg LBW c.prophylaxis##c.ANC4 c.prophylaxis##c.ANC1 uhat SS1 `varlist' . That's the second stage. I wanted to bootstrap the Wald test results from the interaction variable. But I keep getting an error.
The full code is as follows;
set more off
set seed 12345
cap program drop iv_wald
program define iv_wald, rclass
args varlist
reg ANC rain ib0.educ married miscarriage caesar ib1.SES age age2 ib1.birthorder wanted permission ib1.religion urban ib1.ethnic
cap drop uhat
predict uhat, res
return scalar b_iv = _b[rain]
reg LBW c.prophylaxis##c.ANC4 c.prophylaxis##c.ANC1 `varlist' uhat SS1
return scalar b1 = _b[c.prophylaxis##c.ANC4]
return scalar b2 = _b[c.prophylaxis##c.ANC1]
return scalar b_uhat = _b[uhat]
return scalar b_SS1=_b[SS1]
end
local controls = "gestation NDVI sex ib0.educ married twin miscarriage caesar ib1.SES age age2 ib1.birthorder wanted permission ib1.religion urban ib1.ethnic smoking"
bootstrap b_iv=r(b_iv) b1=r(b1) b2=r(b2) b_uhat = r(b_uhat) b_SS1=r(b_SS1), reps(1000): iv_wald `controls'
The error that I got is as follows;
invalid matrix stripe;
c.prophylaxis##c.ANC4
an error occurred when bootstrap executed iv_wald
r(198);
If anyone knows the reason why, please help.
Thanks
Comment