# NOT RUN {
#Load the example data
data("mads.data")
ddf.data <- mads.data$dist.data
region.table <- mads.data$region.table
sample.table <- mads.data$sample.table
obs.table <- mads.data$obs.table
# Fit candidate detection function models using ddf in mrds
# Fit a half normal model
df.all.hn <- ddf(dsmodel = ~mcds(key = "hn", formula = ~ 1),
method='ds', data=ddf.data, meta.data=list(width=1))
summary(df.all.hn)
plot(df.all.hn)
# Fit a hazard rate model
df.all.hr <- ddf(dsmodel = ~mcds(key = "hn", formula = ~ 1),
method='ds', data=ddf.data, meta.data=list(width=1))
summary(df.all.hr)
plot(df.all.hr)
# Set up mads data:
# A vector of the species names
species.codes <- c("CD", "WSD", "Unid")
# A list defining which species the unidentified categories could be
unid.defs <- list("Unid" = c("CD", "WSD"))
# Specify which models are to be tried for each species code
mod.uncert <- list("CD" = c("df.all.hn", "df.all.hr"),
"WSD" = c("df.all.hn", "df.all.hr"),
"Unid" = c("df.all.hn", "df.all.hr"))
# Provide the models in a named list and the selection criteria
models <- list("df.all.hn" = df.all.hn,
"df.all.hr" = df.all.hr)
model.opts <- list(criterion = "AIC")
# }
# NOT RUN {
# Bootstrap options
bootstrap.opts <- list(resample = 'samples', n=999)
#Warning this will take some time to run!
results<- execute.multi.analysis( species.code = species.codes,
unidentified.sightings = unid.defs,
models.by.species.code = mod.uncert,
ddf.model.objects = models,
ddf.model.options = model.opts,
region.table = region.table,
sample.table = sample.table,
obs.table = obs.table,
bootstrap = TRUE,
bootstrap.option = bootstrap.opts)
# }
# NOT RUN {
#Short example to run as per CRAN requirements -
# warning only 1 repetition, results not interpretable!
bootstrap.opts <- list(resample = 'samples', n=1)
results<- execute.multi.analysis( species.code = species.codes,
unidentified.sightings = unid.defs,
models.by.species.code = mod.uncert,
ddf.model.objects = models,
ddf.model.options = model.opts,
region.table = region.table,
sample.table = sample.table,
obs.table = obs.table,
bootstrap = TRUE,
bootstrap.option = bootstrap.opts)
#These are simulated data and true abundances are:
# CD (common dolphins) = 3000
# WSD (white sided dolphins) = 1500
summary(results)
# }
Run the code above in your browser using DataLab