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)

return(coef(fit))

}

bootResults<-boot(statistic =bootReg,

formula=Z.filipendulae~Caterpillar.SR +

Caterpillar.Abundance+Plant.SR+Plant.Abundance+factor(Habitat),

data=Data,R=2000)

Error

Error in t.star[r, ] <- res[[r]] :

number of items to replace is not a multiple of replacement length