### SIMULATE a DATASET under the SITE CONFIRMATION DESIGN ### MULTIPLE-DETECTION-METHODS rm(list = ls()) # Clean the workspace set.seed(456) ### PARAMETERS psi <- 0.6 # occupancy probability p11 <- 0.7 # site-level detection probability (from ambiguous method) p10 <- 0.1 # site-level false positive probability (from ambiguous method) r11 <- 0.5 # site-level detection probability (from unambiguous method) ### SAMPLE CHARACTERSITICS J <- 4 # number of occasions surveyed with ambiguous method K <- 3 # number of occasions surveyed with unambiguous method R <- 500 # number of sites ### OCCUPANCY STATES Z <- rbinom(R, 1, psi) ### SIMULATE DETECTION/NON-DETECTION DATA from ambiguous method (data Y) Y <- matrix(NA,R,J) ### Create a matrix to store detection/non-detection data for (i in 1:R){ ### Loop over all sites 'i' p <- Z[i]*p11 + (1-Z[i])*p10 ### Define the 'binomial' parameter, conditional on site occupancy status Y[i,] <- rbinom(J, 1, p) ### Site-level data Y [0/1] -- for J occasions } ### End Loop over sites Y.sum <- apply(Y, 1, sum) ### Summarize the data as 'number of detection for each site' ### SIMULATE DETECTION/NON-DETECTION DATA from unambiguous method (data W) W <- matrix(NA,R,K) ### Create a matrix to store detection/non-detection data for (i in 1:R){ ### Loop over all sites 'i' W[i,] <- rbinom(K, 1, Z[i]*r11) ### Site-level data W [0/1] -- for K occasions } ### End Loop over sites W.sum <- apply(W, 1, sum) ### Summarize the data as 'number of detection for each site' ### Save the data used in the model data.SiteConf.MM <- cbind(Y.sum, W.sum) ### Observation DATA occ.SiteConf.MM <- c(J,K) ### number of survey occasions TrueValues.SiteConf.MM <- cbind(psi, p11, p10, r11) ### Save the true parameter values for comparison wih estimates # Save these obsjects as a 'RData' file save(file = "DataSiteConf-MM.RData", list = c("data.SiteConf.MM", "occ.SiteConf.MM", "TrueValues.SiteConf.MM"))