Preliminary steps

To install the package:

install.packages("devtools")
library("devtools")
install_github('oliviergimenez/occuHMM')

Load the package occuHMM:

library(occuHMM)

Play around with a dynamic occupancy model with constant parameters

Simulate data from a dynamic occupancy model using the parameters by default: 100 sites, 3 surveys, 10 seasons, first-year occupancy probability is 0.6, detection is 0.7, extinction is 0.5 and colonization is 0.3.

yy = sim_colext()

Define the number of primary (seasons) and secondary (surveys) occasions:

J = 3 # nb_surveys
K = 10 # nb_seasons

Fit a dynamic model with constant parameters to these simulated data:

binit = runif(4) # random initial values
res = fit_colext(data=yy,init=binit,nb_surveys=J,nb_seasons=K)

Get the estimates:

xx = res$par

Back-transform:

psi = exp(xx[1])/(1+exp(xx[1]))
gamma = exp(xx[2])/(1+exp(xx[2]))
epsilon = exp(xx[3])/(1+exp(xx[3]))
p = exp(xx[4])/(1+exp(xx[4]))

Fit the same model with unmarked:

library(unmarked)
simUMF <- unmarkedMultFrame(y = yy,numPrimary=K)
m0 <- colext(psiformula= ~1, gammaformula = ~ 1, epsilonformula = ~ 1,
pformula = ~ 1, data = simUMF, method="BFGS")
psi_unmarked <- backTransform(m0, type="psi")
col_unmarked <- backTransform(m0, type="col")
ext_unmarked <- backTransform(m0, type="ext")
p_unmarked <- backTransform(m0, type="det")

And finally, compare the results:

res_unmarked <-round(c(coef(psi_unmarked),coef(col_unmarked),coef(ext_unmarked),coef(p_unmarked)),2)
ourres <- round(c(psi,gamma,epsilon,p),2)
cat('our estimates:',ourres)
cat('unmarked:', res_unmarked)

Play around with a dynamic occupancy model allowing for false positives

Simulate data from a dynamic occupancy model using the parameters by default (see ?sim_colextfp)

yy = sim_colextfp()

Define the number of primary (seasons) and secondary (surveys) occasions:

J = 3 # nb_surveys
K = 10 # nb_seasons

Fit a false positive dynamic model with constant parameters to these simulated data:

binit = runif(6) # random initial values
res = fit_colextfp(data=yy,init=binit,nb_surveys=J,nb_seasons=K)

Get the estimates:

xx = res$par

Back-transform:

psi = 1/(1+exp(-xx[1]))
colonization = 1/(1+exp(-xx[2]))
extinction = 1/(1+exp(-xx[3]))
p10 = 1/(1+exp(-xx[4]))
p11 = 1/(1+exp(-xx[5]))
delta = 1/(1+exp(-xx[6]))

Unfortunately, unmarked does not fit dynamic occupancy models with false positives (but it does with static aka single-season models). We however could show that our estimates are similar to those E-SURGE provides (results not shown).



oliviergimenez/occuHMM documentation built on May 24, 2019, 12:52 p.m.