我通过多个函数传递相同的参数,部分代码看起来像
inner.integral <-function(f,n,i,x,odds,alpha,beta)
{
beta.func(x,alpha,beta) * ( beta.prob(alpha,beta) * eval(call(paste("func",as.character(i),as.character(alpha+1),sep=".")),(x*(1+f*odds)))+(1-beta.prob(alpha,beta))*eval(call(paste("func",as.character(i),as.character(alpha),sep=".")),(x*(1-f))))
}
inner.integral.int <- function(f,n,i,x,odds,alpha,beta) {
integrate(inner.integral,lower=0,upper=1,n=n,i=i,
x=x,odds=odds,alpha=alpha,beta=beta)
}
inner.integral.int.2 <- function(f,n,i,x,odds,alpha,beta) {
y <- inner.integral.int(f,n,i,x,odds,alpha,beta)$value
return(y)
}
通过优化函数将参数传递给inner.integral.int.2
时,类似于:
optimise(inner.integral.int.2,lower=min.f,
upper=max.f,n=n,i=i,x=x,odds=odds,alpha=a,beta=b)
对于定义的 min.f、max.f、n、i、x 等,我收到错误:
Error in paste("func", as.character(i), as.character(alpha + 1), sep = ".") :
argument "i" is missing, with no default
我做错了什么?