Hello, I use the "xtivreg2" analysis for my analysis, but because my instrument is a dummy variable I want to use the following steps to get the similar results to my baseline :
-I get " std" of my dummy variable
-"std" of the fitted value that I obtained from the first stage
-and then recalling the second stage by a ratio of these two standard deviations.
to get the std of my shock :
so to do this :
but for getting the fitted value of first stage I tried in this way, because I need the standard deviation of first stage:
but I get an error
and then
error
how can I compute the "std" of the fitted value from the first stage? and re-scaling the second stage by the ratio of these two "standard deviations, std of my shock and std of the second stage.
I appreciate receiving your help. in any stage I receive errors.
regards,
-I get " std" of my dummy variable
-"std" of the fitted value that I obtained from the first stage
-and then recalling the second stage by a ratio of these two standard deviations.
to get the std of my shock :
Code:
sum shock_recession
so to do this :
Code:
foreach v in "ltotalfertility" {
foreach vart in "0" {
xi: xtivreg2 d`vart'`v' (shock_recession = instrument) l(1/2).shock_recession l(1/1).d0`v' tt*, fe partial(tt*) robust kernel(tru) bw(1) first savefirst savefprefix(st1)
outreg2 using myfile, replace label keep (shock_recession l(1/2)shock_recession l(1/1).d0`v') bdec(3) cdec(3) stats(coef se) addstat(kleibergen-Paap_rk_LM_statistic, `e(idstat)', p-value, `e(idp)', kleibergen-Paap_rk_LM_statistic, `e(widstat)') excel,
foreach vart in "1" "2" "3" "4" "5" {
xi: xtivreg2 d`vart'`v' (shock_recession = instrument) l(1/2).shock_recession l(1/1).d0`v' tt*, fe partial(tt*) robust kernel(tru) bw(1) first
outreg2 using myfile, append label keep (shock_recession l(1/2)shock_recession l(1/1).d0`v') bdec(3) cdec(3) stats(coef se) addstat(kleibergen-Paap_rk_LM_statistic, `e(idstat)', p-value, `e(idp)', kleibergen-Paap_rk_LM_statistic, `e(widstat)') excel,
}
}
}
but for getting the fitted value of first stage I tried in this way, because I need the standard deviation of first stage:
Code:
gen fitted=.
gen resi =.
foreach v in ltotalfertility {
forvalues i=0/5 {
xi: xtivreg2 d`i'`v' (shock_recession = instrument) l(1/2).shock_recession l(1/1).d0`v' tt*,fe partial(tt*) robust kernel(tru) bw(1) first
predict f if d`i'`v'
predict r if `i' `y', resid
replace fitted= f if d`i'`v' & year==`i'
replace resi = r if d`i'`v' & year==`i'
}
}
predict not supported after xtivreg2 with partialling-out option
r(499);
r(499);
Code:
foreach v in ltotalfertility {
forvalues i=0/5{
xi: xtivreg2 d`i'`v' (shock_recession = instrument) l(1/2).shock_recession l(1/1).d0`v' tt*,fe partial(tt*) robust kernel(tru) bw(1) first
predict res_d`i'`v' if e(sample), res
}
}
error
option res not allowed
r(198);
r(198);
how can I compute the "std" of the fitted value from the first stage? and re-scaling the second stage by the ratio of these two "standard deviations, std of my shock and std of the second stage.
I appreciate receiving your help. in any stage I receive errors.
regards,
