I'm trying to do some hypothesis testing with a bootstrap confidence interval, but am having some trouble setting up the bootstrap. The goal is to test the null at theta=1 and at level 0.05. I've provided a sample of the data that is being used below:
y <- c(3,5,3,1,2,1,2,1,0,2,4,3,1,4,1,2,2,0,4,2,2,4,0,2,1)
Within the bootstrap, I'm also trying to work with a numerical optimization with the following: dpois(data,lambda=exp(x)
. I've provided the code I've generated below:
nboot<-1000
bootxbar <- rep(NA,nboot)
for (i in 1:nboot) {
data <- y[sample(1:n,replace=TRUE)]
bootxbar[i]<-function(x) dpois(data,lambda=exp(x))
}
quantile(bootxbar,c(0.025,0.975))
The error is as follows:
Error in bootxbar[i] <- function(x) dpois(y, lambda = exp(x)) : incompatible types (from closure to logical) in subassignment type fix