fn(par ...)出错:未使用的参数

时间:2018-03-26 18:32:36

标签: r

当我创建'bootstrapped'对象时,我收到以下错误消息:

Error in fn(par, ...) : unused arguments (x = c(18.1818181818182, 8.08080808080808, 62.6262626262626, 26.2626262626263, 76.7676767676768, 18.1818181818182, 38.3838383838384, 69.6969696969697, 64.6464646464647, 5.05050505050505

当我使用调试工具时,它会显示以下内容:

Function: [Anonymous function] (optim())

但是我一直在看我的功能,但没有发现任何问题:

x<-xy$x
y<-xy$y
fn_bootstrap=function(x,y){
bootstrapping<-sample(1:100, replace = T)
fit2<-optim(c(1,1),
fn=myfun,
method="L-BFGS-B",
lower=c(0,-1),
upper=c(15,15),
x=x[bootstrapping], 
y=y[bootstrapping])

return(c(fit1$par,fit1$convergence) )
}

replications<-10000
bootstrapped<-replicate(replications, bootstrap(x=x,y=y))

修改:x,y

的示例

x y 1 4.683172 2 5.152812 3 4.133874 4 3.294114 5 3.871276 6 3.792533 7 3.551182
8 3.389954 9 2.202404 10 3.730870 11 3.223740 12 2.109984 13 3.129297 14 2.830958 15 2.303632 16 1.766578 17 1.749364 18 1.735230 19 1.654743 20 2.033441

0 个答案:

没有答案
相关问题