| pkm {GenEst} | R Documentation |
Fit pk searcher efficiency models.
Description
Searcher efficiency is modeled as a function of the number of
times a carcass has been missed in previous searches and any number of
covariates. Format and usage parallel that of common R functions
lm, glm, and gam. However, the input data
(data) is structured differently to accommodate the
multiple-search searcher efficiency trials (see Details), and model
formulas may be entered for both p (akin to an intercept) and
k (akin to a slope).
Usage
pkm(
formula_p,
formula_k = NULL,
data,
obsCol = NULL,
kFixed = NULL,
allCombos = FALSE,
sizeCol = NULL,
CL = 0.9,
kInit = 0.7,
quiet = FALSE,
...
)
pkm0(
formula_p,
formula_k = NULL,
data,
obsCol = NULL,
kFixed = NULL,
kInit = 0.7,
CL = 0.9,
quiet = FALSE
)
pkmSet(
formula_p,
formula_k = NULL,
data,
obsCol = NULL,
kFixed = NULL,
kInit = 0.7,
CL = 0.9,
quiet = FALSE
)
pkmSize(
formula_p,
formula_k = NULL,
data,
kFixed = NULL,
obsCol = NULL,
sizeCol = NULL,
allCombos = FALSE,
kInit = 0.7,
CL = 0.9,
quiet = FALSE
)
Arguments
formula_p |
Formula for p; an object of class |
formula_k |
Formula for k; an object of class |
data |
Data frame with results from searcher efficiency trials and any
covariates included in |
obsCol |
Vector of names of columns in |
kFixed |
Parameter for user-specified |
allCombos |
logical. If |
sizeCol |
character string. The name of the column in |
CL |
numeric value in (0, 1). confidence level |
kInit |
numeric value in (0, 1). Initial value used for numerical
optimization of |
quiet |
Logical indicator of whether or not to print messsages |
... |
additional arguments passed to subfunctions |
Details
The probability of finding a carcass that is present at the time of
search is p on the first search after carcass arrival and is
assumed to decrease by a factor of k each time the carcass is
missed in searches. Both p and k may depend on covariates
such as ground cover, season, species, etc., and a separate model format
(formula_p and formula_k) may be entered for each. The
models are entered as they would be in the familiar lm or
glm functions in R. For example, p might vary with
A and B, while k varies
only with A. A user might then enter p ~ A + B
for formula_p and k ~ A for
formula_k. Other R conventions for defining formulas may also be
used, with A:B for the interaction between covariates
A and B and A * B as short-hand for A + B + A:B.
Search trial data must be entered in a data frame with data in
each row giving the fate of a single carcass in the field trials. There
must be a column for each search occassion, with 0, 1, or NA depending on
whether the carcass was missed, found, or not available (typically
because it was found and removed on a previous search, had been earlier
removed by scavengers, or was not searched for) on the given search
occasion. Additional columns with values for categorical covariates
(e.g., visibility = E, M, or D) may also be included.
When all trial carcasses are either found on the first search or
are missed on the first search after carcass placement, pkm effects a
necessary adjustment to the for accuracy; otherwise, the model would not be
able to determine the uncertainty and would substantially over-estimate the
variance of the parameter estimates, giving \hat{p} essentially equal
to 0 or 1 with approximately equal probability. The adjustment is to fit the
model on an adjusted data set with duplicated copies of the original data
(2n observations) but with one carcass having the opposite fate of the
others. For example, in field trials with very high searcher efficiency and
n = 10 carcasses, all of which are found in the first search after
carcass placement, the original data set would have a carcass observation
column consisting of 1s (rep(1, 10)). The adjusted data set would
have an observation column consisting of 2n - 1 1s and one 0. In this
case, the point estimate of p is 1/(2n) with distribution that
closely resembling the Bayesian posterior distributions of p with a
uniform or a Jeffreys prior. The adjustment is applied on a cellwise basis
in full cell models (e.g., 1, A, B, A * B). In the additive model with two
predictors (A + B), the adjustment is made only when a full level of
covariate A or B is all 0s or 1s.
Value
an object of an object of class pkm, pkmSet,
pkmSize, or pkmSetSize.
pkm0()returns a
pkmobject, which is a description of a single, fitted pk model. Due to the large number and complexity of components of apkmmodel, only a subset of them is printed automatically; the rest can be viewed/accessed via the$operator if desired. These are described in detail in the 'pkmComponents' section.pkmSet()returns a list of
pkmobjects, one for each of the submodels, as described with parameterallCombos = TRUE.pkmSize()returns a list of
pkmSetobjects (one for each 'size') ifallCombos = T, or a list ofpkmobjects (one for each 'size') ifallCombos = Tpkmreturns a
pkm,pkmSet,pkmSize, orpkmSetSizeobject:-
pkmobject ifallCombos = FALSE, sizeCol = NULL -
pkmSetobject ifallCombos = TRUE, sizeCol = NULL -
pkmSizeobject ifallCombos = FALSE, sizeCol != NULL -
pkmSetSizeobject ifallCombos = TRUE, sizeCol != NULL
-
pkm Components
The following components of a pkm object are displayed automatically:
callthe function call to fit the model
formula_pthe model formula for the
pparameterformula_kthe model formula for the
kparameterpredictorslist of covariates of
pand/orkAICcthe AIC value as corrected for small sample size
convergenceconvergence status of the numerical optimization to find the maximum likelihood estimates of
pandk. A value of0indicates that the model was fit successfully. For help in deciphering other values, seeoptim.cell_pksummary statistics for estimated cellwise estimates of
pandk, including the number of carcasses in each cell, medians and upper & lower bounds on CIs for each parameter, indexed by cell (or combination of covariate levels).
The following components are not printed automatically but can be accessed
via the $ operator:
datathe data used to fit the model
data0$datawith NA rows removedbetahat_p, betahat_kparameter estimates for the terms in the regression model for for
pandk(logit scale). Ifkis fixed or not provided, thenbetahat_kis not calculated.varbetathe variance-covariance matrix of the estimators for
c(betahat_p, betahat_k).cellMM_p, cellMM_kcellwise model (design) matrices for covariate structures of
p_formulaandk_formulalevels_p, levels_kall levels of each covariate of
pandknbeta_p, nbeta_knumber of parameters to fit the
pandkmodelscellscell structure of the pk-model, i.e., combinations of all levels for each covariate of
pandk. For example, ifcovar1has levels"a","b", and"c", andcovar2has levels"X"and"Y", then the cells would consist ofa.X,a.Y,b.X,b.Y,c.X, andc.Y.ncelltotal number of cells
predictors_k, predictors_pcovariates of
pandkobservationsobservations used to fit the model
kFixedthe input
kFixedAICthe AIC value for the fitted model
carcCellsthe cell to which each carcass belongs
CLthe input
CLloglikthe log-liklihood for the maximum likelihood estimate
pOnlya logical value telling whether
kis included in the model.pOnly = TRUEif and only iflength(obsCol) == 1)andkFixed = NULL
.
data_adjdata0as adjusted for the 2n fix to accommodate scenarios in which all trial carcasses are either found or all are not found on the first search occasion (uncommon)fixBadCellsvector giving the names of cells adjusted for the 2n fix
Advanced
pkmSize may also be used to fit a single model for each carcass class if
allCombos = FALSE. To do so, formula_p and formula_k
must be a named list of formulas with names matching the sizes listed in
unique(data[, sizeCol]). The return value is then a list of
pkm objects, one for each size.
See Also
Examples
head(data(wind_RP))
mod1 <- pkm(formula_p = p ~ Season, formula_k = k ~ 1, data = wind_RP$SE)
class(mod1)
mod2 <- pkm(formula_p = p ~ Season, formula_k = k ~ 1, data = wind_RP$SE,
allCombos = TRUE)
class(mod2)
names(mod2)
class(mod2[[1]])
mod3 <- pkm(formula_p = p ~ Season, formula_k = k ~ 1, data = wind_RP$SE,
allCombos = TRUE, sizeCol = "Size")
class(mod3)
names(mod3)
class(mod3[[1]])
class(mod3[[1]][[1]])