Stata 引导后在观察中粘贴标量值
我需要帮助粘贴引导系数及其下限和下限 新变量中的上95%CI用于生成图形 我尝试了下面的代码。看起来标量是用 成功,但我无法将它们粘贴到具体的观察结果中 使用Stata 引导后在观察中粘贴标量值,stata,scalar,Stata,Scalar,我需要帮助粘贴引导系数及其下限和下限 新变量中的上95%CI用于生成图形 我尝试了下面的代码。看起来标量是用 成功,但我无法将它们粘贴到具体的观察结果中 使用时,请更换 clear all forvalues j=0/1{ foreach l in P2 P3 P4 { use `l'_per_`j', clear set seed 1 reg estimate xaxis predict yhat gen
时,请更换
clear all
forvalues j=0/1{
foreach l in P2 P3 P4 {
use `l'_per_`j', clear
set seed 1
reg estimate xaxis
predict yhat
gen yhat_bs=yhat
gen ll_95per=.
gen ul_95per=.
local N = _N
foreach i in 1/11 { //number of time periods to be predicted
bootstrap pred=(_b[_cons] + _b[xaxis]*`i'), reps(1000) seed(1): reg
estimate xaxis
matrix b=e(b)
scalar sb=b[1,1]
matrix ci_normal=e(ci_normal)
local par=b[1,1] //coefficient bootstrap
local ll=ci_normal[1,1] //lower CI 95%
local ul=ci_normal[2,1] //upper CI 95%
replace yhat_bs=`par' if xaxis==`i'
replace ll_95per=`ll' if xaxis==`i'
replace ul_95per=`ul' if xaxis==`i'
}
save `l'_per_`j'_lin_trend, replace
}
}
1/11中每个i的语法在这里是错误的。就Stata而言,这是一个列表,其中有一项1/11
,不会展开。那么,当斯塔塔到达终点时
replace yhat_bs=`par' if xaxis==`i'
这将成为,当这个循环执行时
replace <stuff> if xaxis==1/11
1/11中每个i的语法在这里是错误的。就Stata而言,这是一个列表,其中有一项1/11
,不会展开。那么,当斯塔塔到达终点时
replace yhat_bs=`par' if xaxis==`i'
这将成为,当这个循环执行时
replace <stuff> if xaxis==1/11