########### RUN THE FOLLOWING TO GENERATE DATA ############## n.groups <- 3 n.sample <- 10 n <- n.groups* n.sample x <- rep(1:n.groups, rep(n.sample, n.groups)) pop <- factor(x, labels = c("Montpellier","Paris","Leon")) shrub_M <- sort(runif(n.sample,0,1)) shrub_P <- sort(runif(n.sample,0,1)) shrub_L <- sort(runif(n.sample,0,1)) shrub <- c(shrub_M,shrub_P,shrub_L) Cams <- round(runif(n,10,50)) Xmat <- model.matrix(~pop*shrub) #print(Xmat,dig=2) beta.vec <- c(-4,1,2,1,2,6) lin.pred <- Xmat[,]%*%beta.vec exp.p <- exp(lin.pred)/(1+exp(lin.pred)) Caps <- rbinom(n=n, size=Cams, prob=exp.p) rodents <- as.data.frame(cbind(shrub,Caps,Cams,pop)) rodents$pop <- factor(rodents$pop) levels(rodents$pop) <- c("Montpellier","Paris","Leon") #### Do not chage anything above this line ####### Data for students ######## # Caps == camera traps with capture # Cams == total number of camera traps