Compute score tests comparing a fitted model and a more general alternative model.
score.test(secr, ..., betaindex = NULL, trace = FALSE, ncores = NULL, .relStep = 0.001,
minAbsPar = 0.1)score.table(object, ..., sort = TRUE, dmax = 10)
An object of class `score.test' that inherits from `htest', a list with components
the value the chi-squared test statistic (score statistic)
degrees of freedom of the approximate chi-squared distribution of the test statistic (difference in number of parameters H0, H1)
probability of test statistic assuming chi-square distribution
a character string indicating the type of test performed
character string with null hypothesis, alternative hypothesis and arguments to function call from fit of H0
simpler model
number of parameters in simpler model
alternative model
coefficients of alternative model
Akaike's information criterion, approximated from score statistic
AIC with small-sample adjustment of Hurvich & Tsai 1989
If ... defines several alternative models then a list of score.test objects is returned.
The output from score.table
is a dataframe with one row per model, including the reference model.
fitted secr model
one or more alternative models OR a fitted secr model
logical. If TRUE then output one-line summary at each evaluation of the likelihood
integer number of threads for parallel processing
see fdHess
see fdHess
vector of indices mapping fitted values to parameters in the alternative model
score.test object or list of such objects
logical for whether output rows should be in descending order of AIC
threshold of dAIC for inclusion in model set
Score tests allow fast model selection (e.g. Catchpole & Morgan 1996).
Only the simpler model need be fitted. This implementation uses the
observed information matrix, which may sometimes mislead (Morgan et al.
2007). The gradient and second derivative of the likelihood function are
evaluated numerically at the point in the parameter space of the second
model corresponding to the fit of the first model. This operation uses
the function fdHess
of the nlme package; the likelihood
must be evaluated several times, but many fewer times than would be
needed to fit the model. The score statistic is an approximation to the
likelihood ratio; this allows the difference in AIC to be estimated.
Covariates are inferred from components of the reference model
secr
. If the new models require additional covariates these may
usually be added to the respective component of secr
.
Mapping of parameters between the fitted and alternative models
sometimes requires user intervention via the betaindex
argument.
For example betaindex
= c(1,2,4) is the correct mapping when
comparing the null model (D\(\sim{~}\)1, g0\(\sim{~}\)1,
sigma\(\sim{~}\)1) to one with a behavioural effect on g0
(D\(\sim{~}\)1, g0\(\sim{~}\)b, sigma\(\sim{~}\)1).
The arguments .relStep
and minAbsPar
control the numerical
gradient calculation and are passed directly to
fdHess
. More investigation is needed to determine
optimal settings.
score.table
summarises one or more score tests in the form of a
model comparison table. The ... argument here allows the inclusion of
additional score test objects (note the meaning differs from
score.test
). Approximate AIC values are used to compute relative
AIC model weights for all models within dmax AIC units of the best
model.
If ncores = NULL
then the existing value from the environment variable
RCPP_PARALLEL_NUM_THREADS is used (see setNumThreads
).
Catchpole, E. A. and Morgan, B. J. T. (1996) Model selection of ring-recovery models using score tests. Biometrics 52, 664--672.
Hurvich, C. M. and Tsai, C. L. (1989) Regression and time series model selection in small samples. Biometrika 76, 297--307.
McCrea, R. S. and Morgan, B. J. T. (2011) Multistate mark-recapture model selection using score tests. Biometrics 67, 234--241.
Morgan, B. J. T., Palmer, K. J. and Ridout, M. S. (2007) Negative score test statistic. American statistician 61, 285--288.
AIC
,
LR.test
if (FALSE) {
AIC (secrdemo.0, secrdemo.b)
st <- score.test (secrdemo.0, g0 ~ b)
st
score.table(st)
## adding a time covariate to separate occasions (1,2) from (3,4,5)
secrdemo.0$timecov <- data.frame(t2 = factor(c(1,1,2,2,2)))
st2 <- score.test (secrdemo.0, g0 ~ t2)
score.table(st,st2)
}
Run the code above in your browser using DataLab