# Fit oneStep to simulated data
whi <- 250
T <- 100 # true threshold
p <- 0.85
n <- 200
x <- c( runif(n*p, min=0, max=T), runif(n*(1-p), min=T, max=whi))
x <- setUnits(x, "m")
tranID <- sample(rep(1:10, each=n/10), replace=FALSE)
detectDf <- data.frame(transect = tranID, dist = x)
siteDf <- data.frame(transect = 1:10
, length = rep(setUnits(10,"m"), 10))
distDf <- RdistDf(siteDf, detectDf)
# Estimation
fit <- dfuncEstim(distDf
, formula = dist ~ 1
, likelihood = "oneStep"
, w.hi = setUnits(whi, "m")
)
plot(fit)
thetaHat <- exp(coef(fit)[1])
pHat <- coef(fit)[2]
c(thetaHat, pHat) # should be close to c(100,0.85)
summary(abundEstim(fit, ci=NULL))
Run the code above in your browser using DataLab