全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
2058 2
2011-11-14
使用ciplot画上n个置信区间,其中confint是一个2*n的矩阵,第一行是置信区间的下界,第二行是置信区间的上界。
以下是代码,当时总是出现:
错误于int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) :
  找不到对象'true'
并且图像出来是一片空白……求问这个程序哪个地方错了~~~~
谢谢大家了!
ciplot <- function(confint, true)
{
n <- length(confint[1,]) # find number of confidence intervals
x <- matrix(c(1:n,1:n),nrow=n,ncol=2)
y <- c(t(x)) # produces vector with y[2i-1] = y[2i] = i
z <- c(confint) # vector with z[2i-1] lower bound, z[2i] upper bound of ith ci
plot(z, y, type="n", ylab="Sample number") # plot end points of ci
abline(v=true) # draw vertical line at true value of parameter
for (i in 1:n)
{
a <- 2*i-1
b <- 2*i
if (z[a] <= true & z[b] >= true) # interval contains true value of parameter
{
lines(z[a:b],y[a:b],col=2) # join endpoints of ci with red line
}
else
{
lines(z[a:b],y[a:b],col=4) # join endpoints of ci with blue line
}}}
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-11-19 21:59:11
建议看看基础的教程,任何一本都有介绍,主要是字符值、逻辑值、大小写混淆不清的问题
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-3-2 21:38:36
如果你这个function里面的true不是布尔值,那就要界定一下
如果是布尔值,必须要大写,TRUE

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群