r语言c指数可信区间,如何画出这样的可信区间图

该博客展示了如何利用BCPNN方法进行统计分析,通过创建虚拟数据集并展示其分布。内容包括设置图形参数,绘制带有置信区间的统计图,并用R语言实现BCPNN的中位数和上下界计算。此外,还强调了统计图的横轴参考线和标题的双语显示,突出了统计和IC的重要性。
摘要由CSDN通过智能技术生成

# Make up some dummy data

set.seed(1705190905)

dfDmmy

merge(

data.frame( quarter = c(1:4) ),

data.frame( year = c(2006:2009) )

)

dfDmmy$mid

1.5*exp( -0.2*( seq.int( nrow(dfDmmy) ) - 1 )*

exp( rnorm( nrow(dfDmmy), sd = 0.05 ) ) )

dfDmmy$upper

dfDmmy$lower

# Set up plot

par(family = "serif")

plot(

NA, type = "n",

xlim = range( seq.int( nrow(dfDmmy) ) ), ylim = c(-0.5, 2.5),

xlab = NA_character_, ylab = NA_character_, axes = FALSE

)

# Axes

with(

dfDmmy,

{

axis( side = 1, at = seq_along(quarter), labels = quarter,

lwd = 0, lwd.ticks = 1 )

lapply(

unique(year),

function(i)

mtext( text = as.character(i), side = 1, line = 2,

at = mean( which( year == i ) ), adj = 0.5, padj = 1 )

)

}

)

abline( h = par("usr")[3] )

axis( side = 2, at = c(-1:5/2), labels = sprintf("%5.2f", -1:5/2),

las = 1, lwd = 0, lwd.ticks = 1 )

abline( v = par("usr")[1] )

# Title

# mtext(

#   text = expression( paste( "Statistics with BCPNN methods, ", italic(IC) ) ),

#   side = 3, adj = 0, xpd = FALSE

#      )

# text(

#   x = par("usr")[1] - par("mar")[2]*par("cxy")[1],

#   y = par("usr")[4] + par("cxy")[2]/2,

#   labels = expression( paste( "Statistics with BCPNN methods, ", italic(IC) ) ),

#   adj = c(0, 0), xpd = NA

#     )

windowsFonts( SONG = windowsFont("TT SimSun") )

text(

x = par("usr")[1] - par("mar")[2]*par("cxy")[1],

y = par("usr")[4] + par("cxy")[2]/2,

labels = "BCPNN",

family = "serif", adj = c(0, 0), xpd = NA

)

text(

x = par("usr")[1] - par("mar")[2]*par("cxy")[1] + strwidth("BCPNN"),

y = par("usr")[4] + par("cxy")[2]/2,

labels = "\u{6CD5}\u{7EDF}\u{8BA1}\u{91CF}\u{FF0C}",

family = "SONG", adj = c(0, 0), xpd = NA

)

text(

x =

par("usr")[1] - par("mar")[2]*par("cxy")[1] +

strwidth("BCPNN\u{6CD5}\u{7EDF}\u{8BA1}\u{91CF}\u{FF0C}") + par("cxy")[1],

y = par("usr")[4] + par("cxy")[2]/2,

labels = "IC",

family = "serif", font = 3, adj = c(0, 0), xpd = NA

)

# Horizontal reference line

abline( h = 0, lty = 3, col = "blue" )

# Plot the data

with(

dfDmmy,

{

# Intervals

dvX

# mapply(

#   lines,

#   x =

#     apply( cbind( seq_along(lower) - 0.1, seq_along(lower) + 0.1 ), 1, I ),

#   y = apply( cbind( lower, lower ), 1, I )

#       )

mapply(

segments,

x0 = lapply(dvX - 0.1, I), x1 = lapply(dvX + 0.1, I),

y0 = lapply(lower, I)

)

# mapply(

#   lines,

#   x =

#     apply( cbind( seq_along(upper) - 0.1, seq_along(upper) + 0.1 ), 1, I ),

#   y = apply( cbind( upper, upper ), 1, I )

#       )

mapply(

segments,

x0 = lapply(dvX - 0.1, I), x1 = lapply(dvX + 0.1, I),

y0 = lapply(upper, I)

)

# mapply(

#   lines,

#   x = apply( cbind( seq_along(lower), seq_along(upper) ), 1, I ),

#   y = apply( cbind( lower, upper ), 1, I )

#       )

mapply(

segments,

x0 = lapply(dvX, I), y0 = lapply(lower, I), y1 = lapply(upper, I)

)

# Points and lines

points( mid, type = "o" )

}

)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值