Graph 使用Stata的双向灵敏度图

Graph 使用Stata的双向灵敏度图,graph,stata,Graph,Stata,我正在评估医疗决策模型,并希望显示双向敏感性分析的结果。我已经包含了为两个感兴趣的变量及其线性预测值(生命天数)创建范围的代码 我希望将红色和蓝色区域着色,而不是点。我尝试了两种方式来使用rarea和area命令,但这并没有达到预期的效果。下面编码的散点图是我能达到的最终结果的最佳近似值 *create all possible pairs of data clear set obs 40 gen a = 0.20 if [_n] == 1 replace a = a[_n-1] -

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

我希望将红色和蓝色区域着色,而不是点。我尝试了两种方式来使用rarea和area命令,但这并没有达到预期的效果。下面编码的散点图是我能达到的最终结果的最佳近似值

*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

提前感谢您的帮助。

对于您正在尝试的工作,双向轮廓应该可以工作

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的附加选项和twoway plot options help twoway_选项

例如:

twoway (contour _90 a b, scolor(mint) ecolor(magenta) levels(2) heatmap ///
    zlabel(.25 "0" .75 "1"))
添加zlabel以重新定义图例上使用的值。其他选项可用于更改图例的位置等。还要注意的是,因为等高线是双向打印类型,所以它也可以与其他双向打印组合