如何在两边都有条形的地方制作龙卷风图?

时间:2019-04-07 05:00:07

标签: r plot

我开发了一个流行病模型并生成了输出。现在,当我更改一个参数(例如beta变量)然后探索其对生成的输出的影响时,同时又使其他参数保持不变(不变)时,我想进行敏感性分析。

我要更改的参数是beta。我想在“ middle(beta = 8.4; center)”,“ low(beta = 5; left)”,“ high(beta = 15; high)”处绘制具有不同beta值的模型的生成输出,但是条形图重叠在我使用这些代码创建的龙卷风图中(在右侧)。

我想创建一个类似于此的龙卷风图:

http://protectbenefitrisk.eu/tornadoplot.html

dat <- matrix(c(0.0020, 0.0106,0.0007,0.1196,0.0422,0.2087,0.8730, 0.7015, 
0.6460, 0.01691, 0.0081, 0.0246, 0,0,0,0,0,0,0.2776, .7124,0.1204), ncol=7)

dat <- matrix(c(myRes[4:24]), ncol = 7)  # you don’t need to run this, if you are using the above data
rownames(dat) <- c('beta=8.4','beta=5', 'beta=15')               # Amount of change in beta
colnames(dat) <- c('S', 'LA', 'LB','I', 'T', 'TL', 'Sexp')       # Names of output variables
x <- seq(0,1, 0.01)                          # For plotting the x-axis

#This the output
                    S         LA        LB           I T TL      Sexp
beta=8.4 0.0020776591 0.11966384 0.8730181 0.016916187 0  0 0.2776309
beta=5   0.0106789409 0.04224487 0.7015975 0.008136292 0  0 0.7124848
beta=15  0.0007922731 0.20872385 0.6460100 0.024695246 0  0 0.1204128

# codes for tornado plot
par(mfrow=c(1,1))
barplot(dat[2,], horiz = T, las=1, xlim = c(0,1), xaxt='n', ylab = '',   beside=T, col=c('blue'))  # low=5
barplot(dat[3,], horiz = T, las=1, xlim = c(0,1), xaxt='n', ylab = '',    beside=T, col=c('red'), add = TRUE)  # high=15
grid(5, NA, col="lightgray",  lwd=2)
axis(1, at=x, labels=x, col.axis="black", las=1)

我希望生成的beta = 8.4的输出为中心,左侧的beta = 5的生成输出,龙卷风图的右侧的beta = 15的生成输出。这将总结我的敏感性分析的结果。

但是我正在努力为不同的beta值生成龙卷风图,以显示输出上的beta效果。

任何建议将不胜感激!

0 个答案:

没有答案