How do I install and start secr?
Follow the usual procedure for installing from CRAN archive (see menu
item Packages | Install package(s)... in Windows). You also need to get
the package abind from CRAN.
Other required packages (MASS, nlme, stats) should be
available as part of your Rinstallation.
Like other contributed packages, secr needs to be loaded before
each use e.g.,library(secr)
.
You can learn about changes in the current version with
news(package = "secr")
.How can I get help?
There are three general ways of displaying documentation from within R.
Firstly, you can bring up help pages for particular functions from the
command prompt. For example:
?secr
or
?secr.fit
Secondly, help.search() lets you ask for a list of the help pages on a
vague topic (or just use ?? at the prompt). For example:
?? "linear models"
Thirdly, you can display various secr documents listed in
secr-package
.
Tip: to search all secr help pages open the pdf version of the manual in
Acrobat Reader (../doc/secr-manual.pdf; see also ?secr) and use
F.
There is a support forum at http://www.phidot.org/forum under
`DENSITY|secr'. Please read the FAQ there before posting. See below for
more Rtips. Some specific problems with secr.fit
are covered in
troubleshooting.How should I report a problem?
If you get really stuck or find something you think is a bug then please
report the problem.
You may be asked to send an actual dataset - ideally, the simplest one
that exhibits the problem. The correct address for this is
density.software@otago.ac.nz. Use save
to wrap
several Robjects together in one .RData file, e.g.,
save("captdata", "secrdemo.0", "secrdemo.b", file =
"mydata.RData")
. Also, paste into the text of your message the output
from packageDescription( "secr" )
.Why do I get different answers from secr and Density?
Strictly speaking, this should not happen if you have specified the same
model and likelihood, although you may see a little variation due to the
different maximization algorithms. Likelihoods (and estimates) may
differ if you use different integration meshes (habitat masks), which
can easily happen because the programs differ in how they set up the
mesh. If you want to make a precise comparison, save the Density mesh
to a file and read it into secr, or vice versa.
Extreme data, especially rare long-distance movements, may be handled
differently by the two programs. The `minprob' component of the
`details' argument of secr.fit
sets a lower threshold of
probability for capture histories (smaller values are all set to
minprob), whereas Density has no explicit limit.How can I speed up model fitting and model selection?
If you don't need to model variation in density over space or time then
consider maximizing the conditional likelihood in secr.fit
(CL =
TRUE). This reduces the complexity of the optimization problem,
especially where there are several sessions and you want
session-specific density estimates (by default, derived
returns a
separate estimate for each session even if the detection parameters are
constant across sessions).
Check the extent and spacing of the habitat mask that you are using.
Execution time is roughly proportional to the number of mask points
(nrow(mymask)
). Default settings can lead to very large masks
for detector arrays that are elongated `north-south' because the number
of points in the east-west direction is fixed. Compare results with a
much sparser mask (e.g., nx = 32 instead of nx = 64).
Do you really need to fit that complex model? Chasing down small
decrements in AIC is so last-century. Remember that detection parameters
are mostly nuisance parameters, and models with big differences in AIC
may barely differ in their density estimates. This is a good topic for
further research - we seem to need a `focussed information criterion'
(Claeskens and Hjort 2008) to discern the differences that matter.
If your detectors are arranged in similar clusters (e.g., small square
grids) then try the function mash
.
Use score.test
to compare nested models. At each stage this
requires only the more simple model to have been fitted in full; further
processing is required to obtain a numerical estimate of the gradient of
the likelihood surface for the more complex model, but this is much
faster than maximizing the likelihood.Does secr use multiple cores?
Some computations can be run in parallel on multiple processors (most
desktops these days have multiple cores), but capability is
limited. Check the 'ncores' argument of
sim.secr() and secr.fit() and ?ncores. The speed gain is significant
for parametric bootstrap computations in sim.secr. Parallelisation is
also allowed for the session likelihood components of a multi-session
model in secr.fit(), but gains there seem to be small or negative.Can a model use detector-level covariates that vary over
time?
Yes. See ?timevaryingcov. This is an obvious way to control for
varying effort that cannot be described by the `usage' atribute
(which allows only used vs. not used). A tip: covariate models fit
more quickly when the covariate takes only a few different values.Things You Might Need To Know About R
The function findFn
in package sos lets you search CRAN for
R functions by matching text in their documentation.
There is now a vast amount of Radvice available on the web. For the
terminally frustrated, `R inferno' by Patrick Burns is recommended
(http://www.burns-stat.com/pages/Tutor/R_inferno.pdf). "If you are using
R and you think you're in hell, this is a map for you".
Method functions for S3 classes cannot be listed in the usual way by
typing the function name at the Rprompt because they are `hidden' in a
namespace. Get around this with getAnywhere(). For example:
getAnywhere(print.secr)
R objects have `attributes' that usually are kept out of sight.
Important attributes are `class' (all objects), `dim' (matrices and
arrays) and `names' (lists). secr hides quite a lot of useful data
as named `attributes'. Usually you will use summary and extraction
methods (traps
, covariates
, usage
etc.) to view and change
the attributes of the various classes of object in secr. If you're
curious, you can reveal the lot with `attributes'. For example, with
the demonstration capture history data `captdata':
traps(captdata) ## extraction method for `traps'
attributes(captdata) ## all attributes
Also, the function str
provides a compact summary of any object:
str(captdata)