# For a single-season model
N <- 100 #Number of sites
psi <- 0.4 #Occupancy probability
lam <- 7 #Parameter for exponential distribution of time to detection
Tmax <- 10 #Maximum survey length
z <- rbinom(N, 1, psi) #Simulate occupancy
y <- rexp(N, 1/lam) #Simulate time to detection
y[z==0] <- Tmax
y[y>Tmax] <- Tmax
sc <- as.data.frame(matrix(rnorm(N*2),ncol=2)) #Site covs
oc <- as.data.frame(matrix(rnorm(N*2),ncol=2)) #obs covs
umf <- unmarkedFrameOccuTTD(y=y, surveyLength=Tmax, siteCovs=sc, obsCovs=oc)
Run the code above in your browser using DataLab