0

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

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
Jay
  • 25
  • 4
  • 1
    `bootxbar[i]<-function(x) dpois(data,lambda=exp(x))` tries to assign a function to a part of a vector. – thelatemail Dec 16 '15 at 05:55
  • @thelatemail Oh, then what would be the best way to correct that? I'm trying to have it run a poisson within the bootstrap. – Jay Dec 17 '15 at 00:40

0 Answers0