I want to find bootstrapped CIs for the regression coefficients of the following Poisson regression:
m1p <- glm(Total_balls_chamber~AverageHumidity+Temp_offset+AverageHumidity:Temp_offset, family=poisson, data=Humid)
I have tried the following code:
library(boot)
bootReg=function(formula, data, i)
{
d <- data[i,]
fit <- glm(formula,family=poisson, data = d)
return(coef(fit))
}
bootResults=boot(statistic = bootReg, formula =Total_balls_chamber~AverageHumidity+Temp_offset+AverageHumidity:Temp_offset, data=Humid, R = 2000)
Which I have adapted from the example given from Andy Field's R text book (code here). This gives me the following error:
Error in boot(statistic = bootReg, formula = Total_balls_chamber ~ AverageHumidity + :
number of items to replace is not a multiple of replacement length
I have not been able to find any good examples on the net of how to bootstrap Poisson regressions. Does any one know of any good examples of boostrapping Poisson regressions, or could anyone point out what is wrong in my code?
I should also add, my sample size is only 16, and I wonder if the error is to do with my low sample size, rather than an error in the code.