Using bootstrapped regression to test if categorical and/or count data has an effect on the outcome of another variable

I want to test the effect of Habitat (categorical), caterpillar SR, caterpillar abundance, plant SR and plant abundance on Z. filipendulae (count).

I have decided to use bootstrapped regression as the assumptions of ANCOVA have not been met.

R code below

bootReg<-function(formula=Z. filipendulae~Catepillar.SR+Caterpillar.Abundance+Plant.SR+Plant.Abundance+factor(Habitat), data=AncovaData, i)
d <- data[i,]
fit <- lm(formula, data = d)

bootResults<-boot(statistic =bootReg,
formula=Z.filipendulae~Caterpillar.SR +


Error in[r, ] <- res[[r]] :
number of items to replace is not a multiple of replacement length

I think you have forgot to tell us what your problem is, you are just telling us what have you done so far but not what problems you are having.

Ideally, you should prepare a reproducible example (reprex) illustrating your issue.
Please have a look at this guide, to see how to create one:


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.