使用 Stata 的双向灵敏度图

Two-way sensitivity graph using Stata

我正在评估医疗保健决策模型,并希望显示双向敏感性分析的结果。我已经包含了为两个感兴趣的变量及其线性预测变量(生命天数)创建范围的代码。

而不是点,我想要红色和蓝色区域的阴影。我在twoway中尝试了rareaarea命令,但这并没有达到预期的效果。下面编码的散点图是我可以获得的最终结果的最佳近似值。

*create all possible pairs of data
clear
set obs 40

gen a = 0.20 if [_n] == 1
    replace a = a[_n-1] - 0.02 if [_n] != 1

gen b = a

fillin a b

*predict estimates from equation
gen pred = a*-1067.54 + b*-89.1

*identify all estimates >= 90 days
gen _90 = pred >= 90

*plot predictions by status of exceeding 89 days
twoway scatter a b if _90 == 1 || scatter a b if _90 == 0

提前感谢您的帮助。

对于你正在尝试做的事情 twoway contour 应该有效

clear
set obs 40
gen a = 0.20 if [_n] == 1
replace a = a[_n-1] - 0.02 if [_n] != 1
gen b = a
fillin a b
gen pred = a*-1067.54 + b*-89.1
gen _90 = pred >= 90

twoway (contour _90 a b, levels(2) scolor(mint) ecolor(magenta) heatmap)

当然,您可以尝试使用 contour (help twoway_contour) 的附加选项和附加的双向绘图选项 (help twoway_options)。

例如:

twoway (contour _90 a b, scolor(mint) ecolor(magenta) levels(2) heatmap ///
    zlabel(.25 "0" .75 "1"))

添加 zlabel() 以重新定义图例中使用的值。其他选项可用于更改图例的位置等。另请注意,因为 contour 是双向图类型,它也可以与其他双向图结合使用。