【问题标题】:Two-way sensitivity graph using Stata使用Stata的双向灵敏度图
【发布时间】:2015-09-13 02:32:17
【问题描述】:

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

我希望红色和蓝色区域带有阴影,而不是点。我在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

提前感谢您的帮助。

【问题讨论】:

    标签: graph stata


    【解决方案1】:

    对于您正在尝试做的事情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 是双向图类型,它也可以与其他双向图结合使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多