estimatePopsize {singleRcapture} | R Documentation |
Single source capture-recapture models
Description
estimatePopsize
first fits appropriate (v)glm model and
then estimates full (observed and unobserved) population size.
In this types of models it is assumed that the response vector
(i.e. the dependent variable) corresponds to the number of times a given unit
was observed in the source.
Population size is then usually estimated by Horvitz-Thompson type estimator:
where \(I_{k}=I_{Y_{k} > 0}\) are indicator variables, with value 1 if kth unit was observed at least once and 0 otherwise.
Usage
estimatePopsize(formula, ...)
## Default S3 method:
estimatePopsize(
formula,
data,
model = c("ztpoisson", "ztnegbin", "ztgeom", "zotpoisson", "ztoipoisson",
"oiztpoisson", "ztHurdlepoisson", "Hurdleztpoisson", "zotnegbin", "ztoinegbin",
"oiztnegbin", "ztHurdlenegbin", "Hurdleztnegbin", "zotgeom", "ztoigeom", "oiztgeom",
"ztHurdlegeom", "ztHurdlegeom", "zelterman", "chao"),
ratioReg = FALSE,
weights = NULL,
subset = NULL,
naAction = NULL,
method = c("optim", "IRLS"),
popVar = c("analytic", "bootstrap", "noEst"),
controlMethod = NULL,
controlModel = NULL,
controlPopVar = NULL,
modelFrame = TRUE,
x = FALSE,
y = TRUE,
contrasts = NULL,
offset,
...
)
Arguments
formula |
formula for the model to be fitted, only applied to the "main" linear predictor. Only single response models are available. |
... |
additional optional arguments passed to other methods eg.
|
data |
data frame or object coercible to data.frame class containing data for the regression and population size estimation. |
model |
model for regression and population estimate full description in |
ratioReg |
Not yet implemented |
weights |
optional object of prior weights used in fitting the model.
Can be used to specify number of occurrences of rows in data see |
subset |
a logical vector indicating which observations should be used
in regression and population size estimation. It will be evaluated on |
naAction |
Not yet implemented. |
method |
method for fitting values currently supported: iteratively
reweighted least squares ( |
popVar |
a method of constructing confidence interval either analytic
or bootstrap. Bootstrap confidence interval type may be specified in
|
controlMethod |
a list indicating parameters to use in fitting the model
may be constructed with |
controlModel |
a list indicating additional formulas for regression
(like formula for inflation parameter/dispersion parameter) may be
constructed with |
controlPopVar |
a list indicating parameters to use in estimating variance
of population size estimation may be constructed with
|
modelFrame , x , y |
logical value indicating whether to return model matrix, dependent vector and model matrix as a part of output. |
contrasts |
not yet implemented. |
offset |
a matrix of offset values with number of columns matching the number of distribution parameters providing offset values to each of linear predictors. |
Details
The generalized linear model is characterized by equation
\[\boldsymbol{\eta}=\boldsymbol{X}\boldsymbol{\beta}\]
where \(\boldsymbol{X}\) is the (lm) model matrix.
The vector generalized linear model is similarly characterized by equations
\[\boldsymbol{\eta}_{k}=\boldsymbol{X}_{k}\boldsymbol{\beta}_{k}\]
where \(\boldsymbol{X}_{k}\) is a (lm) model
matrix constructed from appropriate formula
(specified in controlModel
parameter).
The \(\boldsymbol{\eta}\) is then a vector constructed as:
\[\boldsymbol{\eta}=\begin{pmatrix} \boldsymbol{\eta}_{1} \cr \boldsymbol{\eta}_{2} \cr \dotso \cr \boldsymbol{\eta}_{p} \end{pmatrix}^{T}\]and in cases of models in our package the (vlm) model matrix is constructed as a block matrix:
\[\boldsymbol{X}_{vlm}= \begin{pmatrix} \boldsymbol{X}_{1} & \boldsymbol{0} &\dotso &\boldsymbol{0}\cr \boldsymbol{0} & \boldsymbol{X}_{2} &\dotso &\boldsymbol{0}\cr \vdots & \vdots & \ddots & \vdots\cr \boldsymbol{0} & \boldsymbol{0} &\dotso &\boldsymbol{X}_{p} \end{pmatrix}\]this differs from convention in VGAM
package (if we only consider our
special cases of vglm models) but this is just a convention and does not
affect the model, this convention is taken because it makes fitting with
IRLS (explanation of algorithm in estimatePopsizeFit()
) algorithm easier.
(If constraints
matrixes in vglm
match the ones we implicitly
use the vglm
model matrix differs with respect to order of
kronecker
multiplication of X
and constraints
.)
In this package we use observed likelihood to fit regression models.
As mentioned above usually the population size estimation is done via: \[\hat{N} = \sum_{k=1}^{N}\frac{I_{k}}{\mathbb{P}(Y_{k}>0)} = \sum_{k=1}^{N_{obs}}\frac{1}{1-\mathbb{P}(Y_{k}=0)}\]
where \(I_{k}=I_{Y_{k} > 0}\) are indicator variables, with value 1 if kth unit was observed at least once and 0 otherwise. The \(\mathbb{P}(Y_{k}>0)\) are estimated by maximum likelihood.
The following assumptions are usually present when using the method of estimation described above:
The specified regression model is correct. This entails linear relationship between independent variables and dependent ones and dependent variable being generated by appropriate distribution.
No unobserved heterogeneity. If this assumption is broken there are some possible (admittedly imperfect) workarounds see details in
singleRmodels()
.The population size is constant in relevant time frame.
Depending on confidence interval construction (asymptotic) normality of \(\hat{N}\) statistic is assumed.
There are two ways of estimating variance of estimate \(\hat{N}\),
the first being "analytic"
usually done by application of
law of total variance to \(\hat{N}\):
and then by \(\delta\) method to \(\hat{N}|I_{1},\dots I_{N}\):
\[\mathbb{E}\left(\text{var} \left(\hat{N}|I_{1},\dots,I_{n}\right)\right)= \left.\left(\frac{\partial(N|I_1,\dots,I_N)}{\partial\boldsymbol{\beta}}\right)^{T} \text{cov}\left(\boldsymbol{\beta}\right) \left(\frac{\partial(N|I_1,\dots,I_N)}{\partial\boldsymbol{\beta}}\right) \right|_{\boldsymbol{\beta}=\hat{\boldsymbol{\beta}}}\]and the \(\text{var}\left(\mathbb{E}(\hat{N}|I_{1},\dots,I_{n})\right)\) term may be derived analytically (if we assume independence of observations) since \(\hat{N}|I_{1},\dots,I_{n}\) is just a constant.
In general this gives us: \[ \begin{aligned} \text{var}\left(\mathbb{E}(\hat{N}|I_{1},\dots,I_{n})\right)&= \text{var}\left(\sum_{k=1}^{N}\frac{I_{k}}{\mathbb{P}(Y_{k}>0)}\right)\cr &=\sum_{k=1}^{N}\text{var}\left(\frac{I_{k}}{\mathbb{P}(Y_{k}>0)}\right)\cr &=\sum_{k=1}^{N}\frac{1}{\mathbb{P}(Y_{k}>0)^{2}}\text{var}(I_{k})\cr &=\sum_{k=1}^{N}\frac{1}{\mathbb{P}(Y_{k}>0)^{2}}\mathbb{P}(Y_{k}>0)(1-\mathbb{P}(Y_{k}>0))\cr &=\sum_{k=1}^{N}\frac{1}{\mathbb{P}(Y_{k}>0)}(1-\mathbb{P}(Y_{k}>0))\cr &\approx\sum_{k=1}^{N}\frac{I_{k}}{\mathbb{P}(Y_{k}>0)^{2}}(1-\mathbb{P}(Y_{k}>0))\cr &=\sum_{k=1}^{N_{obs}}\frac{1-\mathbb{P}(Y_{k}>0)}{\mathbb{P}(Y_{k}>0)^{2}} \end{aligned} \]
Where the approximation on 6th line appears because in 5th line we sum over all units, that includes unobserved units, since \(I_{k}\) are independent and \(I_{k}\sim b(\mathbb{P}(Y_{k}>0))\) the 6th line is an unbiased estimator of the 5th line.
The other method for estimating variance is "bootstrap"
, but since
\(N_{obs}=\sum_{k=1}^{N}I_{k}\) is also a random variable bootstrap
will not be as simple as just drawing \(N_{obs}\) units from data
with replacement and just computing \(\hat{N}\).
Method described above is referred to in literature as "nonparametric"
bootstrap (see controlPopVar()
), due to ignoring variability in observed
sample size it is likely to underestimate variance.
A more sophisticated bootstrap procedure may be described as follows:
Compute the probability distribution as: \[ \frac{\hat{\boldsymbol{f}}_{0}}{\hat{N}}, \frac{\boldsymbol{f}_{1}}{\hat{N}}, \dots, \frac{\boldsymbol{f}_{\max{y}}}{\hat{N}}\] where \(\boldsymbol{f}_{n}\) denotes observed marginal frequency of units being observed exactly n times.
Draw \(\hat{N}\) units from the distribution above (if \(\hat{N}\) is not an integer than draw \(\lfloor\hat{N}\rfloor + b(\hat{N}-\lfloor\hat{N}\rfloor)\)), where \(\lfloor\cdot\rfloor\) is the floor function.
Truncated units with \(y=0\).
If there are covariates draw them from original data with replacement from uniform distribution. For example if unit drawn to new data has \(y=2\) choose one of covariate vectors from original data that was associated with unit for which was observed 2 times.
Regress \(\boldsymbol{y}_{new}\) on \(\boldsymbol{X}_{vlm new}\) and obtain \(\hat{\boldsymbol{\beta}}_{new}\), with starting point \(\hat{\boldsymbol{\beta}}\) to make it slightly faster, use them to compute \(\hat{N}_{new}\).
Repeat 2-5 unit there are at least
B
statistics are obtained.Compute confidence intervals based on
alpha
andconfType
specified incontrolPopVar()
.
To do step 1 in procedure above it is convenient to first draw binary vector of length \(\lfloor\hat{N}\rfloor + b(\hat{N}-\lfloor\hat{N}\rfloor)\) with probability \(1-\frac{\hat{\boldsymbol{f}}_{0}}{\hat{N}}\), sum elements in that vector to determine the sample size and then draw sample of this size uniformly from the data.
This procedure is known in literature as "semiparametric"
bootstrap
it is necessary to assume that the have a correct estimate
\(\hat{N}\) in order to use this type of bootstrap.
Lastly there is "paramteric"
bootstrap where we assume that the
probabilistic model used to obtain \(\hat{N}\) is correct the
bootstrap procedure may then be described as:
Draw \(\lfloor\hat{N}\rfloor + b(\hat{N}-\lfloor\hat{N}\rfloor)\) covariate information vectors with replacement from data according to probability distribution that is proportional to: \(N_{k}\), where \(N_{k}\) is the contribution of kth unit i.e. \(\dfrac{1}{\mathbb{P}(Y_{k}>0)}\).
Determine \(\boldsymbol{\eta}\) matrix using estimate \(\hat{\boldsymbol{\beta}}\).
Generate \(\boldsymbol{y}\) (dependent variable) vector using \(\boldsymbol{\eta}\) and probability mass function associated with chosen model.
Truncated units with \(y=0\) and construct \(\boldsymbol{y}_{new}\) and \(\boldsymbol{X}_{vlm new}\).
Regress \(\boldsymbol{y}_{new}\) on \(\boldsymbol{X}_{vlm new}\) and obtain \(\hat{\boldsymbol{\beta}}_{new}\) use them to compute \(\hat{N}_{new}\).
Repeat 1-5 unit there are at least
B
statistics are obtained.Compute confidence intervals based on
alpha
andconfType
specified incontrolPopVar()
It is also worth noting that in the "analytic"
method estimatePopsize
only uses "standard" covariance matrix estimation. It is possible that improper
covariance matrix estimate is the only part of estimation that has its assumptions
violated. In such cases post-hoc procedures are implemented in this package
to address this issue.
Lastly confidence intervals for \(\hat{N}\) are computed (in analytic case) either by assuming that it follows a normal distribution or that variable \(\ln(N-\hat{N})\) follows a normal distribution.
These estimates may be found using either summary.singleRStaticCountData
method or popSizeEst.singleRStaticCountData
function. They're labelled as
normal
and logNormal
respectively.
Value
Returns an object of class c("singleRStaticCountData", "singleR", "glm", "lm")
with type list
containing:
y
– Vector of dependent variable if specified at function call.X
– Model matrix if specified at function call.formula
– A list with formula provided on call and additional formulas specified incontrolModel
.call
– Call matching original input.coefficients
– A vector of fitted coefficients of regression.control
– A list of control parameters forcontrolMethod
andcontrolModel
,controlPopVar
is included in populationSize.model
– Model which estimation of population size and regression was built, object of class family.deviance
– Deviance for the model.priorWeights
– Prior weight provided on call.weights
– IfIRLS
method of estimation was chosen weights returned byIRLS
, otherwise same aspriorWeights
.residuals
– Vector of raw residuals.logL
– Logarithm likelihood obtained at final iteration.iter
– Numbers of iterations performed in fitting or ifstats::optim
was used number of call to loglikelihood function.dfResiduals
– Residual degrees of freedom.dfNull
– Null degrees of freedom.fittValues
– Data frame of fitted values for both mu (the expected value) and lambda (Poisson parameter).populationSize
– A list containing information of population size estimate.modelFrame
– Model frame if specified at call.linearPredictors
– Vector of fitted linear predictors.sizeObserved
– Number of observations in original model frame.terms
– terms attribute of model frame used.contrasts
– contrasts specified in function call.naAction
– naAction used.which
– list indicating which observations were used in regression/population size estimation.fittingLog
– log of fitting information for"IRLS"
fitting if specified incontrolMethod
.
Author(s)
Piotr Chlebicki, Maciej Beręsewicz
References
General single source capture recapture literature:
Zelterman, Daniel (1988). ‘Robust estimation in truncated discrete distributions with application to capture-recapture experiments’. In: Journal of statistical planning and inference 18.2, pp. 225–237.
Heijden, Peter GM van der et al. (2003). ‘Point and interval estimation of the population size using the truncated Poisson regression model’. In: Statistical Modelling 3.4, pp. 305–322. doi: 10.1191/1471082X03st057oa.
Cruyff, Maarten J. L. F. and Peter G. M. van der Heijden (2008). ‘Point and Interval Estimation of the Population Size Using a Zero-Truncated Negative Binomial Regression Model’. In: Biometrical Journal 50.6, pp. 1035–1050. doi: 10.1002/bimj.200810455
Böhning, Dankmar and Peter G. M. van der Heijden (2009). ‘A covariate adjustment for zero-truncated approaches to estimating the size of hidden and elusive populations’. In: The Annals of Applied Statistics 3.2, pp. 595–610. doi: 10.1214/08-AOAS214.
Böhning, Dankmar, Alberto Vidal-Diez et al. (2013). ‘A Generalization of Chao’s Estimator for Covariate Information’. In: Biometrics 69.4, pp. 1033– 1042. doi: 10.1111/biom.12082
Böhning, Dankmar and Peter G. M. van der Heijden (2019). ‘The identity of the zero-truncated, one-inflated likelihood and the zero-one-truncated likelihood for general count densities with an application to drink-driving in Britain’. In: The Annals of Applied Statistics 13.2, pp. 1198–1211. doi: 10.1214/18-AOAS1232.
Navaratna WC, Del Rio Vilas VJ, Böhning D. Extending Zelterman's approach for robust estimation of population size to zero-truncated clustered Data. Biom J. 2008 Aug;50(4):584-96. doi: 10.1002/bimj.200710441.
Böhning D. On the equivalence of one-inflated zero-truncated and zero-truncated one-inflated count data likelihoods. Biom J. 2022 Aug 15. doi: 10.1002/bimj.202100343.
Böhning, D., Friedl, H. Population size estimation based upon zero-truncated, one-inflated and sparse count data. Stat Methods Appl 30, 1197–1217 (2021). doi: 10.1007/s10260-021-00556-8
Bootstrap:
Zwane, PGM EN and Van der Heijden, Implementing the parametric bootstrap in capture-recapture models with continuous covariates 2003 Statistics & probability letters 65.2 pp 121-125
Norris, James L and Pollock, Kenneth H Including model uncertainty in estimating variances in multiple capture studies 1996 in Environmental and Ecological Statistics 3.3 pp 235-244
Vector generalized linear models:
Yee, T. W. (2015). Vector Generalized Linear and Additive Models: With an Implementation in R. New York, USA: Springer. ISBN 978-1-4939-2817-0.
See Also
stats::glm()
– For more information on generalized linear models.
stats::optim()
– For more information on optim
function used in
optim
method of fitting regression.
controlMethod()
– For control parameters related to regression.
controlPopVar()
– For control parameters related to population size estimation.
controlModel()
– For control parameters related to model specification.
estimatePopsizeFit()
– For more information on fitting procedure in
esitmate_popsize
.
popSizeEst()
redoPopEstimation()
– For extracting population size
estimation results are applying post-hoc procedures.
summary.singleRStaticCountData()
– For summarizing important information about the
model and population size estimation results.
marginalFreq()
– For information on marginal frequencies and comparison
between observed and fitted quantities.
VGAM::vglm()
– For more information on vector generalized linear models.
singleRmodels()
– For description of various models.
Examples
# Model from 2003 publication
# Point and interval estimation of the
# population size using the truncated Poisson regression mode
# Heijden, Peter GM van der et al. (2003)
model <- estimatePopsize(
formula = capture ~ gender + age + nation,
data = netherlandsimmigrant,
model = ztpoisson
)
summary(model)
# Graphical presentation of model fit
plot(model, "rootogram")
# Statistical test
# see documentation for summary.singleRmargin
summary(marginalFreq(model), df = 1, "group")
# We currently support 2 methods of numerical fitting
# (generalized) IRLS algorithm and via stats::optim
# the latter one is faster when fitting negative binomial models
# (and only then) due to IRLS having to numerically compute
# (expected) information matrixes, optim is also less reliable when
# using alphaFormula argument in controlModel
modelNegBin <- estimatePopsize(
formula = TOTAL_SUB ~ .,
data = farmsubmission,
model = ztnegbin,
method = "optim"
)
summary(modelNegBin)
summary(marginalFreq(modelNegBin))
# More advanced call that specifies additional formula and shows
# in depth information about fitting procedure
pseudoHurdleModel <- estimatePopsize(
formula = capture ~ nation + age,
data = netherlandsimmigrant,
model = Hurdleztgeom,
method = "IRLS",
controlMethod = controlMethod(verbose = 5),
controlModel = controlModel(piFormula = ~ gender)
)
summary(pseudoHurdleModel)
# Assessing model fit
plot(pseudoHurdleModel, "rootogram")
summary(marginalFreq(pseudoHurdleModel), "group", df = 1)
# A advanced input with additional information for fitting procedure and
# additional formula specification and different link for inflation parameter.
Model <- estimatePopsize(
formula = TOTAL_SUB ~ .,
data = farmsubmission,
model = oiztgeom(omegaLink = "cloglog"),
method = "IRLS",
controlMethod = controlMethod(
stepsize = .85,
momentumFactor = 1.2,
epsilon = 1e-10,
silent = TRUE
),
controlModel = controlModel(omegaFormula = ~ C_TYPE + log_size)
)
summary(marginalFreq(Model), df = 18 - length(Model$coefficients))
summary(Model)