我通過多種功能傳遞相同的參數傳遞參數,代碼的部分看起來像通過嵌套函數
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
我做錯了什麼?