From 0629517654a7d97ff06c4063743e3dfe3a0a136d Mon Sep 17 00:00:00 2001 From: BERENZ Date: Wed, 12 Feb 2025 12:11:57 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20ncn-fore?= =?UTF-8?q?igners/singleRcapture@09c152272114c5a55bd16f105995852f38771d15?= =?UTF-8?q?=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- articles/singleRcapture.html | 2 +- pkgdown.yml | 2 +- reference/carcassubmission.html | 4 ++-- reference/farmsubmission.html | 4 ++-- reference/index.html | 8 ++++---- reference/netherlandsimmigrant.html | 4 ++-- reference/stratifyPopsize.html | 4 ++-- search.json | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/articles/singleRcapture.html b/articles/singleRcapture.html index 3d63f38..2e36860 100644 --- a/articles/singleRcapture.html +++ b/articles/singleRcapture.html @@ -2314,7 +2314,7 @@

Implementing a custom singleRcapture family ## } ## res ## } -## <bytecode: 0x55ca34c79b28> +## <bytecode: 0x55c7eacdcb28> ## <environment: namespace:singleRcapture>

One could, of course, include the code for computing them manually.

diff --git a/pkgdown.yml b/pkgdown.yml index bb5abb7..76eb848 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -3,7 +3,7 @@ pkgdown: 2.1.1 pkgdown_sha: ~ articles: singleRcapture: singleRcapture.html -last_built: 2025-02-12T11:48Z +last_built: 2025-02-12T12:08Z urls: reference: https://ncn-foreigners.github.io/singleRcapture/reference article: https://ncn-foreigners.github.io/singleRcapture/articles diff --git a/reference/carcassubmission.html b/reference/carcassubmission.html index 69319c3..9801f77 100644 --- a/reference/carcassubmission.html +++ b/reference/carcassubmission.html @@ -1,5 +1,5 @@ -British farm carcass submissions data — carcassubmission • singleRcaptureThe British farm carcass submissions data — carcassubmission • singleRcapture
diff --git a/reference/farmsubmission.html b/reference/farmsubmission.html index 232496f..2c95892 100644 --- a/reference/farmsubmission.html +++ b/reference/farmsubmission.html @@ -1,5 +1,5 @@ -British farm submissions data — farmsubmission • singleRcaptureThe British farm submissions data — farmsubmission • singleRcapture
diff --git a/reference/index.html b/reference/index.html index 6666ef9..9120dd3 100644 --- a/reference/index.html +++ b/reference/index.html @@ -48,7 +48,7 @@

All functionscarcassubmission -
British farm carcass submissions data
+
The British farm carcass submissions data
confint(<singleRStaticCountData>) @@ -90,7 +90,7 @@

All functionsfarmsubmission

-
British farm submissions data
+
The British farm submissions data
marginalFreq() @@ -102,7 +102,7 @@

All functionsnetherlandsimmigrant

-
Data on immigration in the Netherlands
+
Immigration data in the Netherlands
plot(<singleRStaticCountData>) @@ -150,7 +150,7 @@

All functionsstratifyPopsize()

-
Estimate size of sub populations.
+
Estimate size of sub-populations
summary(<singleRStaticCountData>) diff --git a/reference/netherlandsimmigrant.html b/reference/netherlandsimmigrant.html index d62f061..5203191 100644 --- a/reference/netherlandsimmigrant.html +++ b/reference/netherlandsimmigrant.html @@ -1,5 +1,5 @@ -Data on immigration in the Netherlands — netherlandsimmigrant • singleRcaptureImmigration data in the Netherlands — netherlandsimmigrant • singleRcapture
diff --git a/reference/stratifyPopsize.html b/reference/stratifyPopsize.html index aa30538..1e7a87e 100644 --- a/reference/stratifyPopsize.html +++ b/reference/stratifyPopsize.html @@ -1,5 +1,5 @@ -Estimate size of sub populations. — stratifyPopsize • singleRcaptureEstimate size of sub-populations — stratifyPopsize • singleRcapture Skip to contents @@ -31,7 +31,7 @@
diff --git a/search.json b/search.json index 60940c3..657454d 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://ncn-foreigners.github.io/singleRcapture/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2021 singleRcapture authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Population size estimation methodological approach employed across multiple scientific disciplines, serves basis research, policy formulation, decision-making processes (cf. Böhning, Bunge, Heijden 2018). field statistics, particularly official statistics, precise population estimates essential order develop robust economic models, optimize resource allocation, inform evidence-based policy (cf. Baffour, King, Valente 2013). Social scientists utilize advanced population estimation techniques investigate hard--reach populations, homeless individuals illicit drug users effort overcome inherent limitations conventional census methodologies. techniques crucial obtaining accurate data populations typically -represented difficult access using traditional sampling methods (cf. Vincent Thompson 2022). ecology epidemiology, researchers focus estimating size individual species disease-affected populations within defined geographical regions part conservation efforts, ecosystem management, public health interventions. Population size estimation can approached using various methodologies, distinct advantages limitations. Traditional approaches include full enumeration (e.g. censuses) comprehensive sample surveys, , providing detailed data, often resource-intensive may result delayed estimates, particularly human populations. Alternative methods leverage existing data sources, administrative registers carefully designed small-scale studies wildlife research, census coverage surveys (cf. Wolter 1986; Zhang 2019). Information sources often extracted applying statistical methods, known capture-recapture multiple system estimation, rely data multiple enumerations population (cf. Dunne Zhang 2024). approach can implemented using either single source repeated observations, two sources, multiple sources. paper focus methods involve single data source multiple enumerations units (cf. Heijden et al. 2003). human population studies, data can derived police records, health system databases, border control logs; case non-human populations, data kind can come veterinary records specialized field data. methods often applied estimate hard--reach hidden populations, standard sampling methods may inappropriate prohibitive costs problems identifying population members. methods two sources implemented various open-source software packages, instance CARE-4 (Yang Chao 2006) (GAUSS), Rcapture (Baillargeon Rivest 2007), marked (Laake et al. 2013) VGAM (Thomas W. Yee, Stoklosa, Huggins 2015) (R), single-source capture-recapture (SSCR) methods either available partially implemented existing R packages software. Therefore, paper attempts bridge gap introducing singleRcapture package, implement state---art SSCR methods offer user friendly API resembling existing R functions (e.g., glm). next subsection describe existing R packages software used estimating population size using SSCR methods.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-software","dir":"Articles","previous_headings":"Introduction","what":"Software for capture-recapture with a single source","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"majority SSCR methods assume zero-truncated distributions extensions (e.g., inclusion one-inflation). Distributions.jl (Besançon et al. 2021) (Julia), StatsModels (Seabold Perktold 2010) (Python), countreg (Zeileis, Kleiber, Jackman 2008), VGAM (T. Yee 2015) distributions3 (Hayes et al. 2024) (R) implement truncated distributions (e.g. distributions3::ZTPoisson countreg::zerotrunc) general distributions, Generally Altered, Inflated, Truncated Deflated, can found VGAM package (e.g. VGAM::gaitdpoisson Poisson distribution, see Thomas W. Yee Ma (2024) detailed description). However, estimation parameters given truncated (possibly inflated) distribution just first step (case log-linear models capture-recapture two sources) , best knowledge, open-source software can used estimate population size using SSCR methods includes variance estimators diagnostics. Therefore, purpose singleRcapture, R package, bridge gap providing scientists practitioners tool estimating population size SSCR methods. implemented state---art methods, recently described Böhning, Bunge, Heijden (2018) Böhning Friedl (2024) provided extensions (e.g., inclusion covariates, different treatment one-inflation), covered detail Section 2. package implements variance estimation based various methods, can used create custom models diagnostic plots (e.g. rootograms) parameters estimated using modified iteratively reweighted least squares (IRLS) algorithm implemented estimation stability. best knowledge, existing open-source package allows estimation population size selecting appropriate SSCR model, conducting estimation, providing informative diagnostics results. remaining part paper structured follows. Section 2 contains brief description theoretical background information fitting methods available methods variance estimation. Section 3 introduces main functions package. Section 4 presents case study contains assessment results, diagnostics estimates specific sub-populations. Section 5 describes classes S3methods implemented package. paper ends conclusions appendix showing use estimatePopsizeFit function aimed mimic glm.fit similar functions. replication materials show implement custom model option interest users wishing apply new bootstrap methods implemented package.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"how-to-estimate-population-size-with-a-single-source","dir":"Articles","previous_headings":"Theoretical background","what":"How to estimate population size with a single source?","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Let YkY_{k} represent number times kk-th unit observed single source (e.g. register). Clearly, observe k:Yk>0k:Y_{k}>0 know many units missed (.e. Yk=0Y_{k}=0), population size, denoted NN, needs estimated. general, assume conditional distribution YkY_{k} given vector covariates 𝐱k\\boldsymbol{x}_{k} follows version zero-truncated count data distribution (extensions). know parameters distribution can estimate population size using Horvitz-Thompson type estimator given : N̂=∑k=1NIkℙ[Yk>0|𝐗k]=∑k=1Nobs1ℙ[Yk>0|𝐗k], \\begin{equation} \\hat{N}= \\sum_{k=1}^{N}\\frac{I_{k}}{\\mathbb{P}[Y_{k}>0|\\boldsymbol{X}_{k}]}= \\sum_{k=1}^{N_{obs}}\\frac{1}{\\mathbb{P}[Y_{k}>0|\\boldsymbol{X}_{k}]}, \\end{equation} Ik:=ℐℕ(Yk)I_{k}:=\\mathcal{}_{\\mathbb{N}}(Y_{k}), NobsN_{obs} number observed units ℐ\\mathcal{} indicator function, maximum likelihood estimate NN obtained substituting regression parameters 𝛃\\boldsymbol{\\beta} ℙ[Yk>0|𝐱k]\\mathbb{P}[Y_{k}>0|\\boldsymbol{x}_{k}] equation. basic SSCR assumes independence counts, rather naive assumption, since first capture may significantly influence behavior given unit limit possibility subsequent captures (e.g. due incarceration). solve issues, Ryan T. Godwin Böhning (2017b) Ryan T. Godwin Böhning (2017a) introduced one-inflated distributions, explicitly model probability singletons giving additional mass ω\\omega singletons denoted ℐ{1}(y)\\mathcal{}_{\\{1\\}}(y)(cf. Böhning Friedl 2024). words considered new random varialbe Y*Y^{\\ast} corresponds data collection process exhibits one inflation: ℙ[Y*=y|Y*>0]=ωℐ{1}(y)+(1−ω)ℙ[Y=y|Y>0]. \\begin{equation*} \\mathbb{P}\\left[Y^{\\ast}=y|Y^{\\ast}>0\\right] = \\omega\\mathcal{}_{\\{1\\}}(y)+(1-\\omega)\\mathbb{P}[Y=y|Y>0]. \\end{equation*} Analytic variance estimation performed computing two parts decomposition according law total variance given : var[N̂]=𝔼[var[N̂|I1,…,]]+var[𝔼[N̂|I1,…,]], \\begin{equation}\\label{eq-law_of_total_variance_decomposition} \\text{var}[\\hat{N}] = \\mathbb{E}\\left[\\text{var} \\left[\\hat{N}|I_{1},\\dots,I_{n}\\right]\\right] + \\text{var}\\left[\\mathbb{E}[\\hat{N}|I_{1},\\dots,I_{n}]\\right], \\end{equation} first part can estimated using multivariate δ\\delta method given : 𝔼[var[N̂|I1,…,]]=(∂(N|I1,…,)∂𝛃)⊤cov[𝛃̂](∂(N|I1,…,)∂𝛃)|𝛃=𝛃̂, \\begin{equation*} \\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)^\\top \\text{cov}\\left[\\hat{\\boldsymbol{\\beta}}\\right] \\left(\\frac{\\partial(N|I_1,\\dots,I_N)}{\\partial\\boldsymbol{\\beta}}\\right) \\right|_{\\boldsymbol{\\beta}=\\hat{\\boldsymbol{\\beta}}}, \\end{equation*} second part decomposition , assuming independence IkI_{k}’s omitted simplifications, optimally estimated : var[𝔼(N̂|I1,…,)]=var[∑k=1NIkℙ(Yk>0)]≈∑k=1Nobs1−ℙ(Yk>0)ℙ(Yk>0)2, \\begin{equation*} \\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] \\approx\\sum_{k=1}^{N_{obs}}\\frac{1-\\mathbb{P}(Y_{k}>0)}{\\mathbb{P}(Y_{k}>0)^{2}}, \\end{equation*} serves basis interval estimation. Confidence intervals usually constructed assumption (asymptotic) normality N̂\\hat{N} asymptotic normality ln(N̂−N)\\ln(\\hat{N}-N) (log normality N̂\\hat{N}). latter attempt address common criticism student type confidence intervals SSCR, namely possibly skewed distribution N̂\\hat{N}, results 1−α1-\\alpha confidence interval given : (Nobs+N̂−Nobsξ,Nobs+(N̂−Nobs)ξ), \\begin{equation*} \\left(N_{obs}+\\frac{\\hat{N}-N_{obs}}{\\xi},N_{obs} + \\left(\\hat{N}-N_{obs}\\right)\\xi\\right), \\end{equation*} : ξ=exp(z(1−α2)ln(1+Var̂(N̂)(N̂−Nobs)2)), \\begin{equation*} \\xi = \\exp\\left(z\\left(1-\\frac{\\alpha}{2}\\right) \\sqrt{\\ln\\left(1+\\frac{\\widehat{\\text{Var}}(\\hat{N})}{\\left(\\hat{N}-N_{obs}\\right)^{2}}\\right)}\\right), \\end{equation*} zz quantile function standard normal distribution. estimator N̂\\hat{N} best interpreted estimator total number units population, since means estimating number units population probability included data 00(Heijden et al. 2003).","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"available-models","dir":"Articles","previous_headings":"Theoretical background","what":"Available models","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"full list models implemented singleRcapture along corresponding expressions probability density functions point estimates can found collective help file family functions: sake simplicity, list family functions together brief descriptions. detailed information, please consult relevant literature. current list family functions includes: Generalized Chao’s (Chao 1987) Zelterman’s (Zelterman 1988) estimators via logistic regression variable ZZ defined Z=1Z=1 Y=2Y=2 Z=0Z=0 Y=1Y=1 Z∼b(p)Z\\sim b(p) b(⋅)b(\\cdot) Bernoulli distribution pp can modeled unit kk logit(pk)=ln(λk/2)\\text{logit}(p_k)=\\ln(\\lambda_k/2) Poisson parameter λk=𝐱k𝛃\\lambda_k=\\boldsymbol{x}_{k}\\boldsymbol{\\beta} (covariate extension see Böhning et al. (2013) Böhning Heijden (2009)): N̂Chao=Nobs+∑k=1𝐟1+𝐟2(2exp(𝐱k𝛃̂)+2exp(2𝐱k𝛃̂))−1, \\hat{N}_{\\text{Chao}} = N_{obs}+ \\sum_{k=1}^{\\boldsymbol{f}_{1}+\\boldsymbol{f}_{2}} \\left(2\\exp\\left(\\boldsymbol{x}_{k}\\hat{\\boldsymbol{\\beta}}\\right)+ 2\\exp\\left(2\\boldsymbol{x}_{k}\\hat{\\boldsymbol{\\beta}}\\right)\\right)^{-1}, \\tag{Chao's estimator} N̂Zelt=∑k=1Nobs(1−exp(−2exp(𝐱k𝛃̂)))−1. \\hat{N}_{\\text{Zelt}}=\\sum_{k=1}^{N_{obs}} \\left(1-\\exp\\left(-2\\exp\\left(\\boldsymbol{x}_{k}\\hat{\\boldsymbol{\\beta}}\\right)\\right)\\right)^{-1}. \\tag{Zelterman's estimator} 𝐟1\\boldsymbol{f}_{1} 𝐟2\\boldsymbol{f}_{2} denotes number units observed twice. Zero-truncated (zt*^\\ast) zero-one-truncated (zot*^\\ast) Poisson (Böhning Heijden 2019), geometric, NB type II (NB2) regression, non-truncated distribution parameterized : ℙ[Y=y|λ,α]=Γ(y+α−1)Γ(α−1)y!(α−1α−1+λ)α−1(λλ+α−1)y. \\mathbb{P}[Y=y|\\lambda,\\alpha] = \\frac{\\Gamma\\left(y+\\alpha^{-1}\\right)}{\\Gamma\\left(\\alpha^{-1}\\right)y!} \\left(\\frac{\\alpha^{-1}}{\\alpha^{-1}+\\lambda}\\right)^{\\alpha^{-1}} \\left(\\frac{\\lambda}{\\lambda + \\alpha^{-1}}\\right)^{y}. Zero-truncated one-inflated (ztoi*^\\ast) modifications, count data variable Y*Y^{\\ast} defined distribution statisfies: ℙ[Y*=y]={ℙ[Y=0]y=0,ω(1−ℙ[Y=0])+(1−ω)ℙ[Y=1]y=1,(1−ω)ℙ[Y=y]y>1, \\mathbb{P}\\left[Y^{\\ast}=y\\right]= \\begin{cases} \\mathbb{P}[Y=0] & y=0, \\\\ \\omega\\left(1-\\mathbb{P}[Y=0]\\right)+(1-\\omega)\\mathbb{P}[Y=1] & y=1, \\\\ (1-\\omega)\\mathbb{P}[Y=y] & y>1, \\end{cases} ℙ[Y*=y|Y*>0]=ωℐ{1}(y)+(1−ω)ℙ[Y=y|Y>0]. \\mathbb{P}\\left[Y^{\\ast}=y|Y^{\\ast}>0\\right]=\\omega\\mathcal{}_{\\{1\\}}(y)+(1-\\omega)\\mathbb{P}[Y=y|Y>0]. One-inflated zero-truncated (oizt*^\\ast) modifications, count data variable Y*Y^{\\ast} defined : ℙ[Y*=y]=ωℐ{1}(y)+(1−ω)ℙ[Y=y], \\mathbb{P}\\left[Y^{\\ast}=y\\right] = \\omega \\mathcal{}_{\\{1\\}}(y)+(1-\\omega)\\mathbb{P}[Y=y], ℙ[Y*=y|Y*>0]=ωℐ{1}(y)1−(1−ω)ℙ[Y=0]+(1−ω)ℙ[Y=y]1−(1−ω)ℙ[Y=0]. \\mathbb{P}\\left[Y^{\\ast}=y|Y^{\\ast}>0\\right] = \\omega\\frac{\\mathcal{}_{\\{1\\}}(y)}{1-(1-\\omega)\\mathbb{P}[Y=0]}+ (1-\\omega)\\frac{\\mathbb{P}[Y=y]}{1-(1-\\omega)\\mathbb{P}[Y=0]}. Note ztoi*^\\ast oizt*^\\ast distributions equivalent, sense maximum value likelihood function equal distributions given data, shown (Böhning 2023) population size estimators different. addition, propose two new approaches model singletons similar way hurdle models. particular, proposed following: zero-truncated hurdle model (ztHurdle*) Poisson, geometric NB2 defined : ℙ[Y*=y]={ℙ[Y=0]1−ℙ[Y=1]y=0,π(1−ℙ[Y=1])y=1,(1−π)ℙ[Y=y]1−ℙ[Y=1]y>1, \\mathbb{P}[Y^{\\ast}=y]=\\begin{cases} \\frac{\\mathbb{P}[Y=0]}{1-\\mathbb{P}[Y=1]} & y=0, \\\\ \\pi(1-\\mathbb{P}[Y=1]) & y=1, \\\\ (1-\\pi) \\frac{\\mathbb{P}[Y=y]}{1-\\mathbb{P}[Y=1]} & y>1, \\end{cases} ℙ[Y*=y|Y*>0]=π𝟏{1}(y)+(1−π)𝟏ℕ\\{1}(y)ℙ[Y=y]1−ℙ[Y=0]−ℙ[Y=1]. \\mathbb{P}[Y^{\\ast}=y|Y^{\\ast}>0]=\\pi\\mathbf{1}_{\\{1\\}}(y)+ (1-\\pi)\\mathbf{1}_{\\mathbb{N}\\setminus\\{1\\}}(y)\\frac{\\mathbb{P}[Y=y]}{1-\\mathbb{P}[Y=0]-\\mathbb{P}[Y=1]}. π\\pi denotes conditional probability observing singletons. hurdle zero-truncated model (Hurdlezt*) Poisson, geometric NB2 defined : ℙ[Y*=y]={πy=1,(1−π)ℙ[Y=y]1−ℙ[Y=1]y≠1, \\mathbb{P}[Y^{\\ast}=y]=\\begin{cases} \\pi & y=1, \\\\ (1-\\pi) \\frac{\\mathbb{P}[Y=y]}{1-\\mathbb{P}[Y=1]} & y\\neq1, \\end{cases} ℙ[Y*=y|Y*>0]={π1−ℙ[Y=1]1−ℙ[Y=0]−ℙ[Y=1]y=1,(1−π)ℙ[Y=y]1−ℙ[Y=0]−ℙ[Y=1]y>1, \\mathbb{P}[Y^{\\ast}=y|Y^{\\ast}>0]=\\begin{cases} \\pi\\frac{1-\\mathbb{P}[Y=1]}{1-\\mathbb{P}[Y=0]-\\mathbb{P}[Y=1]} & y=1,\\\\ (1-\\pi)\\frac{\\mathbb{P}[Y=y]}{1-\\mathbb{P}[Y=0]-\\mathbb{P}[Y=1]} & y>1, \\end{cases} π\\pi denotes unconditional probability observing singletons. approaches presented differ assumptions, computational complexity, way treat heterogeneity captures singletons. instance, dispersion parameter α\\alpha NB2 type models often interpreted measuring severity unobserved heterogeneity underlying Poisson process (Cruyff Heijden 2008). using truncated NB model, hope given class models considered, consistency lost despite lack information. discussed literature, interpretation heterogeneous α\\alpha across population (specified controlModel) unobserved heterogeneity affects accuracy prediction dependent variable YY severely others. geometric model (NB α=1\\alpha=1) singled package often considered literature inherent computational issues NB models, exacerbated fact data used SSCR usually rather low quality. Data sparsity particularly common problem SSCR big challenge numerical methods fitting (zero-truncated) NB model. extra mass ω\\omega one-inflated models important extension researcher’s toolbox SSCR models, since inflation y=1y=1 likely occur many types applications. example, estimating number active people committed criminal acts given time period, fact captured first time following arrest associated risk longer able captured second time. One constraint present modelling via inflated models attempts include possibility one inflation one deflation lead numerical inferential problems since parameter space ((ω,λ)(\\omega, \\lambda) (ω,λ,α)(\\omega, \\lambda, \\alpha)) given {(ω,λ,α)|∀x∈ℕ:p(x|ω,λ,α)≥0}\\{(\\omega, \\lambda, \\alpha) | \\forall x\\\\mathbb{N}: p(x|\\omega, \\lambda, \\alpha)\\geq0\\} probability mass function pp. boundary set 11 2−2-dimentional manifold, transforming parameter space ℝ3\\mathbb{R}^{3} require using link functions depend one parameter. Hurdle models represent another approach modelling one-inflation. can also model deflation well inflation deflation simultaneously, flexible , case hurdle zero-truncated models, appear numerically stable. Although question interpret regression parameters tends somewhat overlooked SSCR studies, point interpretation ω\\omega inflation parameter (ztoi*^\\ast oizt*^\\ast) convenient interpretation π\\pi probability parameter (hurdle models). Additionally, interpretation λ\\lambda parameter (one) inflated models conforms following intuition: given unit kk comes non-inflated part population, follows Poisson distribution (respectively geometric negative binomial) λ\\lambda parameter (λ,α\\lambda,\\alpha); interpretation exists hurdle models. Interestingly, estimates hurdle zero-truncated one-inflated zero-truncated models tend quite close one another, although rigorous studies required confirm observation.","code":"?ztpoisson"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"fitting-method","dir":"Articles","previous_headings":"Theoretical background","what":"Fitting method","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"previously noted, singleRcapture package can used model (linear) dependence parameters covariates. modified IRLS algorithm employed purpose presented Algorithm 1; full details available T. Yee (2015). order apply algorithm, modified model matrix 𝐗vlm\\boldsymbol{X}_{\\text{vlm}} created estimatePopsize function called. context models implemented singleRcapture, matrix can written : 𝐗vlm=(𝐗1𝟎…𝟎𝟎𝐗2…𝟎⋮⋮⋱⋮𝟎𝟎…𝐗p) \\begin{equation}\\label{X_vlm-definition} \\boldsymbol{X}_{\\text{vlm}}= \\begin{pmatrix} \\boldsymbol{X}_{1} & \\boldsymbol{0} &\\dotso &\\boldsymbol{0}\\\\ \\boldsymbol{0} & \\boldsymbol{X}_{2} &\\dotso &\\boldsymbol{0}\\\\ \\vdots & \\vdots & \\ddots & \\vdots\\\\ \\boldsymbol{0} & \\boldsymbol{0} &\\dotso &\\boldsymbol{X}_{p} \\end{pmatrix} \\end{equation} 𝐗i\\boldsymbol{X}_{} corresponds model matrix associated user specified formula.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"algorithm-1-the-modified-irls-algorithm-used-in-the-singlercapture-package","dir":"Articles","previous_headings":"Theoretical background > Fitting method","what":"Algorithm 1: The modified IRLS algorithm used in the singleRcapture package","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Initialize iter ← 1, 𝛈\\boldsymbol{\\eta} ← start, 𝐖\\boldsymbol{W} ← , ℓ\\ell ← ℓ(𝛃)\\ell(\\boldsymbol{\\beta}) Store values previous step:ℓ−\\ell_{-} ← ℓ\\ell, 𝐖−\\boldsymbol{W}_{-} ← 𝐖\\boldsymbol{W}, 𝛃−\\boldsymbol{\\beta}_{-} ← 𝛃\\boldsymbol{\\beta} (last assignment omitted first iteration), assign values current iteration: 𝛈\\displaystyle\\boldsymbol{\\eta} ← 𝐗vlm𝛃+𝐨\\boldsymbol{X}_{\\text{vlm}}\\boldsymbol{\\beta}+\\boldsymbol{o} 𝐖(k)\\boldsymbol{W}_{(k)} ← 𝔼[−∂2ℓ∂𝛈(k)⊤∂𝛈(k)]\\mathbb{E}\\left[-\\frac{\\partial^{2}\\ell}{\\partial\\boldsymbol{\\eta}_{(k)}^\\top\\partial\\boldsymbol{\\eta}_{(k)}}\\right] 𝐙(k)\\boldsymbol{Z}_{(k)} ← 𝛈(k)+∂ℓ∂𝛈(k)𝐖(k)−1−𝐨(k)\\boldsymbol{\\eta}_{(k)}+\\frac{\\partial\\ell}{\\partial\\boldsymbol{\\eta}_{(k)}}\\boldsymbol{W}_{(k)}^{-1}-\\boldsymbol{o}_{(k)} 𝐨\\boldsymbol{o} denotes offset. Assign current coefficient value:𝛃\\boldsymbol{\\beta} ← (𝐗vlm𝐖𝐗vlm)−1𝐗vlm𝐖𝐙\\left(\\boldsymbol{X}_{\\text{vlm}}\\boldsymbol{W}\\boldsymbol{X}_{\\text{vlm}}\\right)^{-1}\\boldsymbol{X}_{\\text{vlm}}\\boldsymbol{W}\\boldsymbol{Z} ℓ(𝛃)<ℓ(𝛃−)\\ell(\\boldsymbol{\\beta})<\\ell(\\boldsymbol{\\beta}_{-}) try selecting smallest value hh 𝛃h\\boldsymbol{\\beta}_{h} ← 2−h(𝛃+𝛃−)2^{-h}\\left(\\boldsymbol{\\beta}+\\boldsymbol{\\beta}_{-}\\right) inequality ℓ(𝛃h)>ℓ(𝛃−)\\ell(\\boldsymbol{\\beta}_{h})>\\ell(\\boldsymbol{\\beta}_{-}) holds successful 𝛃\\boldsymbol{\\beta} ← 𝛃h\\boldsymbol{\\beta}_{h}, else stop algorithm. convergence achieved iter higher maxiter, stop algorithm, else iter ← 1 + iter return step 2. case multi-parameter families, get matrix linear predictors 𝛈\\boldsymbol{\\eta} instead vector, number columns matching number parameters distribution. “Weights” (matrix 𝐖\\boldsymbol{W}) modified information matrices 𝔼[−∂2ℓ∂𝛈(k)⊤∂𝛈(k)]\\displaystyle\\mathbb{E}\\left[-\\frac{\\partial^{2}\\ell}{\\partial\\boldsymbol{\\eta}_{(k)}^\\top\\partial\\boldsymbol{\\eta}_{(k)}}\\right], ℓ\\ell log-likelihood function 𝛈(k)\\boldsymbol{\\eta}_{(k)} kk-th row 𝛈\\boldsymbol{\\eta}, typical IRLS scalars 𝔼[−∂2ℓ∂ηk2]\\displaystyle\\mathbb{E}\\left[-\\frac{\\partial^{2}\\ell}{\\partial\\eta_{k}^{2}}\\right], often just −∂2ℓ∂η2\\displaystyle-\\frac{\\partial^{2}\\ell}{\\partial\\eta^{2}}.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-boostrap","dir":"Articles","previous_headings":"Theoretical background","what":"Bootstrap variance estimators","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"implemented three types bootstrap algorithms: parametric (adapted theory Zwane Van der Heijden (2003), Norris Pollock (1996) multiple source setting covariates), semi-parametric (see e.g. Böhning Friedl (2021)) nonparametric. nonparametric version usual bootstrap algorithm; typically underestimate variance N̂\\hat{N}. section, focus first two approaches. idea semi-parametric bootstrap modify usual bootstrap include additional uncertainty resulting fact sample size random variable. type bootstrap performed steps listed Algorithm 2.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"algorithm-2-semi-parametric-bootstrap","dir":"Articles","previous_headings":"Theoretical background > Bootstrap variance estimators","what":"Algorithm 2: Semi-parametric bootstrap","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Draw sample size Nobs′∼Binomial(N′,NobsN′)N_{obs}'\\sim\\text{Binomial}\\left(N', \\frac{N_{obs}}{N'}\\right), N′=⌊N̂⌋+Bernoulli(⌊N̂⌋−N̂)N'=\\lfloor\\hat{N}\\rfloor+\\text{Bernoulli}\\left(\\lfloor\\hat{N}\\rfloor-\\hat{N}\\right) Draw Nobs′N_{obs}' units data uniformly without replacement Obtain new population size estimate NbN_b using bootstrap data Repeat 1-3 steps BB times words, first draw sample size sample conditional sample size. Note using semi-parametric bootstrap one implicitly assumes population size estimate N̂\\hat{N} accurate. last implemented bootstrap type parametric algorithm, first draws finite population size ≈N̂\\approx\\hat{N} superpopulation model samples population according selected model, described Algorithm 3.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"algorithm-3-parametric-bootstrap","dir":"Articles","previous_headings":"Theoretical background > Bootstrap variance estimators","what":"Algorithm 3: Parametric bootstrap","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Draw number covariates equal ⌊N̂⌋+Bernoulli(⌊N̂⌋−N̂)\\lfloor\\hat{N}\\rfloor+\\text{Bernoulli}\\left(\\lfloor\\hat{N}\\rfloor-\\hat{N}\\right) proportional estimated contribution (ℙ[Yk>0|𝐱k])−1(\\mathbb{P}\\left[Y_{k}>0|\\boldsymbol{x}_{k}\\right])^{-1} replacement Using fitted model regression coefficients 𝛃̂\\hat{\\boldsymbol{\\beta}} draw covariate YY value corresponding probability measure ℕ∪{0}\\mathbb{N}\\cup\\{0\\} Truncate units drawn YY value equal 00 Obtain population size estimate NbN_b based truncated data Repeat 1-4 steps BB times Note order type algorithm result consistent standard error estimates, imperative estimated model entire superpopulation probability space consistent, may much less realistic case semi-parametric bootstrap. parametric bootstrap algorithm default option singleRcapture.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"the-estimatepopsize-function","dir":"Articles","previous_headings":"The main function","what":"The estimatePopsize function","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"singleRcapture package built around estimatePopsize function. main design objective make using estimatePopsize similar possible standard stats::glm function packages fitting zero-truncated regression models, countreg (e.g. countreg::zerotrunc function). estimatePopsize function used first fit appropriate (vector) generalized linear model estimate population size along variance. assumed response vector (.e. dependent variable) corresponds number times given unit observed source. important arguments given Table ; obligatory ones formula, data, model. important step using estimatePopsize specifying model parameter, indicates type model used estimating unobserved part population. instance, fit Chao’s Zelterman’s model one select chao zelterman , assuming one-inflation present, one can select one zero-truncated one-inflated (ztoi*^\\ast) one-inflated zero-truncated (oizt*^\\ast) models, oiztpoisson Poisson ztoinegbin NB2. assumed heterogeneity observed NB2 models, one can specify formula controlModel argument controlModel function alphaFormula argument. enables user provide formula dispersion parameter NB2 models. heterogeneity assumed ztoi*^\\ast oizt*^\\ast, one can specify omegaFormula argument, corresponds ω\\omega parameter models. Finally, covariates assumed available hurdle models (ztHurdle*^\\ast Hurdlezt*^\\ast), piFormula can specified, provides formula probability parameter models.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"controlling-variance-estimation-with-controlpopvar","dir":"Articles","previous_headings":"The main function","what":"Controlling variance estimation with controlPopVar","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"estimatePopsize function makes possible specify variance estimation method via popVar (e.g. analytic variance bootstrap) control estimation process specifying controlPopVar. control function controlPopVar user can specify bootType argument, three possible values: \"parametric\", \"semiparametric\" \"nonparametric\". Additional arguments accepted contorlPopVar function, relevant bootstrap, include: alpha, B – significance level number bootstrap samples performed, respectively, 0.050.05 500500 default options. cores – number process cores used bootstrap (1 default); parallel computing enabled doParallel (Microsoft Weston 2022a), foreach (Microsoft Weston 2022b) parallel packages (R Core Team 2023). keepbootStat – logical value indicating whether keep vector statistics produced bootstrap. traceBootstrapSize, bootstrapVisualTrace – logical values indicating whether sample population size tracked (FALSE default); work cores = 1. fittingMethod, bootstrapFitcontrol – fitting method (default one used original call) control parameters (controlMethod) model fitting bootstrap. addition, user can specify type confidence interval means confType type covariance matrix using covType analytical variance estimator (observed Fisher information matrix). next sections present case study involving use simple zero-truncated Poisson regression advanced model: one-inflated zero-truncated geometric regression cloglog link function. First, present example dataset, describe estimate population size assess quality diagnostics measures. Finally, show estimate population size user-specified sub-populations.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-study","dir":"Articles","previous_headings":"","what":"Data analysis example","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"package can installed standard manner using: , need load package using following code:","code":"install.packages(\"singleRcapture\") library(singleRcapture)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"dataset","dir":"Articles","previous_headings":"Data analysis example","what":"Dataset","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"use dataset Heijden et al. (2003), contains information immigrants four Dutch cities (Amsterdam, Rotterdam, Hague Utrecht), staying country without legal permit 1995 appeared police records year. dataset included package called netherlandsimmigrant: number times individual appeared records included capture variable. available covariates include gender, age, reason, nation; last two represent reason captured region world given person comes : One notable characteristic dataset contains disproportionately large number individuals observed (.e. 1645). basic syntax estimatePopsize similar glm, can said output summary method except additional results population size estimates (denoted Population size estimation results). output regarding population size contains point estimate, observed proportion (based input dataset), standard error two confidence intervals: one relating point estimate, second – observed proportion. According simple model, population size 12,500, 15% units observed register. 95% CI normality indicates true population size likely 7,000-18,000, 10-26% target population observed register. Since reasonable suspicion act observing unit dataset may lead undesirable consequences person concerned (case, possible deportation, detention something similar). reasons, user may consider one-inflated models, one-inflated zero-truncated geometric model (specified oiztgeom family) presented . According approach, population size 7,000, 5,000 less case naive Poisson approach. comparison AIC BIC suggests one-inflation model fits data better BIC oiztgeom 1727 1757 ztpoisson. can access population size estimates using following code, returns list numerical results. decision whether use zero-truncated Poisson one-inflated zero-truncated geometric model based assessment model assumptions regarding data generation process. One possible method selection based likelihood ratio test, can computed quickly conveniently lmtest (Zeileis Hothorn (2002)) interface: However, standard method model selection SSCR. next sections dedicated detailed description assess results using standard statistical tests diagnostics.","code":"data(netherlandsimmigrant) head(netherlandsimmigrant) ## capture gender age reason nation ## 1 1 male <40yrs Other reason North Africa ## 2 1 male <40yrs Other reason North Africa ## 3 1 male <40yrs Other reason North Africa ## 4 1 male <40yrs Other reason Asia ## 5 1 male <40yrs Other reason Asia ## 6 2 male <40yrs Other reason North Africa summary(netherlandsimmigrant) ## capture gender age reason ## Min. :1.000 female: 398 <40yrs:1769 Illegal stay: 259 ## 1st Qu.:1.000 male :1482 >40yrs: 111 Other reason:1621 ## Median :1.000 ## Mean :1.162 ## 3rd Qu.:1.000 ## Max. :6.000 ## nation ## American and Australia: 173 ## Asia : 284 ## North Africa :1023 ## Rest of Africa : 243 ## Surinam : 64 ## Turkey : 93 table(netherlandsimmigrant$capture) ## ## 1 2 3 4 5 6 ## 1645 183 37 13 1 1 basicModel <- estimatePopsize( formula = capture ~ gender + age + nation, model = ztpoisson(), data = netherlandsimmigrant, controlMethod = controlMethod(silent = TRUE) ) summary(basicModel) ## ## Call: ## estimatePopsize.default(formula = capture ~ gender + age + nation, ## data = netherlandsimmigrant, model = ztpoisson(), controlMethod = controlMethod(silent = TRUE)) ## ## Pearson Residuals: ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -0.486442 -0.486442 -0.298080 0.002093 -0.209444 13.910844 ## ## Coefficients: ## ----------------------- ## For linear predictors associated with: lambda ## Estimate Std. Error z value P(>|z|) ## (Intercept) -1.3411 0.2149 -6.241 4.35e-10 *** ## gendermale 0.3972 0.1630 2.436 0.014832 * ## age>40yrs -0.9746 0.4082 -2.387 0.016972 * ## nationAsia -1.0926 0.3016 -3.622 0.000292 *** ## nationNorth Africa 0.1900 0.1940 0.979 0.327398 ## nationRest of Africa -0.9106 0.3008 -3.027 0.002468 ** ## nationSurinam -2.3364 1.0136 -2.305 0.021159 * ## nationTurkey -1.6754 0.6028 -2.779 0.005445 ** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## AIC: 1712.901 ## BIC: 1757.213 ## Residual deviance: 1128.553 ## ## Log-likelihood: -848.4504 on 1872 Degrees of freedom ## Number of iterations: 8 ## ----------------------- ## Population size estimation results: ## Point estimate 12690.35 ## Observed proportion: 14.8% (N obs = 1880) ## Std. Error 2808.169 ## 95% CI for the population size: ## lowerBound upperBound ## normal 7186.444 18194.26 ## logNormal 8431.275 19718.32 ## 95% CI for the share of observed population: ## lowerBound upperBound ## normal 10.332927 26.16037 ## logNormal 9.534281 22.29793 set.seed(123456) modelInflated <- estimatePopsize( formula = capture ~ nation, model = oiztgeom(omegaLink = \"cloglog\"), data = netherlandsimmigrant, controlModel = controlModel( omegaFormula = ~ gender + age ), popVar = \"bootstrap\", controlPopVar = controlPopVar(bootType = \"semiparametric\", B = 50) ) summary(modelInflated) ## ## Call: ## estimatePopsize.default(formula = capture ~ nation, data = netherlandsimmigrant, ## model = oiztgeom(omegaLink = \"cloglog\"), popVar = \"bootstrap\", ## controlModel = controlModel(omegaFormula = ~gender + age), ## controlPopVar = controlPopVar(bootType = \"semiparametric\", ## B = 50)) ## ## Pearson Residuals: ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -0.41643 -0.41643 -0.30127 0.00314 -0.18323 13.88376 ## ## Coefficients: ## ----------------------- ## For linear predictors associated with: lambda ## Estimate Std. Error z value P(>|z|) ## (Intercept) -1.2552 0.2149 -5.840 5.22e-09 *** ## nationAsia -0.8193 0.2544 -3.220 0.00128 ** ## nationNorth Africa 0.2057 0.1838 1.119 0.26309 ## nationRest of Africa -0.6692 0.2548 -2.627 0.00862 ** ## nationSurinam -1.5205 0.6271 -2.425 0.01532 * ## nationTurkey -1.1888 0.4343 -2.737 0.00619 ** ## ----------------------- ## For linear predictors associated with: omega ## Estimate Std. Error z value P(>|z|) ## (Intercept) -1.4577 0.3884 -3.753 0.000175 *** ## gendermale -0.8738 0.3602 -2.426 0.015267 * ## age>40yrs 1.1745 0.5423 2.166 0.030326 * ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## AIC: 1677.125 ## BIC: 1726.976 ## Residual deviance: 941.5416 ## ## Log-likelihood: -829.5625 on 3751 Degrees of freedom ## Number of iterations: 10 ## ----------------------- ## Population size estimation results: ## Point estimate 6699.953 ## Observed proportion: 28.1% (N obs = 1880) ## Boostrap sample skewness: 0.5209689 ## 0 skewness is expected for normally distributed variable ## --- ## Bootstrap Std. Error 1579.235 ## 95% CI for the population size: ## lowerBound upperBound ## 5107.533 10738.242 ## 95% CI for the share of observed population: ## lowerBound upperBound ## 17.50752 36.80838 popSizeEst(basicModel) # alternative: basicModel$populationSize ## Point estimate: 12690.35 ## Variance: 7885812 ## 95% confidence intervals: ## lowerBound upperBound ## normal 7186.444 18194.26 ## logNormal 8431.275 19718.32 popSizeEst(modelInflated) # alternative: modelInflated$populationSize ## Point estimate: 6699.953 ## Variance: 2493985 ## 95% confidence intervals: ## lowerBound upperBound ## 5107.533 10738.242 library(lmtest) lrtest(basicModel, modelInflated, name = function(x) { if (family(x)$family == \"ztpoisson\") \"Basic model\" else \"Inflated model\" }) ## Likelihood ratio test ## ## Model 1: Basic model ## Model 2: Inflated model ## #Df LogLik Df Chisq Pr(>Chisq) ## 1 8 -848.45 ## 2 9 -829.56 1 37.776 7.936e-10 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"testing-marginal-frequencies","dir":"Articles","previous_headings":"Data analysis example","what":"Testing marginal frequencies","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"popular method testing model fit single source capture-recapture studies consists comparing fitted marginal frequencies ∑j=1Nobsℙ̂[Yj=k|𝐱j,Yj>0]\\displaystyle\\sum_{j=1}^{N_{obs}}\\hat{\\mathbb{P}}\\left[Y_{j}=k|\\boldsymbol{x}_{j}, Y_{j} > 0\\right] observed marginal frequencies ∑j=1Nℐ{k}(Yj)=∑j=1Nobsℐ{k}(Yj)\\displaystyle\\sum_{j=1}^{N}\\mathcal{}_{\\{k\\}}(Y_{j})=\\sum_{j=1}^{N_{obs}}\\mathcal{}_{\\{k\\}}(Y_{j}) k≥1k\\geq1. fitted model bears sufficient resemblance real data collection process, quantities quite close GG χ2\\chi^{2} tests can used test statistical significance discrepancy following singleRcapture syntax Poisson model (rather poor fit): one-inflated model (better fit): dropl5 argument used indicate handle cells less 55 fitted observations. Note, however, currently continuity correction.","code":"margFreq <- marginalFreq(basicModel) summary(margFreq, df = 1, dropl5 = \"group\") ## Test for Goodness of fit of a regression model: ## ## Test statistics df P(>X^2) ## Chi-squared test 50.06 1 1.5e-12 ## G-test 34.31 1 4.7e-09 ## ## -------------------------------------------------------------- ## Cells with fitted frequencies of < 5 have been grouped ## Names of cells used in calculating test(s) statistic: 1 2 3 margFreq_inf <- marginalFreq(modelInflated) summary(margFreq_inf, df = 1, dropl5 = \"group\") ## Test for Goodness of fit of a regression model: ## ## Test statistics df P(>X^2) ## Chi-squared test 1.88 1 0.17 ## G-test 2.32 1 0.13 ## ## -------------------------------------------------------------- ## Cells with fitted frequencies of < 5 have been grouped ## Names of cells used in calculating test(s) statistic: 1 2 3 4"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"diagnostics","dir":"Articles","previous_headings":"Data analysis example","what":"Diagnostics","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"singleRStaticCountData class plot method implementing several types quick demonstrative plots, rootogram (Kleiber Zeileis 2016), comparing fitted marginal frequencies, can generated following syntax: Rootograms ztpoisson (left) oiztgeom (right) models plots suggest oiztgeom model fits data better. Another important issue population size estimation conduct model diagnostics order verify whether influential observations present data. purpose leave-one-(LOO) diagnostic implemented dfbeta stats package adapted shown (multiplied factor hundred better readability): result dfbeta can used dfpopsize function, can used quantify LOO population size. Note warning bootstap variance estimation applied. Figure 2 shows comparison effect deleting observation population size estimate inverse probability weights, refer contribution given observation population size estimate: Results ztpoisson (left) oiztgeom (right) model plots show population size changes given observation removed. instance, remove observation 542, population size increase 4236 ztpoisson model. case oiztgeom, largest change equal 457 observation 900. full list plot types along list optional arguments can passed call plot method base R graphics functions can found help file plot method.","code":"plot( basicModel, plotType = \"rootogram\", main = \"ZT Poisson model\") plot(modelInflated, plotType = \"rootogram\", main = \"OI ZT Geometric model\") dfb <- dfbeta(basicModel) round(t(apply(dfb, 2, quantile)*100), 4) ## 0% 25% 50% 75% 100% ## (Intercept) -0.9909 -0.1533 0.0191 0.0521 8.6619 ## gendermale -9.0535 -0.0777 -0.0283 0.1017 2.2135 ## age>40yrs -2.0010 0.0179 0.0379 0.0691 16.0061 ## nationAsia -9.5559 -0.0529 0.0066 0.0120 17.9914 ## nationNorth Africa -9.6605 -0.0842 -0.0177 0.0087 3.1260 ## nationRest of Africa -9.4497 -0.0244 0.0030 0.0083 10.9787 ## nationSurinam -9.3140 -0.0066 0.0020 0.0035 99.3383 ## nationTurkey -9.6198 -0.0220 0.0079 0.0143 32.0980 dfi <- dfbeta(modelInflated) round(t(apply(dfi, 2, quantile)*100), 4) ## 0% 25% 50% 75% 100% ## (Intercept) -1.4640 0.0050 0.0184 0.0557 9.0600 ## nationAsia -6.6331 -0.0346 0.0157 0.0347 12.2406 ## nationNorth Africa -7.2770 -0.0768 -0.0170 0.0085 1.9415 ## nationRest of Africa -6.6568 -0.0230 0.0081 0.0262 7.1710 ## nationSurinam -6.2308 -0.0124 0.0162 0.0421 62.2045 ## nationTurkey -6.4795 -0.0273 0.0204 0.0462 21.1338 ## (Intercept):omega -6.8668 -0.0193 0.0476 0.0476 9.3389 ## gendermale:omega -2.2733 -0.2227 0.1313 0.2482 11.1234 ## age>40yrs:omega -30.2130 -0.2247 -0.1312 -0.0663 2.0393 dfb_pop <- dfpopsize(basicModel, dfbeta = dfb) dfi_pop <- dfpopsize(modelInflated, dfbeta = dfi) summary(dfb_pop) ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -4236.412 2.664 2.664 5.448 17.284 117.448 summary(dfi_pop) ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -456.6443 -3.1121 -0.7243 3.4333 5.1535 103.5949 plot(basicModel, plotType = \"dfpopContr\", dfpop = dfb_pop, xlim = c(-4500, 150)) plot(modelInflated, plotType = \"dfpopContr\", dfpop = dfi_pop, xlim = c(-4500, 150)) ?plot.singleRStaticCountData"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"the-stratifypopsize-function","dir":"Articles","previous_headings":"Data analysis example","what":"The stratifyPopsize function","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Researchers may interested total population size also size specific sub-populations (e.g. males, females, particular age groups). reason created stratifyPopsize function, estimates size strata defined coefficients model (default option). following output presents results based ztpoisson oiztgeom models. stratifyPopsize function prepared handle objects singleRStaticCountData class, accepts three optional parameters strata, alpha, cov, used specifying sub-populations, significance levels covariance matrix used computing standard errors. example full call presented . provided integration sandwich (Zeileis, Köll, Graham 2020) package correct variance-covariance matrix δ\\delta method. code used vcovHC method singleRStaticCountData class sandwich package, different significance levels confidence intervals stratum formula specify want estimates males females grouped nation age. strata parameter can specified either : formula empty left hand side, shown example (e.g. ~ gender * age), logical vector number entries equal number rows dataset, case one stratum created (e.g. netherlandsimmigrant$gender == \"male\"), vector names explanatory variables, result every level explanatory variable sub-population variable specified (e.g. c(\"gender\", \"age\")), supplied , case strata correspond levels factor data without interactions (string vectors converted factors convenience user), (named) list element logical vector; names list used specify variable names returned object, example: One can also specify plotType = \"strata\" plot function, results plot point CI estimates population size. Population size covariates ztpoisson (left) oiztgeom (right) model logNormal type confidence interval used plotting since studentized confidence intervals often result negative lower bounds.","code":"popSizestrata <- stratifyPopsize(basicModel) cols <- c(\"name\", \"Observed\", \"Estimated\", \"logNormalLowerBound\", \"logNormalUpperBound\") popSizestrata_report <- popSizestrata[, cols] cols_custom <- c(\"Name\", \"Obs\", \"Estimated\", \"LowerBound\", \"UpperBound\") names(popSizestrata_report) <- cols_custom popSizestrata_report ## Name Obs Estimated LowerBound UpperBound ## 1 gender==female 398 3811.0924 2189.0439 6902.140 ## 2 gender==male 1482 8879.2613 6090.7752 13354.889 ## 3 age==<40yrs 1769 10506.8994 7359.4140 15426.465 ## 4 age==>40yrs 111 2183.4543 872.0130 5754.881 ## 5 nation==American and Australia 173 708.3688 504.6086 1037.331 ## 6 nation==Asia 284 2742.3147 1755.2548 4391.590 ## 7 nation==North Africa 1023 3055.2033 2697.4900 3489.333 ## 8 nation==Rest of Africa 243 2058.1533 1318.7466 3305.786 ## 9 nation==Surinam 64 2386.4544 505.2460 12288.008 ## 10 nation==Turkey 93 1739.8592 638.0497 5068.959 popSizestrata_inflated <- stratifyPopsize(modelInflated) popSizestrata_inflated_report <- popSizestrata_inflated[, cols] names(popSizestrata_inflated_report) <- cols_custom popSizestrata_inflated_report ## Name Obs Estimated LowerBound UpperBound ## 1 nation==American and Australia 173 516.2432 370.8463 768.4919 ## 2 nation==Asia 284 1323.5377 831.1601 2258.9954 ## 3 nation==North Africa 1023 2975.8801 2254.7071 4119.3050 ## 4 nation==Rest of Africa 243 1033.9753 667.6106 1716.4484 ## 5 nation==Surinam 64 354.2236 193.8891 712.4739 ## 6 nation==Turkey 93 496.0934 283.1444 947.5309 ## 7 gender==female 398 1109.7768 778.7197 1728.7066 ## 8 gender==male 1482 5590.1764 3838.4550 8644.0776 ## 9 age==<40yrs 1769 6437.8154 4462.3472 9862.2147 ## 10 age==>40yrs 111 262.1379 170.9490 492.0347 library(sandwich) popSizestrataCustom <- stratifyPopsize( object = basicModel, strata = ~ gender + age, alpha = rep(c(0.1, 0.05), each=2), cov = vcovHC(basicModel, type = \"HC4\") ) popSizestrataCustom_report <- popSizestrataCustom[, c(cols, \"confLevel\")] names(popSizestrataCustom_report) <- c(cols_custom, \"alpha\") popSizestrataCustom_report ## Name Obs Estimated LowerBound UpperBound alpha ## 1 gender==female 398 3811.092 2275.6410 6602.168 0.10 ## 2 gender==male 1482 8879.261 6261.5109 12930.760 0.10 ## 3 age==<40yrs 1769 10506.899 7297.2057 15580.151 0.05 ## 4 age==>40yrs 111 2183.454 787.0673 6464.016 0.05 list( \"Stratum 1\" = netherlandsimmigrant$gender == \"male\" & netherlandsimmigrant$nation == \"Suriname\", \"Stratum 2\" = netherlandsimmigrant$gender == \"female\" & netherlandsimmigrant$nation == \"North Africa\" ) plot(basicModel, plotType = \"strata\") plot(modelInflated, plotType = \"strata\")"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-methods","dir":"Articles","previous_headings":"","what":"Classes and S3Methods","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"created number classes. main ones : singleRStaticCountData, singleRfamily, supplementary : popSizeEstResults, summarysingleRmargin summarysingleRStaticCountData, make possible extract relevant information regarding population size. instance, popSizeEst function can used extract information estimated size population given : resulting object popEst popSizeEstResults class contains following fields: pointEstimate, variance – numerics containing point estimate variance estimate. confidenceInterval – data.frame confidence intervals. boot – bootstrap performed numeric vector containing N̂\\hat{N} values bootstrap, character vector value \"bootstrap performed\" otherwise. control – controlPopVar object controls used obtain object. explicitly defined method popSizeEstResults, summarysingleRmargin summarysingleRStaticCountData classes print method, former one also accepts R primitives like coef: analogously glm stats. singleRfamily inherits family class stats explicitly defined print simulate methods. Example usage presented full list explicitly defined methods singleRStaticCountData methods presented Table .","code":"(popEst <- popSizeEst(basicModel)) ## Point estimate: 12690.35 ## Variance: 7885812 ## 95% confidence intervals: ## lowerBound upperBound ## normal 7186.444 18194.26 ## logNormal 8431.275 19718.32 coef(summary(basicModel)) ## Estimate Std. Error z value P(>|z|) ## (Intercept) -1.3410661 0.2148870 -6.2407965 4.353484e-10 ## gendermale 0.3971793 0.1630155 2.4364504 1.483220e-02 ## age>40yrs -0.9746058 0.4082420 -2.3873235 1.697155e-02 ## nationAsia -1.0925990 0.3016259 -3.6223642 2.919228e-04 ## nationNorth Africa 0.1899980 0.1940007 0.9793677 3.273983e-01 ## nationRest of Africa -0.9106361 0.3008092 -3.0272880 2.467587e-03 ## nationSurinam -2.3363962 1.0135645 -2.3051282 2.115939e-02 ## nationTurkey -1.6753917 0.6027744 -2.7794674 5.444812e-03 set.seed(1234567890) N <- 10000 gender <- rbinom(N, 1, 0.2) eta <- -1 + 0.5*gender counts <- simulate(ztpoisson(), eta = cbind(eta), seed = 1) summary(data.frame(gender, eta, counts)) ## gender eta counts ## Min. :0.0000 Min. :-1.0000 Min. :0.0000 ## 1st Qu.:0.0000 1st Qu.:-1.0000 1st Qu.:0.0000 ## Median :0.0000 Median :-1.0000 Median :0.0000 ## Mean :0.2036 Mean :-0.8982 Mean :0.4196 ## 3rd Qu.:0.0000 3rd Qu.:-1.0000 3rd Qu.:1.0000 ## Max. :1.0000 Max. :-0.5000 Max. :5.0000"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"concluding-remarks","dir":"Articles","previous_headings":"","what":"Concluding remarks","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"paper introduced singleRcapture package single source capture-recapture models. package implement state---art methods estimating population size based single data set multiple counts. package implements different methods account heterogeneity capture probabilities, modelled using covariates, well behavioural change, modelled using one-inflation. built package facilitate implementation new models using family objects; application exemplified Section 7. example implementing custom family described Section 8 presented replication materials. Furthermore, since many R users familiar countreg VGAM packages, implemented lightweight extension called singleRcaptureExtra, available Github (), can used integrate singleRcapture packages. future work plan implement Bayesian estimation using Stan (e.g. via brms package; Carpenter et al. (2017), Bürkner (2017)) one-inflation models can use recent approach proposed Tuoto, Di Cecco, Tancredi (2022) implement families using brms package.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"Acknowledgements","dir":"Articles","previous_headings":"","what":"Acknowledgements","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"authors’ work financed National Science Centre Poland, OPUS 20, grant . 2020/39/B/HS4/00941. authors like thank Peter van der Heijden, Maarten Cruyff, Dankmar Böhning, Łukasz Chrostowski Layna Dennett useful comments helped improve functionality package. addition, like thank Marcin Szymkowiak Tymon Świtalski valuable comments considerably improved paper.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-estimatePopsizeFit","dir":"Articles","previous_headings":"Detailed information","what":"The estimatePopsizeFit function","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"section provide step--step description prepare data order use estimatePopsizeFit function, may useful users, e.g. wishing make modifications N̂\\hat{N} estimate bootstrap. order show apply function fit zero truncated geometric model data Böhning et al. (2013) covariate dependency: log(λ)=β1,1+β1,2log_distance+β1,3C_TYPE+β1,4log_size,logit(ω)=β2,1+β2,2log_distance+β2,3C_TYPE.\\begin{align*} \\log(\\lambda) &= \\beta_{1, 1} + \\beta_{1, 2} \\text{log\\_distance} + \\beta_{1, 3} \\text{C\\_TYPE} + \\beta_{1, 4} \\text{log\\_size}, \\\\ \\text{logit}(\\omega) &= \\beta_{2, 1} + \\beta_{2, 2} \\text{log\\_distance} + \\beta_{2, 3} \\text{C\\_TYPE}. \\end{align*} equivalent following esimatePopsize call: Create data matrix 𝐗vlm\\boldsymbol{X}_{\\text{vlm}} Fill first nn rows model.matrix according specified formula specify attribute attr(X, \"hwm\") informs function elements design matrix correspond linear predictor (covariates counts covariates one-inflation) Obtain starting 𝛃\\boldsymbol{\\beta} parameters using glm.fit function. Use estimatePopsizeFit function fit model assuming zero-truncated one-inflated geometric distribution specified family argument. Compare results obtained applying stats::optim function. default maxiter parameter \"optim\" fitting 10001000, needed increase since optim converge 10001000 steps “gets stuck” plateau, results lower log-likelihood value compared standard \"IRLS\". situation rather typical. conduct formal numerical analyses, seems one attempts model one parameter distribution covariate dependent optim algorithms, \"Nelder-Mead\" \"L-BFGS-B\" seem ill-suited task despite provided analytically computed gradient. one reasons \"IRLS\" default fitting method.","code":"estimatePopsize( TOTAL_SUB ~ ., data = farmsubmission, model = ztoigeom(), controlModel( omegaFormula = ~ 1 + log_size + C_TYPE ) ) X <- matrix(data = 0, nrow = 2 * NROW(farmsubmission), ncol = 7) X[1:NROW(farmsubmission), 1:4] <- model.matrix( ~ 1 + log_size + log_distance + C_TYPE, farmsubmission ) X[-(1:NROW(farmsubmission)), 5:7] <- model.matrix( ~ 1 + log_distance + C_TYPE, farmsubmission ) attr(X, \"hwm\") <- c(4, 3) start <- glm.fit( y = farmsubmission$TOTAL_SUB, x = X[1:NROW(farmsubmission), 1:4], family = poisson() )$coefficients start ## [1] -0.82583943 0.33254499 -0.03277732 0.32746933 res <- estimatePopsizeFit( y = farmsubmission$TOTAL_SUB, X = X, method = \"IRLS\", priorWeights = 1, family = ztoigeom(), control = controlMethod(silent = TRUE), coefStart = c(start, 0, 0, 0), etaStart = matrix(X %*% c(start, 0, 0, 0), ncol = 2), offset = cbind(rep(0, NROW(farmsubmission)), rep(0, NROW(farmsubmission))) ) ll <- ztoigeom()$makeMinusLogLike(y = farmsubmission$TOTAL_SUB, X = X) res2 <- estimatePopsizeFit( y = farmsubmission$TOTAL_SUB, X = X, method = \"optim\", priorWeights = 1, family = ztoigeom(), coefStart = c(start, 0, 0, 0), control = controlMethod(silent = TRUE, maxiter = 10000), offset = cbind(rep(0, NROW(farmsubmission)), rep(0, NROW(farmsubmission))) ) data.frame(IRLS = round(c(res$beta, -ll(res$beta), res$iter), 4), optim = round(c(res2$beta, -ll(res2$beta), res2$iter[1]), 4)) ## IRLS optim ## 1 -2.7845 -2.5971 ## 2 0.6170 0.6163 ## 3 -0.0646 -0.0825 ## 4 0.5346 0.5431 ## 5 -3.1745 -0.1504 ## 6 0.1281 -0.1586 ## 7 -1.0865 -1.0372 ## 8 -17278.7613 -17280.1189 ## 9 15.0000 1696.0000"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-family","dir":"Articles","previous_headings":"Detailed information","what":"Structure of a family function","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"section provide details regarding family object singleRcapture package. object contains additional parameters comparison standard family object stats package.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-custom","dir":"Articles","previous_headings":"","what":"Implementing a custom singleRcapture family function","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Suppose want implement specific zero truncated family function singleRcapture, corresponds following “untruncated” distribution: ℙ[Y=y|λ,π]={1−12λ−12πwhen: y=012πwhen: y=112λwhen: y=2, \\mathbb{P}[Y=y|\\lambda, \\pi] = \\begin{cases} 1 - \\frac{1}{2}\\lambda - \\frac{1}{2}\\pi & \\text{: } y=0\\\\ \\frac{1}{2}\\pi & \\text{: } y=1\\\\ \\frac{1}{2}\\lambda & \\text{: } y=2, \\end{cases} λ,π∈(0,1)\\lambda, \\pi\\\\left(0, 1\\right) dependent covariates. provide possible way implementing model, lambda, pi meaning 12λ,12π\\frac{1}{2}\\lambda,\\frac{1}{2}\\pi. provide simple example shows proposed approach works expected. quick tests shows us implementation fact works: link functions, singleRcapture:::singleRinternalcloglogLink, just internal functions singleRcapture compute link functions, inverses derivatives links inverse links third order: One , course, include code computing manually.","code":"myFamilyFunction <- function(lambdaLink = c(\"logit\", \"cloglog\", \"probit\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ...) { if (missing(lambdaLink)) lambdaLink <- \"logit\" if (missing(piLink)) piLink <- \"logit\" links <- list() attr(links, \"linkNames\") <- c(lambdaLink, piLink) lambdaLink <- switch(lambdaLink, \"logit\" = singleRcapture:::singleRinternallogitLink, \"cloglog\" = singleRcapture:::singleRinternalcloglogLink, \"probit\" = singleRcapture:::singleRinternalprobitLink ) piLink <- switch(piLink, \"logit\" = singleRcapture:::singleRinternallogitLink, \"cloglog\" = singleRcapture:::singleRinternalcloglogLink, \"probit\" = singleRcapture:::singleRinternalprobitLink ) links[1:2] <- c(lambdaLink, piLink) mu.eta <- function(eta, type = \"trunc\", deriv = FALSE, ...) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 if (!deriv) { switch (type, \"nontrunc\" = pi + 2 * lambda, \"trunc\" = 1 + lambda / (pi + lambda) ) } else { # Only necessary if one wishes to use standard errors in predict method switch (type, \"nontrunc\" = { matrix(c(2, 1) * c( lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2, piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2 ), ncol = 2) }, \"trunc\" = { matrix(c( pi / (pi + lambda) ^ 2, -lambda / (pi + lambda) ^ 2 ) * c( lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2, piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2 ), ncol = 2) } ) } } variance <- function(eta, type = \"nontrunc\", ...) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 switch (type, \"nontrunc\" = pi * (1 - pi) + 4 * lambda * (1 - lambda - pi), \"trunc\" = lambda * (1 - lambda) / (pi + lambda) ) } Wfun <- function(prior, y, eta, ...) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 G01 <- ((lambda + pi) ^ (-2)) * piLink(eta[, 2], inverse = TRUE, deriv = 1) * lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) * prior / 4 G00 <- ((lambda + pi) ^ (-2)) - (pi ^ (-2)) - lambda / ((lambda + pi) * (pi ^ 2)) G00 <- G00 * prior * (piLink(eta[, 2], inverse = TRUE, deriv = 1) ^ 2) / 4 G11 <- ((lambda + pi) ^ (-2)) - (((lambda + pi) * lambda) ^ -1) G11 <- G11 * prior * (lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) ^ 2) / 4 matrix( -c(G11, # lambda G01, # mixed G01, # mixed G00 # pi ), dimnames = list(rownames(eta), c(\"lambda\", \"mixed\", \"mixed\", \"pi\")), ncol = 4 ) } funcZ <- function(eta, weight, y, prior, ...) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 weight <- weight / prior G0 <- (2 - y) / pi - ((lambda + pi) ^ -1) G1 <- (y - 1) / lambda - ((lambda + pi) ^ -1) G1 <- G1 * lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2 G0 <- G0 * piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2 uMatrix <- matrix(c(G1, G0), ncol = 2) weight <- lapply(X = 1:nrow(weight), FUN = function (x) { matrix(as.numeric(weight[x, ]), ncol = 2) }) pseudoResid <- sapply(X = 1:length(weight), FUN = function (x) { #xx <- chol2inv(chol(weight[[x]])) # less computationally demanding xx <- solve(weight[[x]]) # more stable xx %*% uMatrix[x, ] }) pseudoResid <- t(pseudoResid) dimnames(pseudoResid) <- dimnames(eta) pseudoResid } minusLogLike <- function(y, X, offset, weight = 1, NbyK = FALSE, vectorDer = FALSE, deriv = 0, ...) { y <- as.numeric(y) if (is.null(weight)) { weight <- 1 } if (missing(offset)) { offset <- cbind(rep(0, NROW(X) / 2), rep(0, NROW(X) / 2)) } if (!(deriv %in% c(0, 1, 2))) stop(\"Only score function and derivatives up to 2 are supported.\") deriv <- deriv + 1 switch (deriv, function(beta) { eta <- matrix(as.matrix(X) %*% beta, ncol = 2) + offset pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 -sum(weight * ((2 - y) * log(pi) + (y - 1) * log(lambda) - log(pi + lambda))) }, function(beta) { eta <- matrix(as.matrix(X) %*% beta, ncol = 2) + offset pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 G0 <- (2 - y) / pi - ((lambda + pi) ^ -1) G1 <- (y - 1) / lambda - ((lambda + pi) ^ -1) G1 <- G1 * weight * lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2 G0 <- G0 * weight * piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2 if (NbyK) { XX <- 1:(attr(X, \"hwm\")[1]) return(cbind(as.data.frame(X[1:nrow(eta), XX]) * G1, as.data.frame(X[-(1:nrow(eta)), -XX]) * G0)) } if (vectorDer) { return(cbind(G1, G0)) } as.numeric(c(G1, G0) %*% X) }, function (beta) { lambdaPredNumber <- attr(X, \"hwm\")[1] eta <- matrix(as.matrix(X) %*% beta, ncol = 2) + offset pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 res <- matrix(nrow = length(beta), ncol = length(beta), dimnames = list(names(beta), names(beta))) # pi^2 derivative dpi <- (2 - y) / pi - (lambda + pi) ^ -1 G00 <- ((lambda + pi) ^ (-2)) - (2 - y) / (pi ^ 2) G00 <- t(as.data.frame(X[-(1:(nrow(X) / 2)), -(1:lambdaPredNumber)] * (G00 * ((piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2) ^ 2) + dpi * piLink(eta[, 2], inverse = TRUE, deriv = 2) / 2) * weight)) %*% as.matrix(X[-(1:(nrow(X) / 2)), -(1:lambdaPredNumber)]) # mixed derivative G01 <- (lambda + pi) ^ (-2) G01 <- t(as.data.frame(X[1:(nrow(X) / 2), 1:lambdaPredNumber]) * G01 * (lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2) * (piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2) * weight) %*% as.matrix(X[-(1:(nrow(X) / 2)), -(1:lambdaPredNumber)]) # lambda^2 derivative G11 <- ((lambda + pi) ^ (-2)) - (y - 1) / (lambda ^ 2) dlambda <- (y - 1) / lambda - ((lambda + pi) ^ -1) G11 <- t(as.data.frame(X[1:(nrow(X) / 2), 1:lambdaPredNumber] * (G11 * ((lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2) ^ 2) + dlambda * lambdaLink(eta[, 1], inverse = TRUE, deriv = 2) / 2) * weight)) %*% X[1:(nrow(X) / 2), 1:lambdaPredNumber] res[-(1:lambdaPredNumber), -(1:lambdaPredNumber)] <- G00 res[1:lambdaPredNumber, 1:lambdaPredNumber] <- G11 res[1:lambdaPredNumber, -(1:lambdaPredNumber)] <- t(G01) res[-(1:lambdaPredNumber), 1:lambdaPredNumber] <- G01 res } ) } validmu <- function(mu) { (sum(!is.finite(mu)) == 0) && all(0 < mu) && all(2 > mu) } # this is optional devResids <- function(y, eta, wt, ...) { 0 } pointEst <- function (pw, eta, contr = FALSE, ...) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 N <- pw / (lambda + pi) if(!contr) { N <- sum(N) } N } popVar <- function (pw, eta, cov, Xvlm, ...) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 bigTheta1 <- -pw / (pi + lambda) ^ 2 # w.r to pi bigTheta1 <- bigTheta1 * piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2 bigTheta2 <- -pw / (pi + lambda) ^ 2 # w.r to lambda bigTheta2 <- bigTheta2 * lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2 # w.r to lambda bigTheta <- t(c(bigTheta2, bigTheta1) %*% Xvlm) f1 <- t(bigTheta) %*% as.matrix(cov) %*% bigTheta f2 <- sum(pw * (1 - pi - lambda) / ((pi + lambda) ^ 2)) f1 + f2 } dFun <- function (x, eta, type = c(\"trunc\", \"nontrunc\")) { if (missing(type)) type <- \"trunc\" pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 switch (type, \"trunc\" = { (pi * as.numeric(x == 1) + lambda * as.numeric(x == 2)) / (pi + lambda) }, \"nontrunc\" = { (1 - pi - lambda) * as.numeric(x == 0) + pi * as.numeric(x == 1) + lambda * as.numeric(x == 2) } ) } simulate <- function(n, eta, lower = 0, upper = Inf) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 CDF <- function(x) { ifelse(x == Inf, 1, ifelse(x < 0, 0, ifelse(x < 1, 1 - pi - lambda, ifelse(x < 2, 1 - lambda, 1)))) } lb <- CDF(lower) ub <- CDF(upper) p_u <- stats::runif(n, lb, ub) sims <- rep(0, n) cond <- CDF(sims) <= p_u while (any(cond)) { sims[cond] <- sims[cond] + 1 cond <- CDF(sims) <= p_u } sims } getStart <- expression( if (method == \"IRLS\") { etaStart <- cbind( family$links[[1]](mean(observed == 2) * (1 + 0 * (observed == 2))), # lambda family$links[[2]](mean(observed == 1) * (1 + 0 * (observed == 1))) # pi ) + offset } else if (method == \"optim\") { init <- c( family$links[[1]](weighted.mean(observed == 2, priorWeights) * 1 + .0001), family$links[[2]](weighted.mean(observed == 1, priorWeights) * 1 + .0001) ) if (attr(terms, \"intercept\")) { coefStart <- c(init[1], rep(0, attr(Xvlm, \"hwm\")[1] - 1)) } else { coefStart <- rep(init[1] / attr(Xvlm, \"hwm\")[1], attr(Xvlm, \"hwm\")[1]) } if (\"(Intercept):pi\" %in% colnames(Xvlm)) { coefStart <- c(coefStart, init[2], rep(0, attr(Xvlm, \"hwm\")[2] - 1)) } else { coefStart <- c(coefStart, rep(init[2] / attr(Xvlm, \"hwm\")[2], attr(Xvlm, \"hwm\")[2])) } } ) structure( list( makeMinusLogLike = minusLogLike, densityFunction = dFun, links = links, mu.eta = mu.eta, valideta = function (eta) {TRUE}, variance = variance, Wfun = Wfun, funcZ = funcZ, devResids = devResids, validmu = validmu, pointEst = pointEst, popVar = popVar, family = \"myFamilyFunction\", etaNames = c(\"lambda\", \"pi\"), simulate = simulate, getStart = getStart, extraInfo = c( mean = \"pi / 2 + lambda\", variance = paste0(\"(pi / 2) * (1 - pi / 2) + 2 * lambda * (1 - lambda / 2 - pi / 2)\"), popSizeEst = \"(1 - (pi + lambda) / 2) ^ -1\", meanTr = \"1 + lambda / (pi + lambda)\", varianceTr = paste0(\"lambda * (1 - lambda / 2) / (pi + lambda)\") ) ), class = c(\"singleRfamily\", \"family\") ) } set.seed(123) Y <- simulate( myFamilyFunction(lambdaLink = \"logit\", piLink = \"logit\"), nsim = 1000, eta = matrix(0, nrow = 1000, ncol = 2), truncated = FALSE ) mm <- estimatePopsize( formula = Y ~ 1, data = data.frame(Y = Y[Y > 0]), model = myFamilyFunction(lambdaLink = \"logit\", piLink = \"logit\"), # the usual observed information matrix # is ill-suited for this distribution controlPopVar = controlPopVar(covType = \"Fisher\") ) summary(mm) ## ## Call: ## estimatePopsize.default(formula = Y ~ 1, data = data.frame(Y = Y[Y > ## 0]), model = myFamilyFunction(lambdaLink = \"logit\", piLink = \"logit\"), ## controlPopVar = controlPopVar(covType = \"Fisher\")) ## ## Pearson Residuals: ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -0.8198 -0.8198 0.8099 0.0000 0.8099 0.8099 ## ## Coefficients: ## ----------------------- ## For linear predictors associated with: lambda ## Estimate Std. Error z value P(>|z|) ## (Intercept) 0.01217 0.20253 0.06 0.952 ## ----------------------- ## For linear predictors associated with: pi ## Estimate Std. Error z value P(>|z|) ## (Intercept) -0.01217 0.08926 -0.136 0.892 ## ## AIC: 687.4249 ## BIC: 695.8259 ## Residual deviance: 0 ## ## Log-likelihood: -341.7124 on 984 Degrees of freedom ## Number of iterations: 2 ## ----------------------- ## Population size estimation results: ## Point estimate 986 ## Observed proportion: 50% (N obs = 493) ## Std. Error 70.30092 ## 95% CI for the population size: ## lowerBound upperBound ## normal 848.2127 1123.787 ## logNormal 866.3167 1144.053 ## 95% CI for the share of observed population: ## lowerBound upperBound ## normal 43.86951 58.12221 ## logNormal 43.09241 56.90759 singleRcapture:::singleRinternalcloglogLink ## function (x, inverse = FALSE, deriv = 0) ## { ## deriv <- deriv + 1 ## if (isFALSE(inverse)) { ## res <- switch(deriv, log(-log(1 - x)), -1/((1 - x) * ## log(1 - x)), -(1 + log(1 - x))/((x - 1)^2 * log(1 - ## x)^2), (2 * log(1 - x)^2 + 3 * log(1 - x) + 2)/(log(1 - ## x)^3 * (x - 1)^3)) ## } ## else { ## res <- switch(deriv, 1 - exp(-exp(x)), exp(x - exp(x)), ## (1 - exp(x)) * exp(x - exp(x)), (exp(2 * x) - 3 * ## exp(x) + 1) * exp(x - exp(x))) ## } ## res ## } ## ## "},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Piotr Chlebicki. Author, contributor. Maciej Beręsewicz. Author, maintainer.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Chlebicki P, Beręsewicz M (2025). singleRcapture: Single-Source Capture-Recapture Models. R package version 0.2.3, https://github.com/ncn-foreigners/singleRcapture.","code":"@Manual{, title = {singleRcapture: Single-Source Capture-Recapture Models}, author = {Piotr Chlebicki and Maciej Beręsewicz}, year = {2025}, note = {R package version 0.2.3}, url = {https://github.com/ncn-foreigners/singleRcapture}, }"},{"path":"https://ncn-foreigners.github.io/singleRcapture/index.html","id":"overview","dir":"","previous_headings":"","what":"Single-Source Capture-Recapture Models","title":"Single-Source Capture-Recapture Models","text":"Capture-recapture type experiments used estimate total population size situations observing part population feasible. recent years types experiments seen interest. Single-source models distinct capture-recapture models estimate population size based many units observed two three sources standard approach. Instead single-source models utilize count data regression models positive distributions (.e. counts greater 0) dependent variable number times particular unit observed source data. package aims implement already existing introduce new methods estimating population size single source simplify research process. Currently, implemented frequentist approaches used literature : Zero-truncated Poisson, geometric negative binomial regression. Zero-truncated one-inflated one-inflated zero-truncated Poisson geometric model. Zero-one-truncated Poisson geometric negative binomial models. Generalized Chao’s Zelterman’s models based logistic regression. Three types bootstrap parametric, semi-parametric nonparametric. wide range additional functionalities associated (vector) generalized linear models relevant topic. details see singleRcapture: R Package Single-Source Capture-Recapture Models vignette CRAN pkgdown website.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Single-Source Capture-Recapture Models","text":"can install current version singleRcapture main branch GitHub : install stable version CRAN :","code":"# install.packages(\"devtools\") remotes::install_github(\"ncn-foreigners/singleRcapture\") install.packages(singleRcapture)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/index.html","id":"examples","dir":"","previous_headings":"Installation","what":"Examples","title":"Single-Source Capture-Recapture Models","text":"main function package estimatePopsize fitts regression specified distribution uses fitted regression estimate population size. Lets look model 2003 publication (Van Der Heijden, P. G., Bustami, R., Cruyff, M. J., Engbersen, G., & Van Houwelingen, H. C. (2003). Point interval estimation population size using truncated Poisson regression model. Statistical Modelling, 3(4), 305-322.). call estimatePopsize look similar anyone used stats::glm function: implemented method plot function visualise model fit useful diagnostic information. One rootogram, type plot compares fitted observed marginal frequencies: possible values plotType argument : qq - normal quantile-quantile plot pearson residuals (default), marginal - matplot comparing fitted observed marginal frequencies, fitresid - plot linear predictor values contrasted pearson residuals, bootHist - histogram bootstrap sample, rootogram - rootogram, example presented , dfpopContr - contrasting two deletion effects identify presence influential observations, dfpopBox - boxplot results dfpopsize function see documentation, scaleLoc - scale-location plot, cooks - plot cooks.values distributions defined, hatplot - plot hatvalues, strata - plot confidence intervals selected populations. User can also pass arguments specify additional information plot title, subtitle etc. similar calling plot data. info check plot.singleR method documentation. seen significant differences fitted observed marginal frequencies. check intuition let’s perform goodness fit test fitted observed marginal frequencies. call summary function marginalFreq function computes marginal frequencies fitted singleR class object: Finally let us check influential observations. comparing deletion effect every observation population size estimate removing entirely model (population size estimate regression) omitting pop size estimation (called contribution observation). observation influential two actions approximately effect: easy deduce plot influential observations dataset (one particular). Lastly singleRcapture offers posthoc procedures example function stratifyPopsize estimates sizes user specified sub populations returns data.frame: strata argument may specified various ways example: package designed convenience mind, example possible specify weights provided call interpreted number occurrences units row: Methods regression diagnostics adjusted (values weights reduced instead rows removed etc.) also included option use common non standard argument significance levels different usual 5%: option estimate standard error population size estimate bootstrap, models one distribution parameter dependent covariates non standard link functions example: results significantly different (warning issued concerns second derivative test existence local minimum, inconclusive manually checked fitting process found optimal regression coefficients ’s provide information user): information criteria support second model:","code":"library(singleRcapture) model <- estimatePopsize( formula = capture ~ gender + age + nation, # specify formula data = netherlandsimmigrant, popVar = \"analytic\", # specify model = \"ztpoisson\", # distribution used method = \"IRLS\", # fitting method one of three currently supported controlMethod = controlMethod(silent = TRUE) # ignore convergence at half step warning ) summary(model) # a summary method for singleR class with standard glm-like output and population size estimation resutls #> #> Call: #> estimatePopsize.default(formula = capture ~ gender + age + nation, #> data = netherlandsimmigrant, model = \"ztpoisson\", method = \"IRLS\", #> popVar = \"analytic\", controlMethod = controlMethod(silent = TRUE)) #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.486442 -0.486442 -0.298080 0.002093 -0.209444 13.910844 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.3411 0.2149 -6.241 4.35e-10 *** #> gendermale 0.3972 0.1630 2.436 0.014832 * #> age>40yrs -0.9746 0.4082 -2.387 0.016972 * #> nationAsia -1.0926 0.3016 -3.622 0.000292 *** #> nationNorth Africa 0.1900 0.1940 0.979 0.327398 #> nationRest of Africa -0.9106 0.3008 -3.027 0.002468 ** #> nationSurinam -2.3364 1.0136 -2.305 0.021159 * #> nationTurkey -1.6754 0.6028 -2.779 0.005445 ** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> #> AIC: 1712.901 #> BIC: 1757.213 #> Residual deviance: 1128.553 #> #> Log-likelihood: -848.4504 on 1872 Degrees of freedom #> Number of iterations: 8 #> ----------------------- #> Population size estimation results: #> Point estimate 12690.35 #> Observed proportion: 14.8% (N obs = 1880) #> Std. Error 2808.165 #> 95% CI for the population size: #> lowerBound upperBound #> normal 7186.449 18194.25 #> logNormal 8431.277 19718.31 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 10.332933 26.16035 #> logNormal 9.534288 22.29793 plot(model, plotType = \"rootogram\") summary(marginalFreq(model), df = 2, dropl5 = \"group\") #> Test for Goodness of fit of a regression model: #> #> Test statistics df P(>X^2) #> Chi-squared test 50.06 2 1.3e-11 #> G-test 34.31 2 3.6e-08 #> #> -------------------------------------------------------------- #> Cells with fitted frequencies of < 5 have been grouped #> Names of cells used in calculating test(s) statistic: 1 2 3 plot(model, plotType = \"dfpopContr\") stratifyPopsize(model, alpha = c(.01, .02, .03, .05), # different significance level for each sub population strata = list( \"Females from Surinam\" = netherlandsimmigrant$gender == \"female\" & netherlandsimmigrant$nation == \"Surinam\", \"Males from Turkey\" = netherlandsimmigrant$gender == \"male\" & netherlandsimmigrant$nation == \"Turkey\", \"Younger males\" = netherlandsimmigrant$gender == \"male\" & netherlandsimmigrant$age == \"<40yrs\", \"Older males\" = netherlandsimmigrant$gender == \"male\" & netherlandsimmigrant$age == \">40yrs\" )) #> name Observed Estimated ObservedPercentage StdError #> 1 Females from Surinam 20 931.4677 2.147149 955.0657 #> 2 Males from Turkey 78 1291.2513 6.040652 741.0066 #> 3 Younger males 1391 7337.0708 18.958520 1282.1402 #> 4 Older males 91 1542.1886 5.900705 781.4747 #> normalLowerBound normalUpperBound logNormalLowerBound logNormalUpperBound #> 1 -1528.61853 3391.554 119.2661 8389.158 #> 2 -432.58790 3015.090 405.4127 4573.791 #> 3 4554.71057 10119.431 5134.8122 10834.785 #> 4 10.52637 3073.851 630.7551 3992.674 #> confLevel #> 1 0.01 #> 2 0.02 #> 3 0.03 #> 4 0.05 stratifyPopsize(model, strata = ~ gender / age) #> name Observed Estimated ObservedPercentage StdError #> 1 gender==female 398 3811.0911 10.443203 1153.9733 #> 2 gender==male 1482 8879.2594 16.690581 1812.0790 #> 3 genderfemale:age<40yrs 378 3169.8263 11.924944 880.9478 #> 4 gendermale:age<40yrs 1391 7337.0708 18.958520 1282.1402 #> 5 genderfemale:age>40yrs 20 641.2648 3.118836 407.5264 #> 6 gendermale:age>40yrs 91 1542.1886 5.900705 781.4747 #> normalLowerBound normalUpperBound logNormalLowerBound logNormalUpperBound #> 1 1549.34513 6072.837 2189.0443 6902.133 #> 2 5327.64991 12430.869 6090.7762 13354.880 #> 3 1443.20030 4896.452 1904.3126 5484.617 #> 4 4824.12208 9850.019 5306.3306 10421.082 #> 5 -157.47223 1440.002 212.3382 2026.726 #> 6 10.52637 3073.851 630.7551 3992.674 #> confLevel #> 1 0.05 #> 2 0.05 #> 3 0.05 #> 4 0.05 #> 5 0.05 #> 6 0.05 df <- netherlandsimmigrant[, c(1:3,5)] df$ww <- 0 ### this is dplyr::count without dependencies df <- aggregate(ww ~ ., df, FUN = length) summary(estimatePopsize( formula = capture ~ nation + age + gender, data = df, model = ztpoisson, weights = df$ww, controlModel = controlModel(weightsAsCounts = TRUE) )) #> #> Call: #> estimatePopsize.default(formula = capture ~ nation + age + gender, #> data = df, model = ztpoisson, weights = df$ww, controlModel = controlModel(weightsAsCounts = TRUE)) #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -317.6467 -2.4060 3.7702 0.0803 13.4920 183.2108 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.3411 0.2149 -6.241 4.35e-10 *** #> nationAsia -1.0926 0.3016 -3.622 0.000292 *** #> nationNorth Africa 0.1900 0.1940 0.979 0.327398 #> nationRest of Africa -0.9106 0.3008 -3.027 0.002468 ** #> nationSurinam -2.3364 1.0136 -2.305 0.021159 * #> nationTurkey -1.6754 0.6028 -2.779 0.005445 ** #> age>40yrs -0.9746 0.4082 -2.387 0.016972 * #> gendermale 0.3972 0.1630 2.436 0.014832 * #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> #> AIC: 1712.901 #> BIC: 1757.213 #> Residual deviance: 1128.553 #> #> Log-likelihood: -848.4504 on 1872 Degrees of freedom #> Number of iterations: 8 #> ----------------------- #> Population size estimation results: #> Point estimate 12690.35 #> Observed proportion: 14.8% (N obs = 1880) #> Std. Error 2808.169 #> 95% CI for the population size: #> lowerBound upperBound #> normal 7186.444 18194.26 #> logNormal 8431.275 19718.32 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 10.332927 26.16037 #> logNormal 9.534281 22.29793 set.seed(123) modelInflated <- estimatePopsize( formula = capture ~ gender + age, data = netherlandsimmigrant, model = \"oiztgeom\", method = \"IRLS\", # control parameters for population size estimation check documentation of controlPopVar controlPopVar = controlPopVar( alpha = .01, # significance level ) ) summary(modelInflated) #> #> Call: #> estimatePopsize.default(formula = capture ~ gender + age, data = netherlandsimmigrant, #> model = \"oiztgeom\", method = \"IRLS\", controlPopVar = controlPopVar(alpha = 0.01, #> )) #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.357193 -0.357193 -0.357193 0.000343 -0.287637 10.233608 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.5346 0.1846 -8.312 < 2e-16 *** #> gendermale 0.3863 0.1380 2.800 0.00512 ** #> age>40yrs -0.7788 0.2942 -2.648 0.00810 ** #> ----------------------- #> For linear predictors associated with: omega #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.7591 0.3765 -4.673 2.97e-06 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> #> AIC: 1736.854 #> BIC: 1759.01 #> Residual deviance: 1011.271 #> #> Log-likelihood: -864.4272 on 3756 Degrees of freedom #> Number of iterations: 6 #> ----------------------- #> Population size estimation results: #> Point estimate 5661.522 #> Observed proportion: 33.2% (N obs = 1880) #> Std. Error 963.9024 #> 99% CI for the population size: #> lowerBound upperBound #> normal 3178.674 8144.370 #> logNormal 3861.508 9096.681 #> 99% CI for the share of observed population: #> lowerBound upperBound #> normal 23.08343 59.14416 #> logNormal 20.66688 48.68564 modelInflated2 <- estimatePopsize( formula = capture ~ age, data = netherlandsimmigrant, popVar = \"bootstrap\", model = oiztgeom(omegaLink = \"cloglog\"), method = \"IRLS\", controlPopVar = controlPopVar( B = 500,# number of boostrap samples alpha = .01, # significance level # type of bootstrap see documentation for estimatePopsize bootType = \"semiparametric\", # control regression fitting on bootstrap samples bootstrapFitcontrol = controlMethod( epsilon = .Machine$double.eps, silent = TRUE, stepsize = 2 ) ), controlModel = controlModel(omegaFormula = ~ gender) # put covariates on omega i.e. the inflation parameter ) #> Warning in estimatePopsize.default(formula = capture ~ age, data = netherlandsimmigrant, : The (analytically computed) hessian of the score function is not negative define. #> NOTE: Second derivative test failing does not #> necessarily mean that the maximum of score function that was found #> numericaly is invalid since R^k is not a bounded space. #> Additionally in one inflated and hurdle models second derivative test often fails even on valid arguments. #> Warning in estimatePopsize.default(formula = capture ~ age, data = #> netherlandsimmigrant, : Switching from observed information matrix to Fisher #> information matrix because hessian of log-likelihood is not negative define. popSizeEst(modelInflated2) #> Point estimate: 5496.376 #> Variance: 1217986 #> 99% confidence intervals: #> lowerBound upperBound #> 4002.763 10231.716 plot(modelInflated2, plotType = \"bootHist\", labels = TRUE, ylim = c(0, 175), breaks = 15) #> First model: AIC = 1736.854 BIC = 1759.01 #> Second model: AIC = 1734.803 BIC = 1756.959"},{"path":"https://ncn-foreigners.github.io/singleRcapture/index.html","id":"funding","dir":"","previous_headings":"","what":"Funding","title":"Single-Source Capture-Recapture Models","text":"Work package supported National Science Centre, OPUS 20 grant . 2020/39/B/HS4/00941.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/carcassubmission.html","id":null,"dir":"Reference","previous_headings":"","what":"British farm carcass submissions data — carcassubmission","title":"British farm carcass submissions data — carcassubmission","text":"Data British animal farms submissions AHVLA. British farms able submit samples AHVLA cause death animal determined private veterinary surgeon decides submit , unless notifiable disease suspected submission required. data set contains information farms. submissions included data frame submissions carcasses .e. submissions blood samples etc. excluded.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/carcassubmission.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"British farm carcass submissions data — carcassubmission","text":"","code":"data(\"carcassubmission\")"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/carcassubmission.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"British farm carcass submissions data — carcassubmission","text":"Data frame 1,858 rows 4 columns. TOTAL_SUB Number submissions animal carcasses. log_size Numerical value equal logarithm size farm. log_distance Numerical value equal logarithm distance nearest AHVLA center. C_TYPE Factor describing type activity farm animals used . Either Dairy Beef","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/carcassubmission.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"British farm carcass submissions data — carcassubmission","text":"data set description provided publication: Böhning, D., Vidal Diez, ., Lerdsuwansri, R., Viwatwongkasem, C., Arnold, M. (2013). \"generalization Chao's estimator covariate information\". Biometrics, 69(4), 1033-1042. doi:10.1111/biom.12082","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/confint.singleRStaticCountData.html","id":null,"dir":"Reference","previous_headings":"","what":"Confidence intervals for model parameters — confint.singleRStaticCountData","title":"Confidence intervals for model parameters — confint.singleRStaticCountData","text":"function computes studentized confidence intervals model coefficients.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/confint.singleRStaticCountData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confidence intervals for model parameters — confint.singleRStaticCountData","text":"","code":"# S3 method for class 'singleRStaticCountData' confint(object, parm, level = 0.95, ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/confint.singleRStaticCountData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confidence intervals for model parameters — confint.singleRStaticCountData","text":"object object singleRStaticCountData class. parm names parameters confidence intervals computed, missing parameters considered. level confidence level intervals. ... currently nothing.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/confint.singleRStaticCountData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confidence intervals for model parameters — confint.singleRStaticCountData","text":"object named columns include upper lower limit confidence intervals.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlMethod.html","id":null,"dir":"Reference","previous_headings":"","what":"Control parameters for regression — controlMethod","title":"Control parameters for regression — controlMethod","text":"controlMethod constructs list necessary control parameters regression fitting estimatePopsizeFit estimatePopsize.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlMethod.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control parameters for regression — controlMethod","text":"","code":"controlMethod( epsilon = 1e-08, maxiter = 1000, verbose = 0, printEveryN = 1L, coefStart = NULL, etaStart = NULL, optimMethod = \"Nelder-Mead\", silent = FALSE, optimPass = FALSE, stepsize = 1, checkDiagWeights = TRUE, weightsEpsilon = 1e-08, momentumFactor = 0, saveIRLSlogs = FALSE, momentumActivation = 5, criterion = c(\"coef\", \"abstol\", \"reltol\") )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlMethod.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control parameters for regression — controlMethod","text":"epsilon tolerance level fitting algorithms default 1e-8. maxiter maximum number iterations. verbose numeric value indicating whether trace steps fitting algorithm IRLS fitting method different values verbose give following information: 1 – Returns information number current iteration current log-likelihood. 2 – Returns information vector regression parameters current iteration (). 3 – Returns information reduction log-likelihood current iteration (). 4 – Returns information value log-likelihood function gradient current iteration (). 5 – Returns information convergence criterion values taken account considering convergence (). optim method chosen verbose passed stats::optim() trace. printEveryN integer value indicating often print information specified verbose, default set 1. coefStart, etaStart initial parameters regression coefficients linear predictors NULL. IRLS fitting etaStart needed coefStart provided converted etaStart, optim fitting coefStart necessary argument etaStart ignored. optimMethod method stats::optim() used \"Nelder-Mead\" default . silent logical value, indicating whether warnings IRLS method suppressed. optimPass optional list parameters passed stats::optim(..., control = optimPass) FALSE list control parameters inferred parameters. stepsize IRLS, scaling updates beta vector lower value means slower convergence accuracy default 1. general fitting algorithm fails lowering value tends effective correcting . checkDiagWeights logical value indicating whether check diagonal elements working weights matrixes IRLS sufficiently positive matrixes positive defined. default TRUE. weightsEpsilon small number ensure positive definedness weights matrixes. matters checkDiagWeights set TRUE. default 1e-8. momentumFactor experimental parameter IRLS allowing taking previous step account current step, .e instead updating regression parameters : _() = _(-1) + stepsize step_() update made : _() = _(-1) + stepsize (step_() + momentumstep_(-1)) saveIRLSlogs logical value indicating information specified verbose saved output object, default FALSE. momentumActivation value log-likelihood reduction bellow momentum apply. criterion criterion used determine convergence IRLS, multiple values may provided. default c(\"coef\", \"abstol\").","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlMethod.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control parameters for regression — controlMethod","text":"List selected parameters, also possible call list directly.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlMethod.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Control parameters for regression — controlMethod","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlModel.html","id":null,"dir":"Reference","previous_headings":"","what":"Control parameters specific to some models — controlModel","title":"Control parameters specific to some models — controlModel","text":"controlModel constructs list necessary control parameters estimatePopsize either specific selected model fit anywhere else. Specifying additional formulas done using right hand side formula also now variables additional formulas also included \"main\" formula.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlModel.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control parameters specific to some models — controlModel","text":"","code":"controlModel( weightsAsCounts = FALSE, omegaFormula = ~1, alphaFormula = ~1, piFormula = ~1 )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlModel.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control parameters specific to some models — controlModel","text":"weightsAsCounts boolean value indicating whether treat weights argument number occurrences row data adjust necessary methods functionalities, like adjustments bootstrap decreasing weights dfbeta instead deleting rows data, accommodate form model specification. omegaFormula formula inflation parameter one inflated zero truncated zero truncated one inflated models. alphaFormula formula dispersion parameter negative binomial based models. piFormula formula probability parameter pseudo hurdle zero truncated zero truncated pseudo hurdle models.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlModel.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control parameters specific to some models — controlModel","text":"list selected parameters, also possible call list directly.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlModel.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Control parameters specific to some models — controlModel","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlPopVar.html","id":null,"dir":"Reference","previous_headings":"","what":"Control parameters for population size estimation — controlPopVar","title":"Control parameters for population size estimation — controlPopVar","text":"Creating control parameters population size estimation respective standard error variance estimation.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlPopVar.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control parameters for population size estimation — controlPopVar","text":"","code":"controlPopVar( alpha = 0.05, bootType = c(\"parametric\", \"semiparametric\", \"nonparametric\"), B = 500, confType = c(\"percentilic\", \"normal\", \"basic\"), keepbootStat = TRUE, traceBootstrapSize = FALSE, bootstrapVisualTrace = FALSE, fittingMethod = c(\"optim\", \"IRLS\"), bootstrapFitcontrol = NULL, sd = c(\"sqrtVar\", \"normalMVUE\"), covType = c(\"observedInform\", \"Fisher\"), cores = 1L )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlPopVar.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control parameters for population size estimation — controlPopVar","text":"alpha significance level, 0.05 used default. bootType bootstrap type used. Default \"parametric\", possible values : \"semiparametric\" \"nonparametric\". B number bootstrap samples performed (default 500). confType type confidence interval bootstrap confidence interval, \"percentile\" default. possibilities: \"studentized\" \"basic\". keepbootStat boolean value indicating whether keep vector statistics produced bootstrap. traceBootstrapSize boolean value indicating whether print size bootstrapped sample truncation semi- fully parametric bootstraps. bootstrapVisualTrace boolean value indicating whether plot bootstrap statistics real time cores = 1 cores > 1 instead indicates whether make progress bar. fittingMethod method used fitting models bootstrap samples. bootstrapFitcontrol control parameters regression works exactly like controlMethod fitting models bootstrap samples. sd character indicating compute standard deviation population size estimator either : =var(N) sqrt (slightly biased N normal distribution) normalMVUE unbiased minimal variance estimator normal distribution: =var(N) (N_obs-12)(N_obs2) N_obs2 ration involving gamma functions computed log gamma function. covType type covariance matrix regression parameters default observed information matrix. cores bootstrap , number processor cores used, number greater 1 activates code designed doParallel, foreach parallel packages. Note now using parallel computing makes tracing impossible traceBootstrapSize bootstrapVisualTrace parameters ignored case.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlPopVar.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control parameters for population size estimation — controlPopVar","text":"list selected parameters, also possible call list directly.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlPopVar.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Control parameters for population size estimation — controlPopVar","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":null,"dir":"Reference","previous_headings":"","what":"Single-source capture-recapture models — estimatePopsize","title":"Single-source capture-recapture models — estimatePopsize","text":"estimatePopsize first fits appropriate (v)glm model estimates full (observed unobserved) population size. types models assumed response vector (.e. dependent variable) corresponds number times given unit observed source. Population size usually estimated Horvitz-Thompson type estimator: N = _k=1^NI_kP(Y_k>0) = _k=1^N_obs11-P(Y_k=0) I_k=I_Y_k > 0 indicator variables, value 1 kth unit observed least 0 otherwise.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Single-source capture-recapture models — estimatePopsize","text":"","code":"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\"), 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, ratioReg = FALSE, offset, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Single-source capture-recapture models — estimatePopsize","text":"formula formula model fitted, applied \"main\" linear predictor. single response models available. ... additional optional arguments passed methods eg. estimatePopsizeFit. data data frame object coercible data.frame class containing data regression population size estimation. model model regression population estimate full description singleRmodels(). weights optional object prior weights used fitting model. Can used specify number occurrences rows data see controlModel() subset logical vector indicating observations used regression population size estimation. evaluated data argument provided call. naAction yet implemented. method method fitting values currently supported: iteratively reweighted least squares (IRLS) maximum likelihood (optim). popVar method constructing confidence interval estimating standard error either analytic bootstrap. Bootstrap confidence interval type may specified controlPopVar. also third possible value noEst skips population size estimate together. controlMethod list indicating parameters use fitting model may constructed singleRcapture::controlMethod function. information included controlMethod(). controlModel list indicating additional formulas regression (like formula inflation parameter/dispersion parameter) may constructed singleRcapture::controlModel function. information eventually included controlModel(). controlPopVar list indicating parameters use estimating variance population size estimation may constructed singleRcapture::controlPopVar function. information included controlPopVar(). modelFrame, x, y logical values indicating whether return model matrix, dependent vector model matrix part output. contrasts yet implemented. ratioReg yet implemented offset matrix offset values number columns matching number distribution parameters providing offset values linear predictors.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Single-source capture-recapture models — estimatePopsize","text":"Returns object class c(\"singleRStaticCountData\", \"singleR\", \"glm\", \"lm\") type list containing: y – Vector dependent variable specified function call. X – Model matrix specified function call. formula – list formula provided call additional formulas specified controlModel. call – Call matching original input. coefficients – vector fitted coefficients regression. control – list control parameters controlMethod controlModel, controlPopVar included populationSize. model – Model estimation population size regression built, object class family. deviance – Deviance model. priorWeights – Prior weight provided call. weights – IRLS method estimation chosen weights returned IRLS, otherwise priorWeights. residuals – Vector raw residuals. logL – Logarithm likelihood obtained final iteration. iter – Numbers iterations performed fitting stats::optim used number call loglikelihood function. dfResiduals – Residual degrees freedom. dfNull – Null degrees freedom. fittValues – Data frame fitted values mu (expected value) lambda (Poisson parameter). populationSize – list containing information population size estimate. modelFrame – Model frame specified call. linearPredictors – Vector fitted linear predictors. sizeObserved – Number observations original model frame. terms – terms attribute model frame used. contrasts – contrasts specified function call. naAction – naAction used. – list indicating observations used regression/population size estimation. fittingLog – log fitting information \"IRLS\" fitting specified controlMethod.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Single-source capture-recapture models — estimatePopsize","text":"generalized linear model characterized equation =X X (lm) model matrix. vector generalized linear model similarly characterized equations _k=X_k_k X_k (lm) model matrix constructed appropriate formula (specified controlModel parameter). vector constructed : =pmatrix _1 _2 _p pmatrix^T cases models package (vlm) model matrix constructed block matrix: X_vlm= pmatrix X_1 & 0 & &0 0 & X_2 & &0 & & & 0 & 0 & &X_p pmatrix differs convention VGAM package (consider special cases vglm models) just convention affect model, convention taken makes fitting IRLS (explanation algorithm estimatePopsizeFit()) algorithm easier. (constraints matrixes vglm match ones implicitly use vglm model matrix differs respect order kronecker multiplication X constraints.) package use observed likelihood fit regression models. mentioned usually population size estimation done via: N = _k=1^NI_kP(Y_k>0) = _k=1^N_obs11-P(Y_k=0) I_k=I_Y_k > 0 indicator variables, value 1 kth unit observed least 0 otherwise. P(Y_k>0) estimated maximum likelihood. following assumptions usually present using method estimation described : specified regression model correct. entails linear relationship independent variables dependent ones dependent variable generated appropriate distribution. unobserved heterogeneity. assumption broken possible (admittedly imperfect) workarounds see details singleRmodels(). population size constant relevant time frame. Depending confidence interval construction (asymptotic) normality N statistic assumed. two ways estimating variance estimate N, first \"analytic\" usually done application law total variance N: var(N)=E(var (N|I_1,...,I_n))+ var(E(N|I_1,...,I_n)) method N|I_1,... I_N: E(var (N|I_1,...,I_n))= .((N|I_1,...,I_N))^T cov() ((N|I_1,...,I_N)) |_= var(E(N|I_1,...,I_n)) term may derived analytically (assume independence observations) since N|I_1,...,I_n just constant. general gives us: aligned var(E(N|I_1,...,I_n))&= var(_k=1^NI_kP(Y_k>0)) &=_k=1^Nvar(I_kP(Y_k>0)) &=_k=1^N1P(Y_k>0)^2var(I_k) &=_k=1^N1P(Y_k>0)^2P(Y_k>0)(1-P(Y_k>0)) &=_k=1^N1P(Y_k>0)(1-P(Y_k>0)) &_k=1^NI_kP(Y_k>0)^2(1-P(Y_k>0)) &=_k=1^N_obs1-P(Y_k>0)P(Y_k>0)^2 aligned approximation 6th line appears 5th line sum units, includes unobserved units, since I_k independent I_k b(P(Y_k>0)) 6th line unbiased estimator 5th line. method estimating variance \"bootstrap\", since N_obs=_k=1^NI_k also random variable bootstrap simple just drawing N_obs units data replacement just computing N. Method described referred literature \"nonparametric\" bootstrap (see controlPopVar()), due ignoring variability observed sample size likely underestimate variance. sophisticated bootstrap procedure may described follows: Compute probability distribution : f_0N, f_1N, ..., f_yN f_n denotes observed marginal frequency units observed exactly n times. Draw N units distribution (N integer draw N + b(N-N)), floor function. Truncated units y=0. covariates draw original data replacement uniform distribution. example unit drawn new data y=2 choose one covariate vectors original data associated unit observed 2 times. Regress y_new X_vlm new obtain _new, starting point make slightly faster, use compute N_new. Repeat 2-5 unit least B statistics obtained. Compute confidence intervals based alpha confType specified controlPopVar(). step 1 procedure convenient first draw binary vector length N + b(N-N) probability 1-f_0N, sum elements vector determine sample size draw sample size uniformly data. procedure known literature \"semiparametric\" bootstrap necessary assume correct estimate N order use type bootstrap. Lastly \"paramteric\" bootstrap assume probabilistic model used obtain N correct bootstrap procedure may described : Draw N + b(N-N) covariate information vectors replacement data according probability distribution proportional : N_k, N_k contribution kth unit .e. 1P(Y_k>0). Determine matrix using estimate . Generate y (dependent variable) vector using probability mass function associated chosen model. Truncated units y=0 construct y_new X_vlm new. Regress y_new X_vlm new obtain _new use compute N_new. Repeat 1-5 unit least B statistics obtained. Compute confidence intervals based alpha confType specified controlPopVar() also worth noting \"analytic\" method estimatePopsize uses \"standard\" covariance matrix estimation. possible improper covariance matrix estimate part estimation assumptions violated. cases post-hoc procedures implemented package address issue. Lastly confidence intervals N computed (analytic case) either assuming follows normal distribution variable (N-N) follows normal distribution. estimates may found using either summary.singleRStaticCountData method popSizeEst.singleRStaticCountData function. labelled normal logNormal respectively.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Single-source capture-recapture models — estimatePopsize","text":"General single source capture recapture literature: Zelterman, Daniel (1988). ‘Robust estimation truncated discrete distributions application capture-recapture experiments’. : Journal statistical planning inference 18.2, pp. 225–237. Heijden, Peter GM van der et al. (2003). ‘Point interval estimation population size using truncated Poisson regression model’. : Statistical Modelling 3.4, pp. 305–322. doi: 10.1191/1471082X03st057oa. Cruyff, Maarten J. L. F. Peter G. M. van der Heijden (2008). ‘Point Interval Estimation Population Size Using Zero-Truncated Negative Binomial Regression Model’. : Biometrical Journal 50.6, pp. 1035–1050. doi: 10.1002/bimj.200810455 Böhning, Dankmar Peter G. M. van der Heijden (2009). ‘covariate adjustment zero-truncated approaches estimating size hidden elusive populations’. : Annals Applied Statistics 3.2, pp. 595–610. doi: 10.1214/08-AOAS214. Böhning, Dankmar, Alberto Vidal-Diez et al. (2013). ‘Generalization Chao’s Estimator Covariate Information’. : Biometrics 69.4, pp. 1033– 1042. doi: 10.1111/biom.12082 Böhning, Dankmar Peter G. M. van der Heijden (2019). ‘identity zero-truncated, one-inflated likelihood zero-one-truncated likelihood general count densities application drink-driving Britain’. : Annals 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 robust estimation population size zero-truncated clustered Data. Biom J. 2008 Aug;50(4):584-96. doi: 10.1002/bimj.200710441. Böhning D. equivalence one-inflated zero-truncated 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 sparse count data. Stat Methods Appl 30, 1197–1217 (2021). doi: 10.1007/s10260-021-00556-8 Bootstrap: Zwane, PGM EN Van der Heijden, Implementing parametric bootstrap capture-recapture models continuous covariates 2003 Statistics & probability letters 65.2 pp 121-125 Norris, James L Pollock, Kenneth H Including model uncertainty estimating variances multiple capture studies 1996 Environmental Ecological Statistics 3.3 pp 235-244 Vector generalized linear models: Yee, T. W. (2015). Vector Generalized Linear Additive Models: Implementation R. New York, USA: Springer. ISBN 978-1-4939-2817-0.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Single-source capture-recapture models — estimatePopsize","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Single-source capture-recapture models — estimatePopsize","text":"","code":"# \\donttest{ # 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) #> #> Call: #> estimatePopsize.default(formula = capture ~ gender + age + nation, #> data = netherlandsimmigrant, model = ztpoisson) #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.486442 -0.486442 -0.298080 0.002093 -0.209444 13.910844 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.3411 0.2149 -6.241 4.35e-10 *** #> gendermale 0.3972 0.1630 2.436 0.014832 * #> age>40yrs -0.9746 0.4082 -2.387 0.016972 * #> nationAsia -1.0926 0.3016 -3.622 0.000292 *** #> nationNorth Africa 0.1900 0.1940 0.979 0.327398 #> nationRest of Africa -0.9106 0.3008 -3.027 0.002468 ** #> nationSurinam -2.3364 1.0136 -2.305 0.021159 * #> nationTurkey -1.6754 0.6028 -2.779 0.005445 ** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 1712.901 #> BIC: 1757.213 #> Residual deviance: 1128.553 #> #> Log-likelihood: -848.4504 on 1872 Degrees of freedom #> Number of iterations: 8 #> ----------------------- #> Population size estimation results: #> Point estimate 12690.35 #> Observed proportion: 14.8% (N obs = 1880) #> Std. Error 2808.169 #> 95% CI for the population size: #> lowerBound upperBound #> normal 7186.444 18194.26 #> logNormal 8431.275 19718.32 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 10.332927 26.16037 #> logNormal 9.534281 22.29793 # Graphical presentation of model fit plot(model, \"rootogram\") # Statistical test # see documentation for summary.singleRmargin summary(marginalFreq(model), df = 1, \"group\") #> Test for Goodness of fit of a regression model: #> #> Test statistics df P(>X^2) #> Chi-squared test 50.06 1 1.5e-12 #> G-test 34.31 1 4.7e-09 #> #> -------------------------------------------------------------- #> Cells with fitted frequencies of < 5 have been grouped #> Names of cells used in calculating test(s) statistic: 1 2 3 # 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) #> #> Call: #> estimatePopsize.default(formula = TOTAL_SUB ~ ., data = farmsubmission, #> model = ztnegbin, method = \"optim\") #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.71322 -0.33627 -0.14256 0.00001 0.14745 7.01427 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -3.17536 0.25947 -12.238 < 2e-16 *** #> log_size 0.63932 0.01771 36.102 < 2e-16 *** #> log_distance -0.07935 0.02228 -3.561 0.000369 *** #> C_TYPEDairy 0.65919 0.03412 19.317 < 2e-16 *** #> ----------------------- #> For linear predictors associated with: alpha #> Estimate Std. Error z value P(>|z|) #> (Intercept) 0.58238 0.07299 7.979 1.48e-15 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 34538.73 #> BIC: 34575.71 #> Residual deviance: 17730.07 #> #> Log-likelihood: -17264.37 on 24067 Degrees of freedom #> Number of calls to log-likelihood function: 654 #> ----------------------- #> Population size estimation results: #> Point estimate 41019.07 #> Observed proportion: 29.3% (N obs = 12036) #> Std. Error 1888.039 #> 95% CI for the population size: #> lowerBound upperBound #> normal 37318.59 44719.56 #> logNormal 37548.53 44961.73 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 26.91440 32.25203 #> logNormal 26.76943 32.05452 summary(marginalFreq(modelNegBin)) #> Test for Goodness of fit of a regression model: #> #> Test statistics df P(>X^2) #> Chi-squared test 30.93 26 0.23 #> G-test 19.12 26 0.83 #> #> -------------------------------------------------------------- #> Cells with fitted frequencies of < 5 have been dropped #> Names of cells used in calculating test(s) statistic: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 # 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) ) #> Iteration number 1 log-likelihood: -846.77533 #> Parameter vector: -1.52435898 -0.62008047 0.16074142 -0.49971856 -0.85750609 -0.78860226 -0.42067526 -0.44312806 -0.70241852 #> log-likelihood reduction: Inf #> Value of gradient at current step: #> 142.04204576 8.81177229 108.34506498 9.81769037 -0.39315787 1.30854693 2.40548998 -74.87532567 -61.35856914 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 1.524359 #> ---- #> Iteration number 2 log-likelihood: -828.37292 #> Parameter vector: -1.11072318 -0.66579168 0.16032836 -0.51705318 -1.27720523 -0.93384649 -0.55851513 -0.52578104 -0.41829231 #> log-likelihood reduction: 18.402407 #> Value of gradient at current step: #> -30.198518684 -2.367348700 -20.882807839 -2.990134863 -0.033406007 -0.236178150 -0.291286777 12.908733472 8.061651997 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.41969914 #> ---- #> Iteration number 3 log-likelihood: -827.03041 #> Parameter vector: -1.26212005 -0.65481997 0.16367571 -0.51638838 -1.22088469 -0.89969898 -0.52141633 -0.61358371 -0.51802941 #> log-likelihood reduction: 1.3425075 #> Value of gradient at current step: #> -0.399477106 -0.125534668 -0.025207083 -0.124263770 -0.012272383 -0.001036293 -0.037255028 -0.402440790 -0.559697165 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.15139687 #> ---- #> Iteration number 4 log-likelihood: -827.01868 #> Parameter vector: -1.28179260 -0.65559457 0.16445074 -0.51702724 -1.22154349 -0.89783555 -0.52232876 -0.64032726 -0.52639838 #> log-likelihood reduction: 0.011729135 #> Value of gradient at current step: #> 0.01965800195 -0.00376668640 0.02342526604 0.00085753707 -0.00131148043 0.00040402353 -0.00468611749 -0.01113423867 -0.00978879207 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.026743552 #> ---- #> Iteration number 5 log-likelihood: -827.01868 #> Parameter vector: -1.28177518 -0.65568959 0.16449297 -0.51701807 -1.22190483 -0.89779857 -0.52262758 -0.64032669 -0.52640250 #> log-likelihood reduction: 0.0000018094989 #> Value of gradient at current step: #> -0.0001561899387 0.0000207886459 -0.0000413107753 -0.0000259493362 0.0000040518562 -0.0000068413444 -0.0000222504320 0.0000011784080 0.0000010016067 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.00036133989 #> ---- #> Iteration number 6 log-likelihood: -827.01868 #> Parameter vector: -1.28177959 -0.65568717 0.16449471 -0.51701668 -1.22190170 -0.89779724 -0.52262830 -0.64033172 -0.52640214 #> log-likelihood reduction: 0.00000000032207481 #> Value of gradient at current step: #> 0.00000138172839925 -0.00000029541573543 0.00000194942825438 0.00000005064943620 -0.00000001912655101 0.00000005032669892 -0.00000167462238743 -0.00000000020190338 -0.00000000017657165 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.0000050277134 #> ---- #> Value of analytically computed hessian at fitted regression coefficients: #> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] -600.647579 -45.430239 -437.78550 -46.3057511 -3.648625 -9.9715730 #> [2,] -45.430239 -45.430239 0.00000 0.0000000 0.000000 0.0000000 #> [3,] -437.785496 0.000000 -437.78550 0.0000000 0.000000 0.0000000 #> [4,] -46.305751 0.000000 0.00000 -46.3057511 0.000000 0.0000000 #> [5,] -3.648625 0.000000 0.00000 0.0000000 -3.648625 0.0000000 #> [6,] -9.971573 0.000000 0.00000 0.0000000 0.000000 -9.9715730 #> [7,] -17.976683 -2.320732 -11.24212 -0.6903141 -2.003224 -0.2486649 #> [8,] 328.022454 23.801161 241.35686 24.3769265 1.870670 5.1505625 #> [9,] 280.048801 20.260808 211.90055 19.7419682 1.462128 4.6637718 #> [,7] [,8] [,9] #> [1,] -17.9766828 328.022454 280.048801 #> [2,] -2.3207316 23.801161 20.260808 #> [3,] -11.2421165 241.356859 211.900549 #> [4,] -0.6903141 24.376927 19.741968 #> [5,] -2.0032237 1.870670 1.462128 #> [6,] -0.2486649 5.150563 4.663772 #> [7,] -17.9766828 9.477666 8.492258 #> [8,] 9.4776658 -197.098079 -168.419176 #> [9,] 8.4922579 -168.419176 -168.419176 #> The matrix above has the following eigen values: #> -3.121074 -6.868861 -9.331036 -16.61098 -18.10422 -33.99724 -45.94396 -112.7247 -1280.581 summary(pseudoHurdleModel) #> #> Call: #> estimatePopsize.default(formula = capture ~ nation + age, data = netherlandsimmigrant, #> model = Hurdleztgeom, method = \"IRLS\", controlMethod = controlMethod(verbose = 5), #> controlModel = controlModel(piFormula = ~gender)) #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.428461 -0.428461 -0.288574 0.004918 -0.181672 13.696149 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.2818 0.1858 -6.899 5.22e-12 *** #> nationAsia -0.6557 0.1994 -3.289 0.00101 ** #> nationNorth Africa 0.1645 0.1417 1.161 0.24561 #> nationRest of Africa -0.5170 0.1979 -2.612 0.00900 ** #> nationSurinam -1.2219 0.5552 -2.201 0.02775 * #> nationTurkey -0.8978 0.3439 -2.611 0.00903 ** #> age>40yrs -0.5226 0.2469 -2.117 0.03429 * #> ----------------------- #> For linear predictors associated with: pi #> Estimate Std. Error z value P(>|z|) #> (Intercept) -0.6403 0.2945 -2.174 0.02969 * #> gendermale -0.5264 0.2043 -2.577 0.00996 ** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 1672.037 #> BIC: 1721.889 #> Residual deviance: 1492.301 #> #> Log-likelihood: -827.0187 on 3751 Degrees of freedom #> Number of iterations: 6 #> ----------------------- #> Population size estimation results: #> Point estimate 6446.833 #> Observed proportion: 29.2% (N obs = 1880) #> Std. Error 1126.716 #> 95% CI for the population size: #> lowerBound upperBound #> normal 4238.511 8655.156 #> logNormal 4715.983 9234.051 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 21.72116 44.35520 #> logNormal 20.35943 39.86443 # Assessing model fit plot(pseudoHurdleModel, \"rootogram\") summary(marginalFreq(pseudoHurdleModel), \"group\", df = 1) #> Test for Goodness of fit of a regression model: #> #> Test statistics df P(>X^2) #> Chi-squared test 1.89 1 0.17 #> G-test 2.13 1 0.14 #> #> -------------------------------------------------------------- #> Cells with fitted frequencies of < 5 have been grouped #> Names of cells used in calculating test(s) statistic: 1 2 3 4 # 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)) #> Test for Goodness of fit of a regression model: #> #> Test statistics df P(>X^2) #> Chi-squared test 54.98 11 7.8e-08 #> G-test 23.06 11 1.7e-02 #> #> -------------------------------------------------------------- #> Cells with fitted frequencies of < 5 have been dropped #> Names of cells used in calculating test(s) statistic: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 summary(Model) #> #> Call: #> estimatePopsize.default(formula = TOTAL_SUB ~ ., data = farmsubmission, #> model = oiztgeom(omegaLink = \"cloglog\"), method = \"IRLS\", #> controlMethod = controlMethod(stepsize = 0.85, momentumFactor = 1.2, #> epsilon = 1e-10, silent = TRUE), controlModel = controlModel(omegaFormula = ~C_TYPE + #> log_size)) #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.891103 -0.644972 -0.443066 0.005967 0.295374 20.809832 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -2.76388 0.23858 -11.585 < 2e-16 *** #> log_size 0.62734 0.01787 35.110 < 2e-16 *** #> log_distance -0.07200 0.02004 -3.593 0.000327 *** #> C_TYPEDairy 0.50965 0.04032 12.640 < 2e-16 *** #> ----------------------- #> For linear predictors associated with: omega #> Estimate Std. Error z value P(>|z|) #> (Intercept) -5.0973 0.8268 -6.165 7.03e-10 *** #> C_TYPEDairy -1.4002 0.3700 -3.784 0.000154 *** #> log_size 0.4461 0.1330 3.354 0.000795 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 34579.91 #> BIC: 34631.68 #> Residual deviance: 12327.24 #> #> Log-likelihood: -17282.96 on 24065 Degrees of freedom #> Number of iterations: 13 #> ----------------------- #> Population size estimation results: #> Point estimate 27249.03 #> Observed proportion: 44.2% (N obs = 12036) #> Std. Error 972.0123 #> 95% CI for the population size: #> lowerBound upperBound #> normal 25343.92 29154.13 #> logNormal 25460.09 29276.36 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 41.28402 47.49069 #> logNormal 41.11166 47.27399 # }"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":null,"dir":"Reference","previous_headings":"","what":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"estimatePopsizeFit estimatePopsize glm.fit glm. internally called estimatePopsize. Since estimatePopsize much just regression fitting estimatePopsizeFit much faster.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"","code":"estimatePopsizeFit( y, X, family, control, method, priorWeights, coefStart, etaStart, offset, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"y vector dependent variables. X model matrix, vglm one. family model estimatePopsize. control control parameters created controlModel. method method estimation estimatePopsize. priorWeights vector prior weights argument weights estimatePopsize. etaStart, coefStart initial value regression parameters linear predictors. offset offset passed default passed estimatePopsize(). ... arguments pass methods.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"List regression parameters, working weights (IRLS fitting method) chosen number iterations taken.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"method argument set \"optim\" stats::optim function used fit regression analytically computed gradient (minus) log likelihood functions gr fn arguments. Unfortunately optim allow hessian specified. information modify optim fitting included controlMethod(). method argument set \"IRLS\" iteratively reweighted least squares. algorithm well know generalised linear models. Thomas W. Yee later extended algorithm vector generalised linear models general terms can roughly described (Yee's description changing conventions): Initialize : converged <- FALSE iter <- 1 <- start W <- prior <- () converged iter > Maxiter move step 7. Store values previous algorithm step: W_- <- W _- <- _- <- assign values current step: <- X_vlm Z_i <- _i+_i_i E(^2_i _i^T_i)^-1 W_ij <- E(^2 _j^T_i) _i ith component log likelihood function, _i vector linear predictors associated ith row E(^2_i _i^T_i) corresponds weights associated ith row W block matrix, made diagonal matrixes E(^2 _j^T_i) Regress Z X_vlm obtain : = (X_vlm^TWX_vlm)^-1 X_vlm^TWZ Assign: converged <- ()-_- < _- ||-_-||_ < iter <- iter + 1 relative tolerance level, default 1e-8. Return step 2. Return , W, iter. package use different conventions X_vlm matrix hence slight differences present algorithm description results identical.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"Yee, T. W. (2015). Vector Generalized Linear Additive Models: Implementation R. New York, USA: Springer. ISBN 978-1-4939-2817-0.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"Piotr Chlebicki, Maciej Beresewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"","code":"# \\donttest{ summary(farmsubmission) #> TOTAL_SUB log_size log_distance C_TYPE #> Min. : 1.00 Min. : 0.000 Min. : 4.102 Beef :5336 #> 1st Qu.: 1.00 1st Qu.: 4.673 1st Qu.:10.351 Dairy:6700 #> Median : 1.00 Median : 5.347 Median :10.778 #> Mean : 2.34 Mean : 5.259 Mean :10.662 #> 3rd Qu.: 3.00 3rd Qu.: 5.940 3rd Qu.:11.099 #> Max. :47.00 Max. :10.480 Max. :12.097 # construct vglm model matrix X <- matrix(data = 0, nrow = 2 * NROW(farmsubmission), ncol = 7) X[1:NROW(farmsubmission), 1:4] <- model.matrix( ~ 1 + log_size + log_distance + C_TYPE, farmsubmission ) X[-(1:NROW(farmsubmission)), 5:7] <- X[1:NROW(farmsubmission), c(1, 3, 4)] # this attribute tells the function which elements of the design matrix # correspond to which linear predictor attr(X, \"hwm\") <- c(4, 3) # get starting points start <- glm.fit( y = farmsubmission$TOTAL_SUB, x = X[1:NROW(farmsubmission), 1:4], family = poisson() )$coefficients res <- estimatePopsizeFit( y = farmsubmission$TOTAL_SUB, X = X, method = \"IRLS\", priorWeights = 1, family = ztoigeom(), control = controlMethod(verbose = 5), coefStart = c(start, 0, 0, 0), etaStart = matrix(X %*% c(start, 0, 0, 0), ncol = 2), offset = cbind(rep(0, NROW(farmsubmission)), rep(0, NROW(farmsubmission))) ) #> Iteration number 1 log-likelihood: -17455.372 #> Parameter vector: -2.255494347 0.521900283 -0.048255922 0.321168020 -1.297382847 0.049409082 -0.726587214 #> log-likelihood reduction: Inf #> Value of gradient at current step: #> 639.53919 4035.62183 6732.72078 672.31223 -316.39394 -3358.16739 -229.50394 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 2.2554943 #> ---- #> Iteration number 2 log-likelihood: -17289.531 #> Parameter vector: -2.859491920 0.627917105 -0.063516471 0.573159952 -2.327571214 0.074464787 -0.734988992 #> log-likelihood reduction: 165.84115 #> Value of gradient at current step: #> 77.37365182 329.72667483 823.92206208 0.28711463 -53.27713944 -568.21808076 -29.69092406 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 1.0301884 #> ---- #> Iteration number 3 log-likelihood: -17279.272 #> Parameter vector: -2.710874025 0.613067896 -0.069548715 0.537208696 -2.550651004 0.071488122 -0.939145580 #> log-likelihood reduction: 10.258788 #> Value of gradient at current step: #> 35.9649654 218.1210745 385.4441808 32.8759028 -6.8429684 -71.8589804 -5.7178443 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.22307979 #> ---- #> Iteration number 4 log-likelihood: -17278.776 #> Parameter vector: -2.78426085 0.61628333 -0.06440012 0.53843272 -3.10491635 0.12060422 -1.04138882 #> log-likelihood reduction: 0.49548535 #> Value of gradient at current step: #> 1.67966432 11.13935043 16.42827781 1.15147049 -0.53787945 -5.57182317 -0.74695785 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.55426534 #> ---- #> Iteration number 5 log-likelihood: -17278.762 #> Parameter vector: -2.77818073 0.61674992 -0.06504016 0.53517478 -3.10447410 0.12145802 -1.08163762 #> log-likelihood reduction: 0.014133264 #> Value of gradient at current step: #> 0.232501334 2.204257359 2.694809270 0.131590616 -0.071608376 -0.605938875 -0.064356213 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.040248796 #> ---- #> Iteration number 6 log-likelihood: -17278.761 #> Parameter vector: -2.78602286 0.61698772 -0.06441877 0.53495927 -3.19325142 0.12969021 -1.08314735 #> log-likelihood reduction: 0.00072206104 #> Value of gradient at current step: #> -0.0149254818 -0.0442854059 -0.2585639448 -0.0671445437 -0.0089103073 -0.1428452786 -0.0408361062 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.088777321 #> ---- #> Iteration number 7 log-likelihood: -17278.761 #> Parameter vector: -2.783307402 0.617006834 -0.064659772 0.534565433 -3.160032510 0.126742033 -1.087078105 #> log-likelihood reduction: 0.000086867327 #> Value of gradient at current step: #> 0.0219006963 0.2137543748 0.2878052109 0.0210725209 -0.0038258075 -0.0055588958 0.0088000042 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.033218913 #> ---- #> Iteration number 8 log-likelihood: -17278.761 #> Parameter vector: -2.785132183 0.617029483 -0.064506904 0.534668321 -3.181900933 0.128724679 -1.085840518 #> log-likelihood reduction: 0.00002149725 #> Value of gradient at current step: #> -0.00917986045 -0.07823752476 -0.12764140888 -0.01528913767 0.00031447068 -0.01459257984 -0.00776040766 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.021868422 #> ---- #> Iteration number 9 log-likelihood: -17278.761 #> Parameter vector: -2.784182050 0.617023943 -0.064588093 0.534586386 -3.170374939 0.127687086 -1.086727858 #> log-likelihood reduction: 0.0000064244196 #> Value of gradient at current step: #> 0.00580810485 0.05244014331 0.07853720973 0.00778331027 -0.00057098473 0.00429221924 0.00373823937 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.011525994 #> ---- #> Iteration number 10 log-likelihood: -17278.761 #> Parameter vector: -2.784725925 0.617028507 -0.064541975 0.534626993 -3.176948180 0.128280435 -1.086273279 #> log-likelihood reduction: 0.0000019945583 #> Value of gradient at current step: #> -0.00307033641 -0.02728421582 -0.04201045320 -0.00448214637 0.00022935424 -0.00326931975 -0.00221219809 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.006573241 #> ---- #> Iteration number 11 log-likelihood: -17278.761 #> Parameter vector: -2.78442528 0.61702627 -0.06456754 0.53460327 -3.17330966 0.12795232 -1.08653540 #> log-likelihood reduction: 0.00000061988248 #> Value of gradient at current step: #> 0.00175710834 0.01568170298 0.02390375513 0.00247668338 -0.00014882078 0.00161926855 0.00120723718 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.0036385179 #> ---- #> Iteration number 12 log-likelihood: -17278.761 #> Parameter vector: -2.784593634 0.617027580 -0.064553239 0.534616288 -3.175346365 0.128136053 -1.086390890 #> log-likelihood reduction: 0.00000019314757 #> Value of gradient at current step: #> -0.000968762326 -0.008641334478 -0.013216142966 -0.001385713893 0.000077984443 -0.000953809247 -0.000679710380 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.0020367031 #> ---- #> Iteration number 13 log-likelihood: -17278.761 #> Parameter vector: -2.784499807 0.617026860 -0.064561213 0.534608978 -3.174211159 0.128033659 -1.086471902 #> log-likelihood reduction: 0.000000060121238 #> Value of gradient at current step: #> 0.000543879327 0.004849594744 0.007409081517 0.000772957752 -0.000044801247 0.000519451071 0.000377932800 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.0011352061 #> ---- #> Iteration number 14 log-likelihood: -17278.761 #> Parameter vector: -2.784552191 0.617027265 -0.064556762 0.534613048 -3.174844941 0.128090828 -1.086426773 #> log-likelihood reduction: 0.000000018728315 #> Value of gradient at current step: #> -0.00030256413 -0.00269909107 -0.00412482670 -0.00043127033 0.00002466148 -0.00029328220 -0.00021122304 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.00063378216 #> ---- #> Iteration number 15 log-likelihood: -17278.761 #> Parameter vector: -2.784522964 0.617027040 -0.064559245 0.534610775 -3.174491334 0.128058932 -1.086451974 #> log-likelihood reduction: 0.00000000583168 #> Value of gradient at current step: #> 0.000169118291 0.001508137320 0.002304647175 0.000240720362 -0.000013855243 0.000162719756 0.000117791115 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.0003536072 #> ---- #> Value of analytically computed hessian at fitted regression coefficients: #> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] -5533.0360 -31139.1628 -58786.3824 -3921.3952 407.46348 23473.8262 #> [2,] -31139.1628 -179723.7217 -330742.8394 -22956.5461 4362.01544 1060.0139 #> [3,] -58786.3824 -330742.8394 -627035.9660 -41504.3671 185.81715 4362.0154 #> [4,] -3921.3952 -22956.5461 -41504.3671 -3921.3952 2193.72685 46845.5137 #> [5,] 407.4635 185.8172 46845.5137 1060.0139 -88.14760 -948.1115 #> [6,] 2193.7268 4362.0154 1971.9380 1971.9380 -948.11154 -10234.8910 #> [7,] 4362.0154 23473.8262 185.8172 185.8172 -28.97964 -312.6869 #> [,7] #> [1,] 1971.93804 #> [2,] 185.81715 #> [3,] 1971.93804 #> [4,] 185.81715 #> [5,] -28.97964 #> [6,] -312.68692 #> [7,] -28.97964 #> The matrix above has the following eigen values: #> -811159.7+0i -17207.51+0i -2161.919+9274.748i -2161.919-9274.748i 6057.218+0i 1581.239+0i -1513.504+0i # extract results # regression coefficient vector res$beta #> [1] -2.78452296 0.61702704 -0.06455925 0.53461077 -3.17449133 0.12805893 #> [7] -1.08645197 # check likelihood ll <- ztoigeom()$makeMinusLogLike(y = farmsubmission$TOTAL_SUB, X = X) -ll(res$beta) #> [1] -17278.76 # number of iterations res$iter #> [1] 15 # working weights head(res$weights) #> lambda mixed mixed omega #> [1,] 0.22688312 -0.03207963 -0.03207963 0.006351956 #> [2,] 0.66642253 -0.03199578 -0.03199578 0.006238854 #> [3,] 0.08469406 -0.01202233 -0.01202233 0.001899477 #> [4,] 0.14084340 -0.01990317 -0.01990317 0.003397031 #> [5,] 0.34099080 -0.04762290 -0.04762290 0.012045206 #> [6,] 0.42290801 -0.05782236 -0.05782236 0.018478738 # Compare with optim call res2 <- estimatePopsizeFit( y = farmsubmission$TOTAL_SUB, X = X, method = \"optim\", priorWeights = 1, family = ztoigeom(), coefStart = c(start, 0, 0, 0), control = controlMethod(verbose = 1, silent = TRUE), offset = cbind(rep(0, NROW(farmsubmission)), rep(0, NROW(farmsubmission))) ) #> Nelder-Mead direct search function minimizer #> function value for initial parameters = 18634.249443 #> Scaled convergence tolerance is 0.000186342 #> Stepsize computed as 0.082584 #> BUILD 8 20695.993313 18634.249443 #> LO-REDUCTION 10 20521.906450 18634.249443 #> REFLECTION 12 19390.030449 18203.536957 #> LO-REDUCTION 14 18936.678302 18203.536957 #> LO-REDUCTION 16 18749.996003 18203.536957 #> LO-REDUCTION 18 18737.148786 18203.536957 #> LO-REDUCTION 20 18718.703486 18203.536957 #> EXTENSION 22 18670.005025 17895.311480 #> LO-REDUCTION 24 18634.249443 17895.311480 #> LO-REDUCTION 26 18560.534560 17895.311480 #> EXTENSION 28 18449.746468 17588.420920 #> LO-REDUCTION 30 18295.895431 17588.420920 #> LO-REDUCTION 32 18222.396059 17588.420920 #> LO-REDUCTION 34 18203.536957 17588.420920 #> LO-REDUCTION 36 18087.422161 17588.420920 #> LO-REDUCTION 38 18005.031702 17588.420920 #> REFLECTION 40 18001.913029 17584.422405 #> REFLECTION 42 17895.311480 17527.021914 #> LO-REDUCTION 44 17780.944181 17527.021914 #> LO-REDUCTION 46 17712.559384 17527.021914 #> HI-REDUCTION 48 17643.578220 17527.021914 #> EXTENSION 50 17621.199586 17473.997274 #> LO-REDUCTION 52 17602.520321 17473.997274 #> HI-REDUCTION 54 17594.799573 17473.997274 #> LO-REDUCTION 56 17588.420920 17473.997274 #> LO-REDUCTION 58 17584.422405 17473.997274 #> EXTENSION 60 17556.846275 17447.303959 #> EXTENSION 62 17555.104630 17408.736552 #> LO-REDUCTION 64 17528.536402 17408.736552 #> LO-REDUCTION 66 17527.021914 17408.736552 #> EXTENSION 68 17511.009990 17375.624732 #> LO-REDUCTION 70 17506.001244 17375.624732 #> LO-REDUCTION 72 17473.997274 17375.624732 #> LO-REDUCTION 74 17459.682283 17375.624732 #> REFLECTION 76 17447.303959 17374.438952 #> EXTENSION 78 17431.820752 17359.678457 #> REFLECTION 80 17410.856537 17352.512930 #> LO-REDUCTION 82 17408.736552 17352.512930 #> LO-REDUCTION 84 17392.430571 17352.512930 #> LO-REDUCTION 86 17383.843739 17352.512930 #> LO-REDUCTION 88 17375.624732 17352.512930 #> HI-REDUCTION 90 17374.438952 17352.512930 #> REFLECTION 92 17364.440518 17351.391717 #> LO-REDUCTION 94 17361.269788 17351.391717 #> HI-REDUCTION 96 17359.678457 17351.391717 #> LO-REDUCTION 98 17359.333428 17351.391717 #> EXTENSION 100 17359.195000 17340.073149 #> LO-REDUCTION 102 17355.280449 17340.073149 #> LO-REDUCTION 104 17354.737924 17340.073149 #> LO-REDUCTION 106 17352.512930 17340.073149 #> LO-REDUCTION 108 17352.283989 17340.073149 #> EXTENSION 110 17351.931319 17334.816229 #> LO-REDUCTION 112 17351.391717 17334.816229 #> LO-REDUCTION 114 17349.077477 17334.816229 #> LO-REDUCTION 116 17346.861518 17334.816229 #> EXTENSION 118 17344.774811 17327.221865 #> LO-REDUCTION 120 17344.768718 17327.221865 #> EXTENSION 122 17340.363390 17314.895018 #> LO-REDUCTION 124 17340.073149 17314.895018 #> LO-REDUCTION 126 17337.014069 17314.895018 #> LO-REDUCTION 128 17336.611433 17314.895018 #> LO-REDUCTION 130 17334.816229 17314.895018 #> EXTENSION 132 17330.280767 17308.580216 #> LO-REDUCTION 134 17327.221865 17308.580216 #> LO-REDUCTION 136 17324.616040 17308.580216 #> REFLECTION 138 17320.961818 17307.339443 #> LO-REDUCTION 140 17320.314061 17307.339443 #> REFLECTION 142 17316.412981 17307.294606 #> LO-REDUCTION 144 17314.895018 17307.294606 #> HI-REDUCTION 146 17311.221319 17307.294606 #> REFLECTION 148 17310.240780 17305.855235 #> LO-REDUCTION 150 17309.024781 17305.855235 #> HI-REDUCTION 152 17308.580216 17305.855235 #> REFLECTION 154 17307.909389 17304.751271 #> LO-REDUCTION 156 17307.607430 17304.751271 #> HI-REDUCTION 158 17307.339443 17304.751271 #> EXTENSION 160 17307.294606 17303.969236 #> LO-REDUCTION 162 17306.726648 17303.969236 #> LO-REDUCTION 164 17306.486915 17303.969236 #> LO-REDUCTION 166 17306.013269 17303.969236 #> LO-REDUCTION 168 17305.855235 17303.969236 #> REFLECTION 170 17305.566500 17303.365745 #> HI-REDUCTION 172 17304.769833 17303.365745 #> LO-REDUCTION 174 17304.751271 17303.365745 #> EXTENSION 176 17304.679762 17302.760257 #> LO-REDUCTION 178 17304.415232 17302.760257 #> LO-REDUCTION 180 17304.272835 17302.760257 #> EXTENSION 182 17304.232531 17301.382173 #> LO-REDUCTION 184 17303.969236 17301.382173 #> LO-REDUCTION 186 17303.740306 17301.382173 #> LO-REDUCTION 188 17303.561302 17301.382173 #> LO-REDUCTION 190 17303.365745 17301.382173 #> REFLECTION 192 17303.285629 17301.216054 #> EXTENSION 194 17302.760257 17300.566315 #> EXTENSION 196 17302.374881 17299.438766 #> EXTENSION 198 17302.365881 17298.338665 #> EXTENSION 200 17301.538607 17296.617465 #> LO-REDUCTION 202 17301.386247 17296.617465 #> LO-REDUCTION 204 17301.382173 17296.617465 #> LO-REDUCTION 206 17301.216054 17296.617465 #> EXTENSION 208 17300.566315 17294.656203 #> EXTENSION 210 17299.438766 17292.415140 #> LO-REDUCTION 212 17298.338665 17292.415140 #> LO-REDUCTION 214 17297.787001 17292.415140 #> REFLECTION 216 17297.283737 17292.315917 #> REFLECTION 218 17296.776034 17290.819569 #> EXTENSION 220 17296.617465 17289.284957 #> LO-REDUCTION 222 17294.656203 17289.284957 #> LO-REDUCTION 224 17294.447369 17289.284957 #> LO-REDUCTION 226 17292.619840 17289.284957 #> REFLECTION 228 17292.415140 17289.050671 #> LO-REDUCTION 230 17292.315917 17289.050671 #> HI-REDUCTION 232 17290.819569 17289.050671 #> LO-REDUCTION 234 17290.333239 17289.050671 #> HI-REDUCTION 236 17290.198503 17289.050671 #> LO-REDUCTION 238 17290.030554 17289.050671 #> HI-REDUCTION 240 17289.707101 17289.050671 #> REFLECTION 242 17289.446684 17289.049956 #> REFLECTION 244 17289.402572 17288.762931 #> LO-REDUCTION 246 17289.314216 17288.762931 #> LO-REDUCTION 248 17289.284957 17288.762931 #> LO-REDUCTION 250 17289.237020 17288.755874 #> REFLECTION 252 17289.231432 17288.591829 #> LO-REDUCTION 254 17289.050671 17288.591829 #> HI-REDUCTION 256 17289.049956 17288.591829 #> LO-REDUCTION 258 17288.965069 17288.591829 #> LO-REDUCTION 260 17288.779011 17288.591829 #> LO-REDUCTION 262 17288.766114 17288.591829 #> REFLECTION 264 17288.762931 17288.553874 #> LO-REDUCTION 266 17288.760612 17288.553874 #> LO-REDUCTION 268 17288.755874 17288.553874 #> REFLECTION 270 17288.712718 17288.530741 #> LO-REDUCTION 272 17288.644400 17288.530741 #> EXTENSION 274 17288.613052 17288.437051 #> HI-REDUCTION 276 17288.606964 17288.437051 #> EXTENSION 278 17288.591829 17288.369092 #> LO-REDUCTION 280 17288.588782 17288.369092 #> LO-REDUCTION 282 17288.553874 17288.369092 #> EXTENSION 284 17288.542682 17288.275532 #> LO-REDUCTION 286 17288.531198 17288.275532 #> LO-REDUCTION 288 17288.530741 17288.275532 #> LO-REDUCTION 290 17288.469459 17288.275532 #> EXTENSION 292 17288.461014 17288.127850 #> LO-REDUCTION 294 17288.437051 17288.127850 #> LO-REDUCTION 296 17288.369092 17288.127850 #> LO-REDUCTION 298 17288.347618 17288.127850 #> LO-REDUCTION 300 17288.313219 17288.127850 #> EXTENSION 302 17288.295935 17288.071792 #> EXTENSION 304 17288.275532 17287.915686 #> LO-REDUCTION 306 17288.214888 17287.915686 #> LO-REDUCTION 308 17288.211032 17287.915686 #> EXTENSION 310 17288.173100 17287.842214 #> LO-REDUCTION 312 17288.141906 17287.842214 #> LO-REDUCTION 314 17288.127850 17287.842214 #> EXTENSION 316 17288.071792 17287.733682 #> EXTENSION 318 17288.054470 17287.663282 #> EXTENSION 320 17287.989272 17287.507624 #> LO-REDUCTION 322 17287.919537 17287.507624 #> LO-REDUCTION 324 17287.915686 17287.507624 #> LO-REDUCTION 326 17287.856498 17287.507624 #> REFLECTION 328 17287.842214 17287.490634 #> LO-REDUCTION 330 17287.733682 17287.490634 #> REFLECTION 332 17287.663282 17287.438068 #> LO-REDUCTION 334 17287.555894 17287.438068 #> LO-REDUCTION 336 17287.551441 17287.438068 #> REFLECTION 338 17287.547247 17287.422322 #> REFLECTION 340 17287.542002 17287.418701 #> REFLECTION 342 17287.507624 17287.368868 #> LO-REDUCTION 344 17287.490634 17287.368868 #> LO-REDUCTION 346 17287.444486 17287.368868 #> LO-REDUCTION 348 17287.438762 17287.368868 #> HI-REDUCTION 350 17287.438068 17287.368868 #> EXTENSION 352 17287.422322 17287.329022 #> EXTENSION 354 17287.418701 17287.274393 #> LO-REDUCTION 356 17287.391509 17287.274393 #> LO-REDUCTION 358 17287.381359 17287.274393 #> LO-REDUCTION 360 17287.375030 17287.274393 #> LO-REDUCTION 362 17287.371807 17287.274393 #> LO-REDUCTION 364 17287.368868 17287.274393 #> REFLECTION 366 17287.329022 17287.274032 #> LO-REDUCTION 368 17287.327098 17287.274032 #> EXTENSION 370 17287.322765 17287.246248 #> LO-REDUCTION 372 17287.316574 17287.246248 #> EXTENSION 374 17287.308329 17287.210843 #> LO-REDUCTION 376 17287.304794 17287.210843 #> LO-REDUCTION 378 17287.279608 17287.210843 #> REFLECTION 380 17287.274393 17287.210366 #> REFLECTION 382 17287.274032 17287.209122 #> LO-REDUCTION 384 17287.264744 17287.209122 #> REFLECTION 386 17287.246248 17287.183411 #> LO-REDUCTION 388 17287.223877 17287.183411 #> LO-REDUCTION 390 17287.214413 17287.183411 #> LO-REDUCTION 392 17287.213088 17287.183411 #> EXTENSION 394 17287.210843 17287.178084 #> LO-REDUCTION 396 17287.210366 17287.178084 #> LO-REDUCTION 398 17287.209122 17287.178084 #> REFLECTION 400 17287.197803 17287.172953 #> EXTENSION 402 17287.196607 17287.164829 #> LO-REDUCTION 404 17287.192398 17287.164829 #> EXTENSION 406 17287.183411 17287.148789 #> LO-REDUCTION 408 17287.183094 17287.148789 #> LO-REDUCTION 410 17287.181404 17287.148789 #> LO-REDUCTION 412 17287.178084 17287.148789 #> LO-REDUCTION 414 17287.173517 17287.148789 #> LO-REDUCTION 416 17287.172953 17287.148789 #> LO-REDUCTION 418 17287.165027 17287.148789 #> EXTENSION 420 17287.164829 17287.142664 #> LO-REDUCTION 422 17287.164534 17287.142664 #> EXTENSION 424 17287.161998 17287.140674 #> LO-REDUCTION 426 17287.160519 17287.140674 #> EXTENSION 428 17287.154476 17287.127103 #> LO-REDUCTION 430 17287.153672 17287.127103 #> LO-REDUCTION 432 17287.148789 17287.127103 #> LO-REDUCTION 434 17287.147540 17287.127103 #> LO-REDUCTION 436 17287.146752 17287.127103 #> LO-REDUCTION 438 17287.142664 17287.127103 #> LO-REDUCTION 440 17287.140674 17287.127103 #> REFLECTION 442 17287.138106 17287.127061 #> EXTENSION 444 17287.131886 17287.110761 #> LO-REDUCTION 446 17287.130480 17287.110761 #> LO-REDUCTION 448 17287.129088 17287.110761 #> LO-REDUCTION 450 17287.128934 17287.110761 #> LO-REDUCTION 452 17287.128336 17287.110761 #> LO-REDUCTION 454 17287.127103 17287.110761 #> LO-REDUCTION 456 17287.127061 17287.110761 #> EXTENSION 458 17287.122784 17287.105926 #> LO-REDUCTION 460 17287.121627 17287.105926 #> EXTENSION 462 17287.120146 17287.101582 #> LO-REDUCTION 464 17287.118771 17287.101582 #> LO-REDUCTION 466 17287.117855 17287.101582 #> EXTENSION 468 17287.117130 17287.090721 #> LO-REDUCTION 470 17287.110761 17287.090721 #> LO-REDUCTION 472 17287.108359 17287.090721 #> LO-REDUCTION 474 17287.107134 17287.090721 #> EXTENSION 476 17287.105926 17287.081849 #> LO-REDUCTION 478 17287.104244 17287.081849 #> EXTENSION 480 17287.101582 17287.080130 #> LO-REDUCTION 482 17287.096149 17287.080130 #> EXTENSION 484 17287.095793 17287.074699 #> LO-REDUCTION 486 17287.093227 17287.074699 #> LO-REDUCTION 488 17287.090721 17287.074699 #> LO-REDUCTION 490 17287.086551 17287.074699 #> REFLECTION 492 17287.086412 17287.074418 #> LO-REDUCTION 494 17287.081849 17287.074418 #> LO-REDUCTION 496 17287.080130 17287.074418 #> REFLECTION 498 17287.077153 17287.073950 #> REFLECTION 500 17287.076483 17287.072432 #> LO-REDUCTION 502 17287.075898 17287.072432 #> LO-REDUCTION 504 17287.075565 17287.072432 #> LO-REDUCTION 506 17287.075074 17287.072432 #> LO-REDUCTION 508 17287.074699 17287.072432 #> LO-REDUCTION 510 17287.074418 17287.072432 #> HI-REDUCTION 512 17287.073950 17287.072432 #> LO-REDUCTION 514 17287.073404 17287.072432 #> EXTENSION 516 17287.072984 17287.071689 #> LO-REDUCTION 518 17287.072957 17287.071689 #> EXTENSION 520 17287.072911 17287.071281 #> LO-REDUCTION 522 17287.072872 17287.071281 #> EXTENSION 524 17287.072566 17287.070932 #> LO-REDUCTION 526 17287.072496 17287.070932 #> REFLECTION 528 17287.072432 17287.070705 #> LO-REDUCTION 530 17287.072040 17287.070705 #> EXTENSION 532 17287.071689 17287.069928 #> LO-REDUCTION 534 17287.071602 17287.069928 #> LO-REDUCTION 536 17287.071281 17287.069928 #> LO-REDUCTION 538 17287.071085 17287.069928 #> REFLECTION 540 17287.070932 17287.069704 #> LO-REDUCTION 542 17287.070818 17287.069704 #> REFLECTION 544 17287.070705 17287.069688 #> REFLECTION 546 17287.070279 17287.069497 #> REFLECTION 548 17287.070113 17287.069324 #> HI-REDUCTION 550 17287.070091 17287.069324 #> LO-REDUCTION 552 17287.070013 17287.069324 #> REFLECTION 554 17287.069928 17287.069224 #> LO-REDUCTION 556 17287.069704 17287.069224 #> EXTENSION 558 17287.069688 17287.069019 #> EXTENSION 560 17287.069605 17287.068864 #> LO-REDUCTION 562 17287.069502 17287.068864 #> LO-REDUCTION 564 17287.069497 17287.068864 #> EXTENSION 566 17287.069324 17287.068482 #> LO-REDUCTION 568 17287.069285 17287.068482 #> EXTENSION 570 17287.069224 17287.068173 #> EXTENSION 572 17287.069019 17287.067727 #> LO-REDUCTION 574 17287.068980 17287.067727 #> EXTENSION 576 17287.068959 17287.066896 #> EXTENSION 578 17287.068864 17287.065841 #> LO-REDUCTION 580 17287.068771 17287.065841 #> EXTENSION 582 17287.068482 17287.064747 #> LO-REDUCTION 584 17287.068173 17287.064747 #> EXTENSION 586 17287.067970 17287.063322 #> LO-REDUCTION 588 17287.067727 17287.063322 #> EXTENSION 590 17287.066896 17287.061580 #> LO-REDUCTION 592 17287.066709 17287.061580 #> LO-REDUCTION 594 17287.066510 17287.061580 #> EXTENSION 596 17287.065841 17287.057767 #> LO-REDUCTION 598 17287.064747 17287.057767 #> EXTENSION 600 17287.063788 17287.053859 #> LO-REDUCTION 602 17287.063322 17287.053859 #> LO-REDUCTION 604 17287.062792 17287.053859 #> LO-REDUCTION 606 17287.062126 17287.053859 #> EXTENSION 608 17287.061580 17287.050184 #> EXTENSION 610 17287.058435 17287.045782 #> LO-REDUCTION 612 17287.057767 17287.045782 #> LO-REDUCTION 614 17287.057359 17287.045782 #> EXTENSION 616 17287.057193 17287.037166 #> LO-REDUCTION 618 17287.053911 17287.037166 #> LO-REDUCTION 620 17287.053859 17287.037166 #> LO-REDUCTION 622 17287.050184 17287.037166 #> LO-REDUCTION 624 17287.048790 17287.037166 #> EXTENSION 626 17287.046966 17287.027006 #> LO-REDUCTION 628 17287.045782 17287.027006 #> EXTENSION 630 17287.041585 17287.015525 #> LO-REDUCTION 632 17287.037975 17287.015525 #> LO-REDUCTION 634 17287.037776 17287.015525 #> LO-REDUCTION 636 17287.037537 17287.015525 #> EXTENSION 638 17287.037166 17287.002045 #> LO-REDUCTION 640 17287.029130 17287.002045 #> LO-REDUCTION 642 17287.027006 17287.002045 #> EXTENSION 644 17287.021112 17286.982852 #> LO-REDUCTION 646 17287.020505 17286.982852 #> LO-REDUCTION 648 17287.020369 17286.982852 #> EXTENSION 650 17287.015525 17286.962921 #> LO-REDUCTION 652 17287.006234 17286.962921 #> LO-REDUCTION 654 17287.003316 17286.962921 #> LO-REDUCTION 656 17287.002045 17286.962921 #> LO-REDUCTION 658 17286.999773 17286.962921 #> EXTENSION 660 17286.994995 17286.933690 #> LO-REDUCTION 662 17286.982852 17286.933690 #> LO-REDUCTION 664 17286.977870 17286.933690 #> LO-REDUCTION 666 17286.975300 17286.933690 #> LO-REDUCTION 668 17286.974307 17286.933690 #> EXTENSION 670 17286.969127 17286.897589 #> LO-REDUCTION 672 17286.962921 17286.897589 #> LO-REDUCTION 674 17286.956414 17286.897589 #> EXTENSION 676 17286.943420 17286.853826 #> LO-REDUCTION 678 17286.937677 17286.853826 #> LO-REDUCTION 680 17286.935539 17286.853826 #> EXTENSION 682 17286.933690 17286.809961 #> LO-REDUCTION 684 17286.911841 17286.809961 #> LO-REDUCTION 686 17286.906427 17286.809961 #> EXTENSION 688 17286.897589 17286.764565 #> EXTENSION 690 17286.877846 17286.704552 #> LO-REDUCTION 692 17286.872431 17286.704552 #> EXTENSION 694 17286.853826 17286.604256 #> LO-REDUCTION 696 17286.822022 17286.604256 #> LO-REDUCTION 698 17286.811029 17286.604256 #> LO-REDUCTION 700 17286.809961 17286.604256 #> EXTENSION 702 17286.764565 17286.493497 #> LO-REDUCTION 704 17286.736274 17286.493497 #> EXTENSION 706 17286.704552 17286.355870 #> LO-REDUCTION 708 17286.657383 17286.355870 #> LO-REDUCTION 710 17286.628318 17286.355870 #> EXTENSION 712 17286.621506 17286.141094 #> LO-REDUCTION 714 17286.604256 17286.141094 #> LO-REDUCTION 716 17286.503365 17286.141094 #> LO-REDUCTION 718 17286.493497 17286.141094 #> EXTENSION 720 17286.414390 17285.877458 #> LO-REDUCTION 722 17286.366513 17285.877458 #> LO-REDUCTION 724 17286.355870 17285.877458 #> LO-REDUCTION 726 17286.251140 17285.877458 #> EXTENSION 728 17286.244105 17285.662233 #> EXTENSION 730 17286.223061 17285.393569 #> LO-REDUCTION 732 17286.141094 17285.393569 #> LO-REDUCTION 734 17285.992524 17285.393569 #> LO-REDUCTION 736 17285.964793 17285.393569 #> EXTENSION 738 17285.889261 17284.967393 #> LO-REDUCTION 740 17285.877458 17284.967393 #> EXTENSION 742 17285.662233 17284.823201 #> EXTENSION 744 17285.587027 17284.571260 #> EXTENSION 746 17285.430175 17284.208648 #> LO-REDUCTION 748 17285.411444 17284.208648 #> LO-REDUCTION 750 17285.393569 17284.208648 #> LO-REDUCTION 752 17285.061522 17284.208648 #> LO-REDUCTION 754 17284.967393 17284.208648 #> LO-REDUCTION 756 17284.823201 17284.208648 #> LO-REDUCTION 758 17284.663334 17284.208648 #> EXTENSION 760 17284.571260 17284.082158 #> EXTENSION 762 17284.471298 17283.933635 #> REFLECTION 764 17284.370237 17283.918499 #> LO-REDUCTION 766 17284.326906 17283.918499 #> LO-REDUCTION 768 17284.242090 17283.918499 #> LO-REDUCTION 770 17284.232223 17283.918499 #> EXTENSION 772 17284.208648 17283.684327 #> HI-REDUCTION 774 17284.082158 17283.684327 #> LO-REDUCTION 776 17284.006206 17283.684327 #> LO-REDUCTION 778 17283.954602 17283.684327 #> LO-REDUCTION 780 17283.943643 17283.684327 #> EXTENSION 782 17283.941150 17283.629046 #> LO-REDUCTION 784 17283.933635 17283.629046 #> EXTENSION 786 17283.918499 17283.432835 #> LO-REDUCTION 788 17283.855866 17283.432835 #> LO-REDUCTION 790 17283.737787 17283.432835 #> EXTENSION 792 17283.707141 17283.177089 #> LO-REDUCTION 794 17283.691961 17283.177089 #> LO-REDUCTION 796 17283.684327 17283.177089 #> LO-REDUCTION 798 17283.629046 17283.177089 #> EXTENSION 800 17283.480788 17283.019801 #> EXTENSION 802 17283.464836 17282.857567 #> LO-REDUCTION 804 17283.432835 17282.857567 #> LO-REDUCTION 806 17283.427379 17282.857567 #> REFLECTION 808 17283.273719 17282.810344 #> LO-REDUCTION 810 17283.192011 17282.810344 #> EXTENSION 812 17283.177089 17282.773026 #> LO-REDUCTION 814 17283.100216 17282.773026 #> EXTENSION 816 17283.019801 17282.431349 #> LO-REDUCTION 818 17282.924383 17282.431349 #> LO-REDUCTION 820 17282.882981 17282.431349 #> LO-REDUCTION 822 17282.857567 17282.431349 #> LO-REDUCTION 824 17282.826993 17282.431349 #> EXTENSION 826 17282.810344 17282.134774 #> LO-REDUCTION 828 17282.773026 17282.134774 #> LO-REDUCTION 830 17282.673630 17282.134774 #> EXTENSION 832 17282.551561 17281.917158 #> LO-REDUCTION 834 17282.507799 17281.917158 #> LO-REDUCTION 836 17282.441034 17281.917158 #> EXTENSION 838 17282.431349 17281.805083 #> EXTENSION 840 17282.328334 17281.485386 #> LO-REDUCTION 842 17282.207399 17281.485386 #> EXTENSION 844 17282.134774 17281.177471 #> LO-REDUCTION 846 17281.971962 17281.177471 #> LO-REDUCTION 848 17281.930907 17281.177471 #> LO-REDUCTION 850 17281.917158 17281.177471 #> LO-REDUCTION 852 17281.805083 17281.177471 #> LO-REDUCTION 854 17281.637799 17281.177471 #> LO-REDUCTION 856 17281.542150 17281.177471 #> LO-REDUCTION 858 17281.485386 17281.177471 #> LO-REDUCTION 860 17281.450381 17281.177471 #> EXTENSION 862 17281.448390 17280.945651 #> LO-REDUCTION 864 17281.369614 17280.945651 #> LO-REDUCTION 866 17281.303934 17280.945651 #> EXTENSION 868 17281.250802 17280.800450 #> LO-REDUCTION 870 17281.238533 17280.800450 #> LO-REDUCTION 872 17281.223261 17280.800450 #> EXTENSION 874 17281.177471 17280.488585 #> LO-REDUCTION 876 17281.024470 17280.488585 #> LO-REDUCTION 878 17280.950337 17280.488585 #> LO-REDUCTION 880 17280.945651 17280.488585 #> LO-REDUCTION 882 17280.939912 17280.488585 #> LO-REDUCTION 884 17280.816046 17280.488585 #> LO-REDUCTION 886 17280.800450 17280.488585 #> REFLECTION 888 17280.738456 17280.447101 #> REFLECTION 890 17280.664631 17280.390325 #> LO-REDUCTION 892 17280.577249 17280.390325 #> LO-REDUCTION 894 17280.566783 17280.390325 #> LO-REDUCTION 896 17280.538991 17280.390325 #> LO-REDUCTION 898 17280.511395 17280.390325 #> LO-REDUCTION 900 17280.488585 17280.390325 #> LO-REDUCTION 902 17280.459344 17280.390325 #> LO-REDUCTION 904 17280.447101 17280.390325 #> REFLECTION 906 17280.446459 17280.382631 #> LO-REDUCTION 908 17280.422497 17280.382631 #> LO-REDUCTION 910 17280.420917 17280.381469 #> LO-REDUCTION 912 17280.406656 17280.381469 #> LO-REDUCTION 914 17280.406429 17280.381469 #> LO-REDUCTION 916 17280.394455 17280.379401 #> LO-REDUCTION 918 17280.390325 17280.379401 #> HI-REDUCTION 920 17280.388261 17280.379401 #> REFLECTION 922 17280.387657 17280.375301 #> LO-REDUCTION 924 17280.387214 17280.375301 #> REFLECTION 926 17280.382631 17280.374067 #> HI-REDUCTION 928 17280.382496 17280.374067 #> REFLECTION 930 17280.381469 17280.373924 #> LO-REDUCTION 932 17280.379656 17280.373924 #> HI-REDUCTION 934 17280.379401 17280.373924 #> LO-REDUCTION 936 17280.377978 17280.373666 #> REFLECTION 938 17280.377712 17280.372196 #> EXTENSION 940 17280.375615 17280.367543 #> LO-REDUCTION 942 17280.375301 17280.367543 #> LO-REDUCTION 944 17280.374265 17280.367543 #> LO-REDUCTION 946 17280.374067 17280.367543 #> LO-REDUCTION 948 17280.373924 17280.367543 #> REFLECTION 950 17280.373666 17280.366638 #> REFLECTION 952 17280.372196 17280.366393 #> LO-REDUCTION 954 17280.370941 17280.366393 #> EXTENSION 956 17280.369039 17280.360078 #> LO-REDUCTION 958 17280.368943 17280.360078 #> LO-REDUCTION 960 17280.368258 17280.360078 #> LO-REDUCTION 962 17280.367543 17280.360078 #> LO-REDUCTION 964 17280.366638 17280.360078 #> LO-REDUCTION 966 17280.366395 17280.360078 #> EXTENSION 968 17280.366393 17280.358415 #> EXTENSION 970 17280.364882 17280.356231 #> EXTENSION 972 17280.364704 17280.352703 #> EXTENSION 974 17280.361998 17280.350130 #> EXTENSION 976 17280.360738 17280.346336 #> LO-REDUCTION 978 17280.360395 17280.346336 #> LO-REDUCTION 980 17280.360078 17280.346336 #> REFLECTION 982 17280.358415 17280.344675 #> LO-REDUCTION 984 17280.356231 17280.344675 #> LO-REDUCTION 986 17280.352703 17280.344675 #> LO-REDUCTION 988 17280.350130 17280.344675 #> LO-REDUCTION 990 17280.349130 17280.344675 #> EXTENSION 992 17280.348501 17280.341423 #> LO-REDUCTION 994 17280.347252 17280.341423 #> LO-REDUCTION 996 17280.346336 17280.341423 #> LO-REDUCTION 998 17280.346022 17280.341423 #> LO-REDUCTION 1000 17280.345873 17280.341423 #> Exiting from Nelder Mead minimizer #> 1002 function evaluations used # extract results # regression coefficient vector res2$beta #> [1] -2.64077894 0.62582753 -0.08293688 0.53247068 -0.12437312 -0.16298836 #> [7] -1.10550227 # check likelihood -ll(res2$beta) #> [1] -17280.34 # number of calls to log lik function # since optim does not return the number of # iterations res2$iter #> function gradient #> 1002 NA # optim does not calculated working weights head(res2$weights) #> [1] 1 # }"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/farmsubmission.html","id":null,"dir":"Reference","previous_headings":"","what":"British farm submissions data — farmsubmission","title":"British farm submissions data — farmsubmission","text":"Data British animal farms submissions AHVLA. British farms able submit samples AHVLA cause death animal determined private veterinary surgeon decides submit , unless notifiable disease suspected submission required. data set contains information farms. submissions farms included data frame carcasses also blood samples etc.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/farmsubmission.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"British farm submissions data — farmsubmission","text":"","code":"data(\"farmsubmission\")"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/farmsubmission.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"British farm submissions data — farmsubmission","text":"Data frame 12,036 rows 4 columns. TOTAL_SUB Number submissions animal material. log_size Numerical value equal logarithm size farm. log_distance Numerical value equal logarithm distance nearest AHVLA center. C_TYPE Factor describing type activity farm animals used . Either Dairy Beef","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/farmsubmission.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"British farm submissions data — farmsubmission","text":"data set description provided publication: Böhning, D., Vidal Diez, ., Lerdsuwansri, R., Viwatwongkasem, C., Arnold, M. (2013). \"generalization Chao's estimator covariate information\". Biometrics, 69(4), 1033-1042. doi:10.1111/biom.12082","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/marginalFreq.html","id":null,"dir":"Reference","previous_headings":"","what":"Observed and fitted marginal frequencies — marginalFreq","title":"Observed and fitted marginal frequencies — marginalFreq","text":"function given fitted singleR class object computed marginal frequencies sum probability density functions unit data point .e. kth element marginal frequency table given _j=1^N_obsP(Y_j=k|_j). k=0 (specified call) computed N-N_obs f_0 assumed unobserved part studied population. frequencies useful diagnostics count data regression, assessment fit.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/marginalFreq.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Observed and fitted marginal frequencies — marginalFreq","text":"","code":"marginalFreq( object, includeones = TRUE, includezeros = TRUE, onecount = NULL, range, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/marginalFreq.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Observed and fitted marginal frequencies — marginalFreq","text":"object object singleR class. includeones logical value indicating whether include estimated number zero counts. includezeros logical value indicating whether include one counts zero-one truncated models. onecount numeric value indicating number one counts null trcount object assumed number one counts. range optional argument specifying range selected Y values. ... currently nothing.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/marginalFreq.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Observed and fitted marginal frequencies — marginalFreq","text":"list observed name fitted model family degrees freedom observed fitted marginal frequencies.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/marginalFreq.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Observed and fitted marginal frequencies — marginalFreq","text":"Piotr Chlebicki","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/netherlandsimmigrant.html","id":null,"dir":"Reference","previous_headings":"","what":"Data on immigration in the Netherlands — netherlandsimmigrant","title":"Data on immigration in the Netherlands — netherlandsimmigrant","text":"data set contains information immigrants four cities (Amsterdam, Rotterdam, Hague Utrecht) Netherlands staying country illegally 1995 appeared police records year.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/netherlandsimmigrant.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Data on immigration in the Netherlands — netherlandsimmigrant","text":"","code":"data(\"netherlandsimmigrant\")"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/netherlandsimmigrant.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Data on immigration in the Netherlands — netherlandsimmigrant","text":"Data frame 1,880 rows 5 columns. capture Number times person captured police. gender Factor describing gender apprehended person. age Factor describing age apprehended person. Either bellow 40 years old. reason Factor describing reason apprehended police either illegal stay Netherlands reasons. nation Factor nation origin captured person. 6 levels variable: \"American Australia\", \"Asia\", \"North Africa\", \"Rest Africa\", \"Surinam\", \"Turkey\".","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/netherlandsimmigrant.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Data on immigration in the Netherlands — netherlandsimmigrant","text":"data set description provided publication: van Der Heijden, P. G., Bustami, R., Cruyff, M. J., Engbersen, G., Van Houwelingen, H. C. (2003). Point interval estimation population size using truncated Poisson regression model. Statistical Modelling, 3(4), 305-322. doi:10.1191/1471082X03st057oa","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/plot.singleRStaticCountData.html","id":null,"dir":"Reference","previous_headings":"","what":"Diagnostic plots for regression and population size estimation — plot.singleRStaticCountData","title":"Diagnostic plots for regression and population size estimation — plot.singleRStaticCountData","text":"Simple diagnostic plots singleRStaticCountData class objects.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/plot.singleRStaticCountData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Diagnostic plots for regression and population size estimation — plot.singleRStaticCountData","text":"","code":"# S3 method for class 'singleRStaticCountData' plot( x, plotType = c(\"qq\", \"marginal\", \"fitresid\", \"bootHist\", \"rootogram\", \"dfpopContr\", \"dfpopBox\", \"scaleLoc\", \"cooks\", \"hatplot\", \"strata\"), confIntStrata = c(\"normal\", \"logNormal\"), histKernels = TRUE, dfpop, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/plot.singleRStaticCountData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Diagnostic plots for regression and population size estimation — plot.singleRStaticCountData","text":"x object singleRStaticCountData class. plotType character parameter (default \"qq\") specifying type plot made. following list presents briefly explains possible type plots: qq – quantile-quantile plot pearson residuals (standardized pearson residuals available model) .e. empirical quantiles residuals plotted theoretical quantiles standard distribution. marginal – plot made matplot fitted observed marginal frequencies labels. fitresid – Plot fitted linear predictors (standardized) pearson residuals. bootHist – Simple histogram statistics obtained bootstrapping (one performed statistics saved). rootogram – Rootogram, full explanation see: Kleiber Zeileis Visualizing Count Data Regressions Using Rootograms (2016), short barplot height square root observed marginal frequencies adjusted difference square root observed fitted marginal frequencies connected line representing fitted marginal frequencies. less difference 0 line beginning bar accurate fitt produced model. dfpopContr – Plot dfpopsize unit contribution. plot y = x line .e. deletion effect removing unit model effect regression coefficients. away observation line influential . dfpopBox – Boxplot dfpopsize getting general idea distribution \"influence\" unit population size estimate. scaleLoc – scale - location plot .e. square root absolute values (standardized) pearson residuals linear predictors column linear predictors. cooks – Plot cooks distance detecting influential observations. hatplot – Plot hat values linear predictor detecting influential observations. strata – Plot confidence intervals point estimates strata provided ... argument confIntStrata confidence interval type use strata plot. Currently supported values \"normal\" \"logNormal\". histKernels logical value indicating whether add density lines histogram. dfpop TODO ... additional optional arguments passed following functions: plotType = \"bootHist\" graphics::hist – x, main, xlab, ylab parameters fixed. plotType = \"rootogram\" graphics::barplot – height, offset, ylab, xlab, ylim parameters fixed. graphics::lines – x, y, pch, type, lwd, col parameters fixed. plotType = \"dfpopContr\" dfpopsize – model, observedPop parameters fixed. plot.default – x, y, xlab, main parameters fixed. plotType = \"dfpopBox\" dfpopsize – model, observedPop parameters fixed. graphics::boxplot – x, ylab, main parameters fixed. plotType = \"scaleLoc\" plot.default – x, y, xlab, ylab, main, sub parameters fixed. plotType = \"fitresid\" plot.default – x, y, xlab, ylab, main, sub parameters fixed. plotType = \"cooks\" plot.default – x, xlab, ylab, main parameters fixed. plotType = \"hatplot\" hatvalues.singleRStaticCountData plot.default – x, xlab, ylab, main parameters fixed. plotType = \"strata\" stratifyPopsize.singleRStaticCountData","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/plot.singleRStaticCountData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Diagnostic plots for regression and population size estimation — plot.singleRStaticCountData","text":"return value plot made.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/plot.singleRStaticCountData.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Diagnostic plots for regression and population size estimation — plot.singleRStaticCountData","text":"Piotr Chlebicki","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/popSizeEst.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract population size estimation results — popSizeEst","title":"Extract population size estimation results — popSizeEst","text":"extractor function singleRStaticCountData method extracting important information regarding pop size estimate.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/popSizeEst.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract population size estimation results — popSizeEst","text":"","code":"popSizeEst(object, ...) # S3 method for class 'singleRStaticCountData' popSizeEst(object, ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/popSizeEst.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract population size estimation results — popSizeEst","text":"object object population size estimates. ... additional optional arguments, currently used singleRStaticCountData class method.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/popSizeEst.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract population size estimation results — popSizeEst","text":"object class popSizeEstResults containing population size estimation results.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/predict.singleRStaticCountData.html","id":null,"dir":"Reference","previous_headings":"","what":"Predict method for singleRStaticCountData class — predict.singleRStaticCountData","title":"Predict method for singleRStaticCountData class — predict.singleRStaticCountData","text":"method predict function, works analogous predict.glm gives possibility get standard errors mean/distribution parameters directly get pop size estimates new data.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/predict.singleRStaticCountData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predict method for singleRStaticCountData class — predict.singleRStaticCountData","text":"","code":"# S3 method for class 'singleRStaticCountData' predict( object, newdata, type = c(\"response\", \"link\", \"mean\", \"popSize\", \"contr\"), se.fit = FALSE, na.action = NULL, weights, cov, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/predict.singleRStaticCountData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predict method for singleRStaticCountData class — predict.singleRStaticCountData","text":"object object singleRStaticCountData class. newdata optional data.frame containing new data. type type prediction required, possible values : \"response\"– matrix containing estimated distributions parameters. \"link\" – matrix linear predictors. \"mean\" – fitted values Y Y|Y>0. \"contr\" – inverse probability weights (named observation contribution population size estimate). \"popSize\" – population size estimation. Note results call redoPopEstimation usually better call function directly. default set \"response\". se.fit logical value indicating whether standard errors computed. matters type \"response\", \"mean\", \"link\". na.action nothing yet. weights optional vector weights type \"contr\", \"popSize\". cov optional matrix function character specifying either covariance matrix function compute covariance matrix. default vcov.singleRStaticCountData can set e.g. vcovHC. ... arguments passed functions, now affects vcov.singleRStaticCountData method cov function.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/predict.singleRStaticCountData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Predict method for singleRStaticCountData class — predict.singleRStaticCountData","text":"Depending type argument one \"response\", \"link\", \"mean\" matrix fitted values possibly standard errors se.fit argument set TRUE, type set \"contr\" vector inverses probabilities, finally \"popSize\" object class popSizeEstResults methods containing population size estimation results.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/predict.singleRStaticCountData.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Predict method for singleRStaticCountData class — predict.singleRStaticCountData","text":"Standard errors computed assumption regression coefficients asymptotically normally distributed, assumption holds linear predictors .e. row =X_vlm asymptotically normally distributed variances expressed well known formula. mean distribution parameters differentiable functions asymptotically normally distributed variables therefore variances can computed using (multivariate) delta method.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/redoPopEstimation.html","id":null,"dir":"Reference","previous_headings":"","what":"Updating population size estimation results — redoPopEstimation","title":"Updating population size estimation results — redoPopEstimation","text":"function applies post-hoc procedures taken (heteroscedastic consistent covariance matrix estimation bias reduction) population size estimation standard error estimation.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/redoPopEstimation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Updating population size estimation results — redoPopEstimation","text":"","code":"redoPopEstimation(object, newdata, ...) # S3 method for class 'singleRStaticCountData' redoPopEstimation( object, newdata, cov, weights, coef, control, popVar, offset, weightsAsCounts, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/redoPopEstimation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Updating population size estimation results — redoPopEstimation","text":"object object update population size estimation results done. newdata optional data.frame new data pop size estimation. ... additional optional arguments, currently used singleRStaticCountData class method. cov updated covariance matrix estimate. weights optional vector weights use population size estimation. coef optional vector coefficients regression base population size estimation. missing set coef(object). control similar controlPopVar estimatePopsize(). missing set controls provided call object. popVar similar popVar estimatePopsize(). missing set \"analytic\". offset offset argument new data weightsAsCounts singleRStaticCountData method used specify whether weights treated number occurrences rows data","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/redoPopEstimation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Updating population size estimation results — redoPopEstimation","text":"object class popSizeEstResults containing updated population size estimation results.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/redoPopEstimation.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Updating population size estimation results — redoPopEstimation","text":"non specified arguments inferred object","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/redoPopEstimation.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Updating population size estimation results — redoPopEstimation","text":"","code":"# Create simple model Model <- estimatePopsize( formula = capture ~ nation + gender, data = netherlandsimmigrant, model = ztpoisson, method = \"IRLS\" ) # Apply heteroscedasticity consistent covariance matrix estimation require(sandwich) #> Loading required package: sandwich cov <- vcovHC(Model, type = \"HC3\") summary(Model, cov = cov, popSizeEst = redoPopEstimation(Model, cov = cov)) #> #> Call: #> estimatePopsize.default(formula = capture ~ nation + gender, #> data = netherlandsimmigrant, model = ztpoisson, method = \"IRLS\") #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.479668 -0.479668 -0.351833 0.000449 -0.225717 14.058858 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.3977 0.2553 -5.475 4.37e-08 *** #> nationAsia -1.0560 0.3940 -2.680 0.00736 ** #> nationNorth Africa 0.2327 0.2399 0.970 0.33200 #> nationRest of Africa -0.8864 0.3514 -2.523 0.01164 * #> nationSurinam -2.3519 1.0273 -2.289 0.02205 * #> nationTurkey -1.6845 0.6110 -2.757 0.00583 ** #> gendermale 0.3833 0.2014 1.904 0.05695 . #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 1718.993 #> BIC: 1757.766 #> Residual deviance: 1136.645 #> #> Log-likelihood: -852.4963 on 1873 Degrees of freedom #> Number of iterations: 8 #> ----------------------- #> Population size estimation results: #> Point estimate 11879.92 #> Observed proportion: 15.8% (N obs = 1880) #> Std. Error 2531.196 #> 95% CI for the population size: #> lowerBound upperBound #> normal 6918.872 16840.98 #> logNormal 8015.862 18177.38 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 11.16325 27.17206 #> logNormal 10.34252 23.45350 # Compare to results with usual covariance matrix estimation summary(Model) #> #> Call: #> estimatePopsize.default(formula = capture ~ nation + gender, #> data = netherlandsimmigrant, model = ztpoisson, method = \"IRLS\") #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.479668 -0.479668 -0.351833 0.000449 -0.225717 14.058858 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.3977 0.2146 -6.514 7.33e-11 *** #> nationAsia -1.0560 0.3016 -3.501 0.000464 *** #> nationNorth Africa 0.2327 0.1939 1.200 0.230002 #> nationRest of Africa -0.8864 0.3009 -2.946 0.003224 ** #> nationSurinam -2.3519 1.0137 -2.320 0.020337 * #> nationTurkey -1.6845 0.6029 -2.794 0.005203 ** #> gendermale 0.3833 0.1630 2.352 0.018686 * #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 1718.993 #> BIC: 1757.766 #> Residual deviance: 1136.645 #> #> Log-likelihood: -852.4963 on 1873 Degrees of freedom #> Number of iterations: 8 #> ----------------------- #> Population size estimation results: #> Point estimate 11879.92 #> Observed proportion: 15.8% (N obs = 1880) #> Std. Error 2448.792 #> 95% CI for the population size: #> lowerBound upperBound #> normal 7080.380 16679.47 #> logNormal 8111.333 17927.69 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 11.27134 26.55225 #> logNormal 10.48657 23.17745 ## get confidence interval with larger significance level redoPopEstimation(Model, control = controlPopVar(alpha = .000001)) #> Point estimate: 11879.92 #> Variance: 5996583 #> 99.9999% confidence intervals: #> lowerBound upperBound #> normal 1880.000 23858.53 #> logNormal 4951.313 34438.87"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":null,"dir":"Reference","previous_headings":"","what":"Regression diagnostics in singleRcapture — regDiagSingleR","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"List regression diagnostics implemented singleRStaticCountData class. Functions either require changes glm class relevant context singleRcapture omitted.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"","code":"dfpopsize(model, ...) # S3 method for class 'singleRStaticCountData' dfpopsize(model, dfbeta = NULL, ...) # S3 method for class 'singleRStaticCountData' dfbeta(model, maxitNew = 1, trace = FALSE, cores = 1, ...) # S3 method for class 'singleRStaticCountData' hatvalues(model, ...) # S3 method for class 'singleRStaticCountData' residuals( object, type = c(\"pearson\", \"pearsonSTD\", \"response\", \"working\", \"deviance\", \"all\"), ... ) # S3 method for class 'singleRStaticCountData' cooks.distance(model, ...) # S3 method for class 'singleRStaticCountData' sigma(object, ...) # S3 method for class 'singleRStaticCountData' influence(model, do.coef = FALSE, ...) # S3 method for class 'singleRStaticCountData' rstudent(model, ...) # S3 method for class 'singleRStaticCountData' rstandard(model, type = c(\"deviance\", \"pearson\"), ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"model, object object singleRStaticCountData class. ... arguments passed methods. Notably dfpopsize.singleRStaticCountData calls dfbeta.singleRStaticCountData dfbeta argument provided controlMethod called dfbeta method. dfbeta dfbeta already obtained possible pass function need computed second time. maxitNew maximal number iterations regressions starting points data specified call model removal k'th row. default 1. trace logical value specifying whether tracking results cores > 1 result progress bar created. cores number processor cores used, number greater 1 activates code designed doParallel, foreach parallel packages. Note now using parallel computing makes tracing impossible trace parameter ignored case. type type residual return. .coef logical indicating dfbeta computation influence done. FALSE default.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"hatvalues – matrix n rows p columns n number observations data p number regression parameters. dfpopsize – vector k'th element corresponds difference point estimate population size estimation full data set point estimate population size estimation removal k'th unit data set. dfbeta – matrix n rows p observations p number units data p number regression parameters. K'th row matrix corresponds -_-k _-k vector estimates regression parameters removal k'th row data. cooks.distance – matrix single columns values cooks distance every unit model.matrix residuals.singleRStaticCountData – data.frame chosen residuals.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"dfpopsize dfbeta closely related. dfbeta fits regression removing specific row data returns difference regression coefficients estimated full data set data set obtained deletion row, repeats procedure every unit present data.dfpopsize population size estimation utilizing coefficients computed dfbeta. cooks.distance implemented (now) models single linear predictor works exactly like method glm class. sigma computes standard errors predicted means. Returns matrix two columns first truncated mean non-truncated mean. residuals.singleRStaticCountData (can abbreviated resid) works like residuals.glm exception : \"pearson\" – returns non standardized residuals. \"pearsonSTD\" – currently defined single predictors models extended models near future, families one distribution parameter multivariate residual. \"response\" – returns residuals computed truncated non truncated fitted value. \"working\" – possibly multivariate one linear predictor present. \"deviance\" – yet defined families singleRmodels() e.g. negative binomial based methods. \"\" – returns available residual types. hatvalues.singleRStaticCountData method singleRStaticCountData class extracting diagonal elements projection matrix. Since singleRcapture supports regular glm's also vglm's hatvalues returns matrix number columns corresponding number linear predictors model, kth column corresponds elements diagonal projection matrix associated kth linear predictor. glm's W^12X (X^TWX)^-1 X^TW^12 : W=E(Diag (^2^T )) X model (lm) matrix. vglm's present package instead : X_vlm (X_vlm^TWX_vlm)^-1 X_vlm^TW : W = E(bmatrix Diag(^2_1^T_1) & Diag(^2_1^T_2) & & Diag(^2_1^T_p) Diag(^2_2^T_1) & Diag(^2_2^T_2) & & Diag(^2_2^T_p) & & & Diag(^2_p^T_1) & Diag(^2_p^T_2) & & Diag(^2_p^T_p) bmatrix) block matrix constructed taking expected value diagonal matrixes corresponding second derivatives respect linear predictor (mixed derivatives) X_vlm model (vlm) matrix constructed using specifications controlModel call estimatePopsize. influence works like glm counterpart computing important influence measures.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"","code":"# \\donttest{ # For singleRStaticCountData class # Get simple model Model <- estimatePopsize( formula = capture ~ nation + age + gender, data = netherlandsimmigrant, model = ztpoisson, method = \"IRLS\" ) # Get dfbeta dfb <- dfbeta(Model) # The dfpopsize results are obtained via (It is also possible to not provide # dfbeta then they will be computed manually): res <- dfpopsize(Model, dfbeta = dfb) summary(res) #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -4236.412 2.664 2.664 5.448 17.284 117.448 plot(res) # see vaious types of residuals: head(resid(Model, \"all\")) #> lambda truncatedResponse nontruncatedResponse pearson pearsonSTD #> 1 -0.9328875 -0.25364898 0.5294668 -0.4864422 -0.4867283 #> 2 -0.9328875 -0.25364898 0.5294668 -0.4864422 -0.4867283 #> 3 -0.9328875 -0.25364898 0.5294668 -0.4864422 -0.4867283 #> 4 -0.9791760 -0.06666172 0.8695135 -0.2554869 -0.2559964 #> 5 -0.9791760 -0.06666172 0.8695135 -0.2554869 -0.2559964 #> 6 2.7449807 0.74635102 1.5294668 1.4313347 1.4321768 #> deviance #> 1 -0.6992491 #> 2 -0.6992491 #> 3 -0.6992491 #> 4 -0.3631875 #> 5 -0.3631875 #> 6 1.0619767 # }"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/simulate.html","id":null,"dir":"Reference","previous_headings":"","what":"Generating data in singleRcapture — simulate","title":"Generating data in singleRcapture — simulate","text":"S3 method stats::simulate handle singleRStaticCountData singleRfamily classes.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/simulate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generating data in singleRcapture — simulate","text":"","code":"# S3 method for class 'singleRStaticCountData' simulate(object, nsim = 1, seed = NULL, ...) # S3 method for class 'singleRfamily' simulate(object, nsim, seed = NULL, eta, truncated = FALSE, ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/simulate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generating data in singleRcapture — simulate","text":"object object representing fitted model. nsim numeric scalar specifying: number response vectors simulate simulate.singleRStaticCountData, defaults 1L. number units draw simulate.singleRfamily, defaults NROW(eta). seed object specifying random number generator initialized (‘seeded’). ... additional optional arguments. eta matrix linear predictors truncated logical value indicating whether sample truncated full distribution.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/simulate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generating data in singleRcapture — simulate","text":"data.frame n rows nsim columns.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/simulate.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Generating data in singleRcapture — simulate","text":"Maciej Beręsewicz, Piotr Chlebicki","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/simulate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generating data in singleRcapture — simulate","text":"","code":"N <- 10000 ###gender <- rbinom(N, 1, 0.2) gender <- rep(0:1, c(8042, 1958)) eta <- -1 + 0.5*gender counts <- simulate(ztpoisson(), eta = cbind(eta), seed = 1) df <- data.frame(gender, eta, counts) df2 <- subset(df, counts > 0) ### check coverage with summary mod1 <- estimatePopsize( formula = counts ~ 1 + gender, data = df2, model = ztpoisson, controlMethod = list(silent = TRUE) ) mod1_sims <- simulate(mod1, nsim=10, seed = 1) colMeans(mod1_sims) #> sim_1 sim_2 sim_3 sim_4 sim_5 sim_6 sim_7 sim_8 #> 1.241014 1.259281 1.239246 1.244255 1.226871 1.237773 1.239540 1.234532 #> sim_9 sim_10 #> 1.230701 1.244844 mean(df2$counts) #> [1] 1.240424"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/singleRmodels.html","id":null,"dir":"Reference","previous_headings":"","what":"Family functions in singleRcapture package — chao","title":"Family functions in singleRcapture package — chao","text":"Package singleRcapture utilizes various family type functions specify variable parts population size estimation, regression, diagnostics necessary information depends model. functions used model argument estimatePopsize function.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/singleRmodels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Family functions in singleRcapture package — chao","text":"","code":"chao(lambdaLink = \"loghalf\", ...) Hurdleztgeom( lambdaLink = c(\"log\", \"neglog\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) Hurdleztnegbin( nSim = 1000, epsSim = 1e-08, eimStep = 6, lambdaLink = c(\"log\", \"neglog\"), alphaLink = c(\"log\", \"neglog\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) Hurdleztpoisson( lambdaLink = c(\"log\", \"neglog\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) oiztgeom( lambdaLink = c(\"log\", \"neglog\"), omegaLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) oiztnegbin( nSim = 1000, epsSim = 1e-08, eimStep = 6, lambdaLink = c(\"log\", \"neglog\"), alphaLink = c(\"log\", \"neglog\"), omegaLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) oiztpoisson( lambdaLink = c(\"log\", \"neglog\"), omegaLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) zelterman(lambdaLink = \"loghalf\", ...) zotgeom(lambdaLink = c(\"log\", \"neglog\"), ...) zotnegbin( nSim = 1000, epsSim = 1e-08, eimStep = 6, lambdaLink = c(\"log\", \"neglog\"), alphaLink = c(\"log\", \"neglog\"), ... ) zotpoisson(lambdaLink = c(\"log\", \"neglog\"), ...) ztHurdlegeom( lambdaLink = c(\"log\", \"neglog\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) ztHurdlenegbin( nSim = 1000, epsSim = 1e-08, eimStep = 6, lambdaLink = c(\"log\", \"neglog\"), alphaLink = c(\"log\", \"neglog\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) ztHurdlepoisson( lambdaLink = c(\"log\", \"neglog\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) ztgeom(lambdaLink = c(\"log\", \"neglog\"), ...) ztnegbin( nSim = 1000, epsSim = 1e-08, eimStep = 6, lambdaLink = c(\"log\", \"neglog\"), alphaLink = c(\"log\", \"neglog\"), ... ) ztoigeom( lambdaLink = c(\"log\", \"neglog\"), omegaLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) ztoinegbin( nSim = 1000, epsSim = 1e-08, eimStep = 6, lambdaLink = c(\"log\", \"neglog\"), alphaLink = c(\"log\", \"neglog\"), omegaLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) ztoipoisson( lambdaLink = c(\"log\", \"neglog\"), omegaLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) ztpoisson(lambdaLink = c(\"log\", \"neglog\"), ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/singleRmodels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Family functions in singleRcapture package — chao","text":"lambdaLink link Poisson parameter, \"log\" default except zelterman's chao's models (x2) possible. ... Additional arguments, used now. piLink link probability parameter, \"logit\" default nSim, epsSim working weights computed analytically arguments specify maximum number simulations allowed precision level finding numerically respectively. eimStep non negative integer describing many values used step approximation information matrixes analytic solution available (e.g. \"ztnegbin\"), default varies depending function. Higher value usually means faster convergence may potentially cause issues convergence. alphaLink link dispersion parameter, \"log\" default omegaLink link inflation parameter, \"logit\" default","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/singleRmodels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Family functions in singleRcapture package — chao","text":"object class family containing objects: makeMinusLogLike – factory function creating following functions: (), , ^2^T functions y vector X_vlm matrix (just X applied model single linear predictor)deriv argument possible values c(0, 1, 2) determine derivative return; default value 0, represents minus log-likelihood. links – list link functions. mu.eta, variance – Functions linear predictors return expected value variance. type argument 2 possible values (\"trunc\" \"nontrunc\") specifies whether return E(Y|Y>0), var(Y|Y>0) E(Y), var(Y) respectively; deriv argument values c(0, 1, 2) used indicating derivative respect linear predictors, used providing standard errors predict method. family – string specifies name model. valideta, validmu – now returns TRUE. near future, used check whether applied linear predictors valid (.e. transformed elements parameter space subjected inverse link function). funcZ, Wfun – Functions create pseudo residuals working weights used IRLS algorithm. devResids – function given linear predictors prior weights vector response vector returns deviance residuals. family functions functions implemented yet. pointEst, popVar – Functions given prior weights linear predictors latter case also estimate cov() X_vlm matrix return point estimate population size analytic estimation variance.additional boolean parameter contr former function set true returns contribution unit. etaNames – Names linear predictors. densityFunction – function given linear predictors returns value PMF values x. Additional argument type specifies whether return P(Y|Y>0) P(Y). simulate – function generates values dependent vector given linear predictors. getStart – expression generating starting points.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/singleRmodels.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Family functions in singleRcapture package — chao","text":"functions based \"base\" distribution support N_0=N 0 describe distribution Y truncation. Currently include: P(Y=y|,)= arraycc ^ye^-y! & Poisson distribution (y+^-1)(^-1)y! (^-1^-1+)^^-1 (^-1+)^y & negative binomial distribution ^y(1+)^y+1 & geometric distribution array . Poisson parameter dispersion parameter. Geometric distribution special case negative binomial distribution =1 included negative binomial distribution quite troublesome numerical regression fitting. important know PMF negative binomial distribution approaches PMF Poisson distribution 0^+. Note literature single source capture recapture models dispersion parameter introduces greater variability negative binomial distribution compared Poisson distribution generally interpreted explaining unobserved heterogeneity .e. presence important unobserved independent variables. methods estimating population size tied Poisson processes hence use parameter symbol instead emphasize connection. Also hard see estimators derived modifying \"base\" distribution unbiased assumptions made respective models violated. zero-truncated models corresponding \"base\" distributions characterized relation: P(Y=y|Y>0)= arraycc P(Y=y)1-P(Y=0) & y 0 0 & y=0 array. allows us estimate parameter values using observed part population. models lead following estimates, respectively: aligned N &= _k=1^N_obs11-(-_k) & Poisson distribution N &= _k=1^N_obs11-(1+\\alpha_k_k)^-_k^-1 & negative binomial distribution N &= _k=1^N_obs1+_k_k & geometric distribution aligned One common way assumptions zero-truncated models violated presence one-inflation presence somewhat similar single source capture-recapture models zero-inflation usual count data analysis. two ways one-inflation may understood, relate whether P(Y=0) modified inflation. first approach inflate ( parameter) zero-truncated distribution : P_new(Y=y|Y>0) = arraycc + (1 - )P_old(Y=1|Y>0)& : y = 1 (1 - ) P_old(Y=y|Y>0) & : y 1 array. corresponds : P_new(Y=y) = arraycc P_old(Y=0) & : y = 0 (1 - P(Y=0)) + (1 - )P_old(Y=1) & : y = 1 (1 - ) P_old(Y=y) & : y > 1 array. zero-truncation. Models utilize approach commonly referred zero-truncated one-inflated models. Another way accommodating one-inflation SSCR putting inflation parameter base distribution : P_new(Y=y) = arraycc + (1 - )P_old(Y=1)& : y = 1 (1 - ) P_old(Y=y) & : y 1 array. becomes: P_new(Y=y|Y>0) = arraycc 1 - (1-)P_old(Y=0) + (1 - )1 - (1-)P_old(Y=0)P_old(Y=1)& : y = 1 (1 - )1 - (1-)P_old(Y=0)P_old(Y=y) & : y > 1 array. truncation. shown Böhning 2022 paper approaches equivalent terms maximizing likelihoods put formula . can however lead different population size estimates. zero-truncated one-inflated models formula population size estimate N change since P(y=0) remains estimation parameters changes calculations. one-inflated zero-truncated models population size estimates expressed, respectively : aligned N &= _k=1^N_obs11-(1-_k)(-_k) & base Poisson distribution N &= _k=1^N_obs11-(1-_k)(1+\\alpha_k_k)^-_k^-1 & base negative binomial distribution N &= _k=1^N_obs1+_k_k + _k & base geometric distribution aligned Zero-one-truncated models ignore one counts instead accommodating one-inflation utilizing identity _ztoi=f_1f_1N_obs +(N_obs-f_1)(1-f_1N_obs ) + _zot _zot log likelihood zero-one-truncated distribution characterized probability mass function: P(Y=y|Y>1)= arraycc P(Y=y)1-P(Y=0)-P(Y=1) & y > 1 0 & y 0, 1 array. P(Y) probability mass function \"base\" distribution. identity justifies use zero-one-truncated, unfortunately proven intercept models, however numerical simulations seem indicate even theorem extended (non trivial) regression population size estimation still possible. zero-one-truncated models population size estimates expressed : aligned N &= f_1 + _k=1^N_obs 1-_k(-_k)1-(-_k)-_k(-_k) & base Poisson distribution N &= f_1 + _k=1^N_obs 1-_k(1+_k_k)^-1-_k^-1 1-(1+_k_k)^-_k^-1-_k(1+_k_k)^-1-_k^-1 & base negative binomial distribution N &= f_1 + _k=1^N_obs _k^2+_k+1_k^2 & base geometric distribution aligned Pseudo hurdle models experimental yet described literature. Lastly chao zelterman models based logistic regression dummy variable Z = arraycc 0 & Y = 1 1 & Y = 2 array. based equation: logit(p_k)= (_k2)= x_k=_k _k Poisson parameter. zelterman estimator population size expressed : N=_k=1^N_obs1-(-_k) chao estimator form: N=N_obs+_k=1^f_1+f_2 1_k+ _k^22","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/singleRmodels.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Family functions in singleRcapture package — chao","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/stratifyPopsize.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate size of sub populations. — stratifyPopsize","title":"Estimate size of sub populations. — stratifyPopsize","text":"function estimates sizes specific sub populations based capture-recapture model whole population.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/stratifyPopsize.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate size of sub populations. — stratifyPopsize","text":"","code":"stratifyPopsize(object, strata, alpha, ...) # S3 method for class 'singleRStaticCountData' stratifyPopsize(object, strata, alpha, cov = NULL, ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/stratifyPopsize.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate size of sub populations. — stratifyPopsize","text":"object object population size estimates based singleRcapture package fitter singleRStaticCountData class object. strata specification sub populations given one : formula – formula applied model.frame extracted object. Logical vector number entries equal number rows dataset. (named) list element logical vector, names list used specify names variable returned object. Vector names explanatory variables. singleRStaticCountData method function specification strata parameter result every level explanatory variable sub population variable specified. value provided singleRStaticCountData method function create sub populations based levels factor variables model.frame. alpha significance level confidence intervals – Either single numeric value vector length equal number sub populations specified strata. missing set .05 singleRStaticCountData method. ... vector arguments passed functions. singleRStaticCountData method functions arguments ... passed either cov argument provided function vcov cov argument missing call. cov singleRStaticCountData method estimate variance-covariance matrix estimate regression parameters. possible pass function example sandwich::vcovHC called : foo(object, ...) user may specify additional arguments function ... argument. provided estimate covariance matrix set calling appropriate vcov method.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/stratifyPopsize.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate size of sub populations. — stratifyPopsize","text":"data.frame object row names names specified sub populations either provided inferred.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/stratifyPopsize.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Estimate size of sub populations. — stratifyPopsize","text":"single source capture-recapture models frequently used estimate population size Horvitz-Thompson type estimate: N = _k=1^NI_kP(Y_k>0) = _k=1^N_obs11-P(Y_k=0) I_k=I_Y_k > 0 indicator variables, value 1 kth unit observed least 0 otherwise inverse probabilistic weights weights units observed data 1P(Y_k>0) estimated using fitted linear predictors. estimates different sub populations made changing I_k=I_Y_k > 0 indicator variables refer population whole sub populations considered .e. changing values 1 0 kth unit member sub population considered moment. estimation variance estimates estimation variance estimate population size whole population follow relation one described .","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRStaticCountData.html","id":null,"dir":"Reference","previous_headings":"","what":"Summary statistics for model of singleRStaticCountData class — summary.singleRStaticCountData","title":"Summary statistics for model of singleRStaticCountData class — summary.singleRStaticCountData","text":"summary method singleRStaticCountData class","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRStaticCountData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summary statistics for model of singleRStaticCountData class — summary.singleRStaticCountData","text":"","code":"# S3 method for class 'singleRStaticCountData' summary( object, test = c(\"t\", \"z\"), resType = \"pearson\", correlation = FALSE, confint = FALSE, cov, popSizeEst, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRStaticCountData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summary statistics for model of singleRStaticCountData class — summary.singleRStaticCountData","text":"object object singleRStaticCountData class. test type test significance parameters \"t\" t-test \"z\" normal approximation students t distribution, default \"z\" used 30 degrees freedom \"t\" used cases. resType type residuals summarize value allowed residuals.singleRStaticCountData except \"\" allowed. default pearson residuals used. correlation logical value indicating whether correlation matrix computed covariance matrix default FALSE. confint logical value indicating whether confidence intervals regression parameters constructed. default FALSE. cov covariance matrix corresponding regression parameters. possible give cov argument function object. specified constructed using vcov.singleRStaticCountData method. (.e using Cramer-Rao lower bound) popSizeEst popSizeEstResults class object. specified population size estimation results drawn object. post-hoc procedures, sandwich covariance matrix estimation bias reduction, taken possible include population size estimation results calling redoPopEstimation. ... additional optional arguments passed following functions: vcov.singleRStaticCountData – cov argument provided. cov – cov parameter specified call function. confint.singleRStaticCountData – confint parameter set TRUE function call. particular possible set confidence level ....","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRStaticCountData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summary statistics for model of singleRStaticCountData class — summary.singleRStaticCountData","text":"object summarysingleRStaticCountData class containing: call – call created object. coefficients – dataframe estimated regression coefficients summary statistics standard error Wald test statistic p value Wald test. residuals – vector residuals type specified call. aic – Akaike's information criterion. bic – Bayesian (Schwarz's) information criterion. iter – Number iterations taken fitting regression. logL – Logarithm likelihood function evaluated coefficients. deviance – Residual deviance. populationSize – Object population size estimation results. dfResidual – Residual degrees freedom. sizeObserved – Size observed population. correlation – Correlation matrix correlation parameter set TRUE test – Type statistical test performed. model – Family class object specified call object. skew – bootstrap sample saved contains estimate skewness.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRStaticCountData.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Summary statistics for model of singleRStaticCountData class — summary.singleRStaticCountData","text":"Works analogically summary.glm includes population size estimation results. additional statistics, confidence intervals coefficients coefficient correlation, specified printed.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRmargin.html","id":null,"dir":"Reference","previous_headings":"","what":"Statistical tests of goodness of fit — summary.singleRmargin","title":"Statistical tests of goodness of fit — summary.singleRmargin","text":"Performs two statistical test observed fitted marginal frequencies. G test test statistic computed : G = 2_kO_k(O_kE_k) ^2 test statistic computed : ^2 = _k(O_k-E_k)^2E_k O_k,E_k denoted observed fitted frequencies respectively. statistics converge ^2 distribution asymptotically degrees freedom. convergence G, ^2 statistics ^2 distribution may violated expected counts cells low, say < 5, customary either censor omit cells.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRmargin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Statistical tests of goodness of fit — summary.singleRmargin","text":"","code":"# S3 method for class 'singleRmargin' summary(object, df, dropl5 = c(\"drop\", \"group\", \"no\"), ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRmargin.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Statistical tests of goodness of fit — summary.singleRmargin","text":"object object singleRmargin class. df degrees freedom provided function try manually always possible. dropl5 character indicating treatment cells frequencies < 5 either grouping , dropping leaving . Defaults drop. ... currently nothing.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRmargin.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Statistical tests of goodness of fit — summary.singleRmargin","text":"chi squared test G test comparison fitted observed marginal frequencies.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRmargin.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Statistical tests of goodness of fit — summary.singleRmargin","text":"","code":"# Create a simple model Model <- estimatePopsize( formula = capture ~ ., data = netherlandsimmigrant, model = ztpoisson, method = \"IRLS\" ) plot(Model, \"rootogram\") # We see a considerable lack of fit summary(marginalFreq(Model), df = 1, dropl5 = \"group\") #> Test for Goodness of fit of a regression model: #> #> Test statistics df P(>X^2) #> Chi-squared test 50.06 1 1.5e-12 #> G-test 34.31 1 4.7e-09 #> #> -------------------------------------------------------------- #> Cells with fitted frequencies of < 5 have been grouped #> Names of cells used in calculating test(s) statistic: 1 2 3"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcov.singleRStaticCountData.html","id":null,"dir":"Reference","previous_headings":"","what":"Obtain covariance matrix estimation — vcov.singleRStaticCountData","title":"Obtain covariance matrix estimation — vcov.singleRStaticCountData","text":"vcov method singleRStaticCountData class.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcov.singleRStaticCountData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Obtain covariance matrix estimation — vcov.singleRStaticCountData","text":"","code":"# S3 method for class 'singleRStaticCountData' vcov(object, type = c(\"Fisher\", \"observedInform\"), ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcov.singleRStaticCountData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Obtain covariance matrix estimation — vcov.singleRStaticCountData","text":"object object singleRStaticCountData class. type type estimate covariance matrix now either expected (Fisher) information matrix observed information matrix. ... additional arguments method functions","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcov.singleRStaticCountData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Obtain covariance matrix estimation — vcov.singleRStaticCountData","text":"covariance matrix fitted coefficients, rows columns correspond parameters returned coef method.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcov.singleRStaticCountData.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Obtain covariance matrix estimation — vcov.singleRStaticCountData","text":"Returns estimated covariance matrix model coefficients calculated analytic hessian Fisher information matrix usually utilizing asymptotic effectiveness maximum likelihood estimates. Covariance type taken control parameter provided call created object arguments type specified.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcovHC.singleRStaticCountData.html","id":null,"dir":"Reference","previous_headings":"","what":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","title":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","text":"S3 method vcovHC handle singleRStaticCountData class objects. Works exactly like vcovHC.default difference method handles vector generalised linear models. Updating covariance matrix variance/standard error estimation population size estimator can done via redoPopEstimation()","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcovHC.singleRStaticCountData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","text":"","code":"# S3 method for class 'singleRStaticCountData' estfun(x, ...) # S3 method for class 'singleRStaticCountData' bread(x, ...) # S3 method for class 'singleRStaticCountData' vcovHC( x, type = c(\"HC3\", \"const\", \"HC\", \"HC0\", \"HC1\", \"HC2\", \"HC4\", \"HC4m\", \"HC5\"), omega = NULL, sandwich = TRUE, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcovHC.singleRStaticCountData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","text":"x fitted singleRStaticCountData class object. ... vcovHC additional optional arguments passed following functions: estfun – empirical estimating functions. hatvalues – diagonal elements projection matrix. sandwich – sandwich argument function call set TRUE. vcov – calling bread internally. type character string specifying estimation type, sandwich::vcovHC.default. HC3 default value. omega vector function depending arguments residuals (.e. derivative log-likelihood respect linear predictor), diaghat (diagonal corresponding hat matrix) df (residual degrees freedom), sandwich::vcovHC.default. sandwich logical. sandwich estimator computed? set FALSE meat matrix returned. sandwich::vcovHC()","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcovHC.singleRStaticCountData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","text":"Variance-covariance matrix estimation corrected heteroscedasticity regression errors","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcovHC.singleRStaticCountData.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcovHC.singleRStaticCountData.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","text":"","code":"set.seed(1) N <- 10000 gender <- rbinom(N, 1, 0.2) eta <- -1 + 0.5*gender counts <- rpois(N, lambda = exp(eta)) df <- data.frame(gender, eta, counts) df2 <- subset(df, counts > 0) mod1 <- estimatePopsize( formula = counts ~ 1 + gender, data = df2, model = \"ztpoisson\", method = \"optim\", popVar = \"analytic\" ) require(sandwich) HC <- sandwich::vcovHC(mod1, type = \"HC4\") Fisher <- vcov(mod1, \"Fisher\") # variance covariance matrix obtained from #Fisher (expected) information matrix HC #> (Intercept) gender #> (Intercept) 0.00201216 -0.002012160 #> gender -0.00201216 0.004790297 Fisher #> (Intercept) gender #> (Intercept) 0.002022145 -0.002022145 #> gender -0.002022145 0.004881858 # usual results summary(mod1) #> #> Call: #> estimatePopsize.default(formula = counts ~ 1 + gender, data = df2, #> model = \"ztpoisson\", method = \"optim\", popVar = \"analytic\") #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.5503 -0.4267 -0.4267 0.0000 -0.4267 6.2261 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.01346 0.04497 -22.537 < 2e-16 *** #> gender 0.50288 0.06987 7.197 6.14e-13 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 3990.538 #> BIC: 4002.804 #> Residual deviance: 2386.29 #> #> Log-likelihood: -1993.269 on 3403 Degrees of freedom #> Number of calls to log-likelihood function: 35 #> ----------------------- #> Population size estimation results: #> Point estimate 10146.02 #> Observed proportion: 33.6% (N obs = 3405) #> Std. Error 341.7287 #> 95% CI for the population size: #> lowerBound upperBound #> normal 9476.239 10815.79 #> logNormal 9508.827 10849.72 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 31.48175 35.93198 #> logNormal 31.38330 35.80883 # updated results summary(mod1, cov = HC, popSizeEst = redoPopEstimation(mod1, cov = HC)) #> #> Call: #> estimatePopsize.default(formula = counts ~ 1 + gender, data = df2, #> model = \"ztpoisson\", method = \"optim\", popVar = \"analytic\") #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.5503 -0.4267 -0.4267 0.0000 -0.4267 6.2261 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.01346 0.04486 -22.593 < 2e-16 *** #> gender 0.50288 0.06921 7.266 3.71e-13 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 3990.538 #> BIC: 4002.804 #> Residual deviance: 2386.29 #> #> Log-likelihood: -1993.269 on 3403 Degrees of freedom #> Number of calls to log-likelihood function: 35 #> ----------------------- #> Population size estimation results: #> Point estimate 10146.02 #> Observed proportion: 33.6% (N obs = 3405) #> Std. Error 340.7902 #> 95% CI for the population size: #> lowerBound upperBound #> normal 9478.078 10813.95 #> logNormal 9510.489 10847.69 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 31.48710 35.92500 #> logNormal 31.38916 35.80257 # estimating equations mod1_sims <- sandwich::estfun(mod1) head(mod1_sims) #> (Intercept) gender #> 1 -0.1924342 0.0000000 #> 2 0.6700925 0.6700925 #> 3 -0.1924342 0.0000000 #> 4 -0.1924342 0.0000000 #> 5 -0.1924342 0.0000000 #> 6 -0.1924342 0.0000000 # bread method all(vcov(mod1, \"Fisher\") * nrow(df2) == sandwich::bread(mod1, type = \"Fisher\")) #> [1] TRUE"},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-023","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.3","title":"singleRcapture 0.2.3","text":"BugFix anova working methods Tests working methods added Small changes documentation","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-022","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.2","title":"singleRcapture 0.2.2","text":"CRAN release: 2025-02-04 Fixing documentation typos errors plot now default value qq vignette added based paper submitted JSS","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-0212","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.1.2","title":"singleRcapture 0.2.1.2","text":"CRAN release: 2024-07-18 Bugfix interaction terms formula considered Small changes summary marginal count distributions Small fixes standard errors predicted means Code coverage raised nearly 90% logLik.singleRStaticCountData method now type argument , set \"function\" makes function return minus log-likelihood function (default) deriv argument set 1 2 respectively either gradient hessian log-likelihood function.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-0211","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.1.1","title":"singleRcapture 0.2.1.1","text":"CRAN release: 2023-10-23 Bugfix tests failing noLongDouble","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-021","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.1","title":"singleRcapture 0.2.1","text":"CRAN release: 2023-10-14 Fixed bugs IRLS fitting providing weights argument calling estimatePopsize weightsAsCounts option controlModel now works properly, dfbeta dfpopsize decrease weight selected row model matrix instead deleting set TRUE simulate method now works family object (like ztpoisson()) objects returned estimatePopsize Introduced singleRStaticCountData sub class singleRclass made estimatePopsize method new package singleRcaptureExtra (development) can make necessary calculations pop size estimation providing object fitted countreg::zerotrunc VGAM::vglm/VGAM::vgam bugfixes multicore bootstrap Code re-factored make development/maintenance package much easier Update uploaded CRAN semiparametric bootstrap now much faster sampling algorithm (job) Unit tests: * Reduced computational burden unit tests * Multicore tests performed TEST_SINGLERCAPTURE_MULTICORE_DEVELOPER set \"true\" via Sys.setenv _R_CHECK_LIMIT_CORES_ false","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-0201","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.0.1","title":"singleRcapture 0.2.0.1","text":"Added offset argument estimatePopsize Added options parallel computing bootstrap dfbeta Added deviance negative binomial based models. (NOTE: slow now believe may change verify one theoretical results lead significant speed increase computations) Overhaul starting points (new methods added linear predictors start IRLS) Code weights IRLS fitting speed Minor bugfixes","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-020","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.0","title":"singleRcapture 0.2.0","text":"CRAN release: 2023-06-11","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"the-package-is-now-at-cran-0-2-0","dir":"Changelog","previous_headings":"","what":"The package is now at CRAN","title":"singleRcapture 0.2.0","text":"Added final Hurdleztnegbin model Vastly improved redoPopSize now handles bootstrap fitted model non standard covariance matrixes newdata argument user supplied coef etc. Added predict.singleR method offers standard error link, response well mean predictions unexpected warnings occur now main function using package correctly control arguments now verified passed Fitting now reliable Added information stats::optim error codes Added warnings functions computing deviance fixed bugs occurring using mathematical functions part formulas .e. setting formula something like: y ~ log(x) + (x ^ t) + (t ^ 2)","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-014","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.4","title":"singleRcapture 0.1.4","text":"Added ztoinegbin, oiztnegbin ztHurdlenegbin models Added optional arguments family-functions specify link function distribution parameters Updated standardized documentation Added warnings Added methods singleR class commonly used glm functions, particular texreg::screenreg work well now Changed default arguments Added option save logs IRLS fitting Fixed issues intercept models Fixed slight miscalculations information matrixes one inflated models making fitting much reliable better Rcmd tests","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-0132--ntts","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.3.2 – NTTS","title":"singleRcapture 0.1.3.2 – NTTS","text":"Added function implements population size estimates stratas warnings fitting options control functions Corrected/implemented deviance residuals models Now whole package uses cammelCase Performance upgrades Corrected miss calculated moments Change exported data factors actually factors just characters Removed unused dependency Added automated R-cmd check","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-0131","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.3.1","title":"singleRcapture 0.1.3.1","text":"Basically documentation redone now features important theory SSCR methods information (v)glms Added checks positivity working weights matrixes stabilise \"IRLS\" algorithm S3 method vcovHC implemented vcovCL work singleR class objects work \"HC0\" \"HC1\" type argument values Basic version function redoPopEstimation updating population size estimation post-hoc procedures implemented popSizeEst function extracting population size estimation results implemented Minor improvements memory usage made computation speed little Changed names mle robust fitting methods optim IRLS respectively bugfixes warnings messages estimate_popsize.fit","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-013","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.3","title":"singleRcapture 0.1.3","text":"Multiple new models IRLS generalised distributions multiple parameters bugfixes QOL improvements extended bootstrap methods new models","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-012","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.2","title":"singleRcapture 0.1.2","text":"control parameters model control parameters regression bootstrap sampling leave one diagnostics popsize regression parameters (dfbetas corrected) fixes Goodness fit tests zero one truncated models computational improvements IRLS small bugfixes","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-011","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.1","title":"singleRcapture 0.1.1","text":"tiny tests fixes marginal frequencies Deviance implemented dfbetas levarage matrix Parametric bootstraps work correctly part just polishing left ","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-010","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.0","title":"singleRcapture 0.1.0","text":"first version package released","code":""}] +[{"path":"https://ncn-foreigners.github.io/singleRcapture/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2021 singleRcapture authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Population size estimation methodological approach employed across multiple scientific disciplines, serves basis research, policy formulation, decision-making processes (cf. Böhning, Bunge, Heijden 2018). field statistics, particularly official statistics, precise population estimates essential order develop robust economic models, optimize resource allocation, inform evidence-based policy (cf. Baffour, King, Valente 2013). Social scientists utilize advanced population estimation techniques investigate hard--reach populations, homeless individuals illicit drug users effort overcome inherent limitations conventional census methodologies. techniques crucial obtaining accurate data populations typically -represented difficult access using traditional sampling methods (cf. Vincent Thompson 2022). ecology epidemiology, researchers focus estimating size individual species disease-affected populations within defined geographical regions part conservation efforts, ecosystem management, public health interventions. Population size estimation can approached using various methodologies, distinct advantages limitations. Traditional approaches include full enumeration (e.g. censuses) comprehensive sample surveys, , providing detailed data, often resource-intensive may result delayed estimates, particularly human populations. Alternative methods leverage existing data sources, administrative registers carefully designed small-scale studies wildlife research, census coverage surveys (cf. Wolter 1986; Zhang 2019). Information sources often extracted applying statistical methods, known capture-recapture multiple system estimation, rely data multiple enumerations population (cf. Dunne Zhang 2024). approach can implemented using either single source repeated observations, two sources, multiple sources. paper focus methods involve single data source multiple enumerations units (cf. Heijden et al. 2003). human population studies, data can derived police records, health system databases, border control logs; case non-human populations, data kind can come veterinary records specialized field data. methods often applied estimate hard--reach hidden populations, standard sampling methods may inappropriate prohibitive costs problems identifying population members. methods two sources implemented various open-source software packages, instance CARE-4 (Yang Chao 2006) (GAUSS), Rcapture (Baillargeon Rivest 2007), marked (Laake et al. 2013) VGAM (Thomas W. Yee, Stoklosa, Huggins 2015) (R), single-source capture-recapture (SSCR) methods either available partially implemented existing R packages software. Therefore, paper attempts bridge gap introducing singleRcapture package, implement state---art SSCR methods offer user friendly API resembling existing R functions (e.g., glm). next subsection describe existing R packages software used estimating population size using SSCR methods.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-software","dir":"Articles","previous_headings":"Introduction","what":"Software for capture-recapture with a single source","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"majority SSCR methods assume zero-truncated distributions extensions (e.g., inclusion one-inflation). Distributions.jl (Besançon et al. 2021) (Julia), StatsModels (Seabold Perktold 2010) (Python), countreg (Zeileis, Kleiber, Jackman 2008), VGAM (T. Yee 2015) distributions3 (Hayes et al. 2024) (R) implement truncated distributions (e.g. distributions3::ZTPoisson countreg::zerotrunc) general distributions, Generally Altered, Inflated, Truncated Deflated, can found VGAM package (e.g. VGAM::gaitdpoisson Poisson distribution, see Thomas W. Yee Ma (2024) detailed description). However, estimation parameters given truncated (possibly inflated) distribution just first step (case log-linear models capture-recapture two sources) , best knowledge, open-source software can used estimate population size using SSCR methods includes variance estimators diagnostics. Therefore, purpose singleRcapture, R package, bridge gap providing scientists practitioners tool estimating population size SSCR methods. implemented state---art methods, recently described Böhning, Bunge, Heijden (2018) Böhning Friedl (2024) provided extensions (e.g., inclusion covariates, different treatment one-inflation), covered detail Section 2. package implements variance estimation based various methods, can used create custom models diagnostic plots (e.g. rootograms) parameters estimated using modified iteratively reweighted least squares (IRLS) algorithm implemented estimation stability. best knowledge, existing open-source package allows estimation population size selecting appropriate SSCR model, conducting estimation, providing informative diagnostics results. remaining part paper structured follows. Section 2 contains brief description theoretical background information fitting methods available methods variance estimation. Section 3 introduces main functions package. Section 4 presents case study contains assessment results, diagnostics estimates specific sub-populations. Section 5 describes classes S3methods implemented package. paper ends conclusions appendix showing use estimatePopsizeFit function aimed mimic glm.fit similar functions. replication materials show implement custom model option interest users wishing apply new bootstrap methods implemented package.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"how-to-estimate-population-size-with-a-single-source","dir":"Articles","previous_headings":"Theoretical background","what":"How to estimate population size with a single source?","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Let YkY_{k} represent number times kk-th unit observed single source (e.g. register). Clearly, observe k:Yk>0k:Y_{k}>0 know many units missed (.e. Yk=0Y_{k}=0), population size, denoted NN, needs estimated. general, assume conditional distribution YkY_{k} given vector covariates 𝐱k\\boldsymbol{x}_{k} follows version zero-truncated count data distribution (extensions). know parameters distribution can estimate population size using Horvitz-Thompson type estimator given : N̂=∑k=1NIkℙ[Yk>0|𝐗k]=∑k=1Nobs1ℙ[Yk>0|𝐗k], \\begin{equation} \\hat{N}= \\sum_{k=1}^{N}\\frac{I_{k}}{\\mathbb{P}[Y_{k}>0|\\boldsymbol{X}_{k}]}= \\sum_{k=1}^{N_{obs}}\\frac{1}{\\mathbb{P}[Y_{k}>0|\\boldsymbol{X}_{k}]}, \\end{equation} Ik:=ℐℕ(Yk)I_{k}:=\\mathcal{}_{\\mathbb{N}}(Y_{k}), NobsN_{obs} number observed units ℐ\\mathcal{} indicator function, maximum likelihood estimate NN obtained substituting regression parameters 𝛃\\boldsymbol{\\beta} ℙ[Yk>0|𝐱k]\\mathbb{P}[Y_{k}>0|\\boldsymbol{x}_{k}] equation. basic SSCR assumes independence counts, rather naive assumption, since first capture may significantly influence behavior given unit limit possibility subsequent captures (e.g. due incarceration). solve issues, Ryan T. Godwin Böhning (2017b) Ryan T. Godwin Böhning (2017a) introduced one-inflated distributions, explicitly model probability singletons giving additional mass ω\\omega singletons denoted ℐ{1}(y)\\mathcal{}_{\\{1\\}}(y)(cf. Böhning Friedl 2024). words considered new random varialbe Y*Y^{\\ast} corresponds data collection process exhibits one inflation: ℙ[Y*=y|Y*>0]=ωℐ{1}(y)+(1−ω)ℙ[Y=y|Y>0]. \\begin{equation*} \\mathbb{P}\\left[Y^{\\ast}=y|Y^{\\ast}>0\\right] = \\omega\\mathcal{}_{\\{1\\}}(y)+(1-\\omega)\\mathbb{P}[Y=y|Y>0]. \\end{equation*} Analytic variance estimation performed computing two parts decomposition according law total variance given : var[N̂]=𝔼[var[N̂|I1,…,]]+var[𝔼[N̂|I1,…,]], \\begin{equation}\\label{eq-law_of_total_variance_decomposition} \\text{var}[\\hat{N}] = \\mathbb{E}\\left[\\text{var} \\left[\\hat{N}|I_{1},\\dots,I_{n}\\right]\\right] + \\text{var}\\left[\\mathbb{E}[\\hat{N}|I_{1},\\dots,I_{n}]\\right], \\end{equation} first part can estimated using multivariate δ\\delta method given : 𝔼[var[N̂|I1,…,]]=(∂(N|I1,…,)∂𝛃)⊤cov[𝛃̂](∂(N|I1,…,)∂𝛃)|𝛃=𝛃̂, \\begin{equation*} \\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)^\\top \\text{cov}\\left[\\hat{\\boldsymbol{\\beta}}\\right] \\left(\\frac{\\partial(N|I_1,\\dots,I_N)}{\\partial\\boldsymbol{\\beta}}\\right) \\right|_{\\boldsymbol{\\beta}=\\hat{\\boldsymbol{\\beta}}}, \\end{equation*} second part decomposition , assuming independence IkI_{k}’s omitted simplifications, optimally estimated : var[𝔼(N̂|I1,…,)]=var[∑k=1NIkℙ(Yk>0)]≈∑k=1Nobs1−ℙ(Yk>0)ℙ(Yk>0)2, \\begin{equation*} \\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] \\approx\\sum_{k=1}^{N_{obs}}\\frac{1-\\mathbb{P}(Y_{k}>0)}{\\mathbb{P}(Y_{k}>0)^{2}}, \\end{equation*} serves basis interval estimation. Confidence intervals usually constructed assumption (asymptotic) normality N̂\\hat{N} asymptotic normality ln(N̂−N)\\ln(\\hat{N}-N) (log normality N̂\\hat{N}). latter attempt address common criticism student type confidence intervals SSCR, namely possibly skewed distribution N̂\\hat{N}, results 1−α1-\\alpha confidence interval given : (Nobs+N̂−Nobsξ,Nobs+(N̂−Nobs)ξ), \\begin{equation*} \\left(N_{obs}+\\frac{\\hat{N}-N_{obs}}{\\xi},N_{obs} + \\left(\\hat{N}-N_{obs}\\right)\\xi\\right), \\end{equation*} : ξ=exp(z(1−α2)ln(1+Var̂(N̂)(N̂−Nobs)2)), \\begin{equation*} \\xi = \\exp\\left(z\\left(1-\\frac{\\alpha}{2}\\right) \\sqrt{\\ln\\left(1+\\frac{\\widehat{\\text{Var}}(\\hat{N})}{\\left(\\hat{N}-N_{obs}\\right)^{2}}\\right)}\\right), \\end{equation*} zz quantile function standard normal distribution. estimator N̂\\hat{N} best interpreted estimator total number units population, since means estimating number units population probability included data 00(Heijden et al. 2003).","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"available-models","dir":"Articles","previous_headings":"Theoretical background","what":"Available models","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"full list models implemented singleRcapture along corresponding expressions probability density functions point estimates can found collective help file family functions: sake simplicity, list family functions together brief descriptions. detailed information, please consult relevant literature. current list family functions includes: Generalized Chao’s (Chao 1987) Zelterman’s (Zelterman 1988) estimators via logistic regression variable ZZ defined Z=1Z=1 Y=2Y=2 Z=0Z=0 Y=1Y=1 Z∼b(p)Z\\sim b(p) b(⋅)b(\\cdot) Bernoulli distribution pp can modeled unit kk logit(pk)=ln(λk/2)\\text{logit}(p_k)=\\ln(\\lambda_k/2) Poisson parameter λk=𝐱k𝛃\\lambda_k=\\boldsymbol{x}_{k}\\boldsymbol{\\beta} (covariate extension see Böhning et al. (2013) Böhning Heijden (2009)): N̂Chao=Nobs+∑k=1𝐟1+𝐟2(2exp(𝐱k𝛃̂)+2exp(2𝐱k𝛃̂))−1, \\hat{N}_{\\text{Chao}} = N_{obs}+ \\sum_{k=1}^{\\boldsymbol{f}_{1}+\\boldsymbol{f}_{2}} \\left(2\\exp\\left(\\boldsymbol{x}_{k}\\hat{\\boldsymbol{\\beta}}\\right)+ 2\\exp\\left(2\\boldsymbol{x}_{k}\\hat{\\boldsymbol{\\beta}}\\right)\\right)^{-1}, \\tag{Chao's estimator} N̂Zelt=∑k=1Nobs(1−exp(−2exp(𝐱k𝛃̂)))−1. \\hat{N}_{\\text{Zelt}}=\\sum_{k=1}^{N_{obs}} \\left(1-\\exp\\left(-2\\exp\\left(\\boldsymbol{x}_{k}\\hat{\\boldsymbol{\\beta}}\\right)\\right)\\right)^{-1}. \\tag{Zelterman's estimator} 𝐟1\\boldsymbol{f}_{1} 𝐟2\\boldsymbol{f}_{2} denotes number units observed twice. Zero-truncated (zt*^\\ast) zero-one-truncated (zot*^\\ast) Poisson (Böhning Heijden 2019), geometric, NB type II (NB2) regression, non-truncated distribution parameterized : ℙ[Y=y|λ,α]=Γ(y+α−1)Γ(α−1)y!(α−1α−1+λ)α−1(λλ+α−1)y. \\mathbb{P}[Y=y|\\lambda,\\alpha] = \\frac{\\Gamma\\left(y+\\alpha^{-1}\\right)}{\\Gamma\\left(\\alpha^{-1}\\right)y!} \\left(\\frac{\\alpha^{-1}}{\\alpha^{-1}+\\lambda}\\right)^{\\alpha^{-1}} \\left(\\frac{\\lambda}{\\lambda + \\alpha^{-1}}\\right)^{y}. Zero-truncated one-inflated (ztoi*^\\ast) modifications, count data variable Y*Y^{\\ast} defined distribution statisfies: ℙ[Y*=y]={ℙ[Y=0]y=0,ω(1−ℙ[Y=0])+(1−ω)ℙ[Y=1]y=1,(1−ω)ℙ[Y=y]y>1, \\mathbb{P}\\left[Y^{\\ast}=y\\right]= \\begin{cases} \\mathbb{P}[Y=0] & y=0, \\\\ \\omega\\left(1-\\mathbb{P}[Y=0]\\right)+(1-\\omega)\\mathbb{P}[Y=1] & y=1, \\\\ (1-\\omega)\\mathbb{P}[Y=y] & y>1, \\end{cases} ℙ[Y*=y|Y*>0]=ωℐ{1}(y)+(1−ω)ℙ[Y=y|Y>0]. \\mathbb{P}\\left[Y^{\\ast}=y|Y^{\\ast}>0\\right]=\\omega\\mathcal{}_{\\{1\\}}(y)+(1-\\omega)\\mathbb{P}[Y=y|Y>0]. One-inflated zero-truncated (oizt*^\\ast) modifications, count data variable Y*Y^{\\ast} defined : ℙ[Y*=y]=ωℐ{1}(y)+(1−ω)ℙ[Y=y], \\mathbb{P}\\left[Y^{\\ast}=y\\right] = \\omega \\mathcal{}_{\\{1\\}}(y)+(1-\\omega)\\mathbb{P}[Y=y], ℙ[Y*=y|Y*>0]=ωℐ{1}(y)1−(1−ω)ℙ[Y=0]+(1−ω)ℙ[Y=y]1−(1−ω)ℙ[Y=0]. \\mathbb{P}\\left[Y^{\\ast}=y|Y^{\\ast}>0\\right] = \\omega\\frac{\\mathcal{}_{\\{1\\}}(y)}{1-(1-\\omega)\\mathbb{P}[Y=0]}+ (1-\\omega)\\frac{\\mathbb{P}[Y=y]}{1-(1-\\omega)\\mathbb{P}[Y=0]}. Note ztoi*^\\ast oizt*^\\ast distributions equivalent, sense maximum value likelihood function equal distributions given data, shown (Böhning 2023) population size estimators different. addition, propose two new approaches model singletons similar way hurdle models. particular, proposed following: zero-truncated hurdle model (ztHurdle*) Poisson, geometric NB2 defined : ℙ[Y*=y]={ℙ[Y=0]1−ℙ[Y=1]y=0,π(1−ℙ[Y=1])y=1,(1−π)ℙ[Y=y]1−ℙ[Y=1]y>1, \\mathbb{P}[Y^{\\ast}=y]=\\begin{cases} \\frac{\\mathbb{P}[Y=0]}{1-\\mathbb{P}[Y=1]} & y=0, \\\\ \\pi(1-\\mathbb{P}[Y=1]) & y=1, \\\\ (1-\\pi) \\frac{\\mathbb{P}[Y=y]}{1-\\mathbb{P}[Y=1]} & y>1, \\end{cases} ℙ[Y*=y|Y*>0]=π𝟏{1}(y)+(1−π)𝟏ℕ\\{1}(y)ℙ[Y=y]1−ℙ[Y=0]−ℙ[Y=1]. \\mathbb{P}[Y^{\\ast}=y|Y^{\\ast}>0]=\\pi\\mathbf{1}_{\\{1\\}}(y)+ (1-\\pi)\\mathbf{1}_{\\mathbb{N}\\setminus\\{1\\}}(y)\\frac{\\mathbb{P}[Y=y]}{1-\\mathbb{P}[Y=0]-\\mathbb{P}[Y=1]}. π\\pi denotes conditional probability observing singletons. hurdle zero-truncated model (Hurdlezt*) Poisson, geometric NB2 defined : ℙ[Y*=y]={πy=1,(1−π)ℙ[Y=y]1−ℙ[Y=1]y≠1, \\mathbb{P}[Y^{\\ast}=y]=\\begin{cases} \\pi & y=1, \\\\ (1-\\pi) \\frac{\\mathbb{P}[Y=y]}{1-\\mathbb{P}[Y=1]} & y\\neq1, \\end{cases} ℙ[Y*=y|Y*>0]={π1−ℙ[Y=1]1−ℙ[Y=0]−ℙ[Y=1]y=1,(1−π)ℙ[Y=y]1−ℙ[Y=0]−ℙ[Y=1]y>1, \\mathbb{P}[Y^{\\ast}=y|Y^{\\ast}>0]=\\begin{cases} \\pi\\frac{1-\\mathbb{P}[Y=1]}{1-\\mathbb{P}[Y=0]-\\mathbb{P}[Y=1]} & y=1,\\\\ (1-\\pi)\\frac{\\mathbb{P}[Y=y]}{1-\\mathbb{P}[Y=0]-\\mathbb{P}[Y=1]} & y>1, \\end{cases} π\\pi denotes unconditional probability observing singletons. approaches presented differ assumptions, computational complexity, way treat heterogeneity captures singletons. instance, dispersion parameter α\\alpha NB2 type models often interpreted measuring severity unobserved heterogeneity underlying Poisson process (Cruyff Heijden 2008). using truncated NB model, hope given class models considered, consistency lost despite lack information. discussed literature, interpretation heterogeneous α\\alpha across population (specified controlModel) unobserved heterogeneity affects accuracy prediction dependent variable YY severely others. geometric model (NB α=1\\alpha=1) singled package often considered literature inherent computational issues NB models, exacerbated fact data used SSCR usually rather low quality. Data sparsity particularly common problem SSCR big challenge numerical methods fitting (zero-truncated) NB model. extra mass ω\\omega one-inflated models important extension researcher’s toolbox SSCR models, since inflation y=1y=1 likely occur many types applications. example, estimating number active people committed criminal acts given time period, fact captured first time following arrest associated risk longer able captured second time. One constraint present modelling via inflated models attempts include possibility one inflation one deflation lead numerical inferential problems since parameter space ((ω,λ)(\\omega, \\lambda) (ω,λ,α)(\\omega, \\lambda, \\alpha)) given {(ω,λ,α)|∀x∈ℕ:p(x|ω,λ,α)≥0}\\{(\\omega, \\lambda, \\alpha) | \\forall x\\\\mathbb{N}: p(x|\\omega, \\lambda, \\alpha)\\geq0\\} probability mass function pp. boundary set 11 2−2-dimentional manifold, transforming parameter space ℝ3\\mathbb{R}^{3} require using link functions depend one parameter. Hurdle models represent another approach modelling one-inflation. can also model deflation well inflation deflation simultaneously, flexible , case hurdle zero-truncated models, appear numerically stable. Although question interpret regression parameters tends somewhat overlooked SSCR studies, point interpretation ω\\omega inflation parameter (ztoi*^\\ast oizt*^\\ast) convenient interpretation π\\pi probability parameter (hurdle models). Additionally, interpretation λ\\lambda parameter (one) inflated models conforms following intuition: given unit kk comes non-inflated part population, follows Poisson distribution (respectively geometric negative binomial) λ\\lambda parameter (λ,α\\lambda,\\alpha); interpretation exists hurdle models. Interestingly, estimates hurdle zero-truncated one-inflated zero-truncated models tend quite close one another, although rigorous studies required confirm observation.","code":"?ztpoisson"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"fitting-method","dir":"Articles","previous_headings":"Theoretical background","what":"Fitting method","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"previously noted, singleRcapture package can used model (linear) dependence parameters covariates. modified IRLS algorithm employed purpose presented Algorithm 1; full details available T. Yee (2015). order apply algorithm, modified model matrix 𝐗vlm\\boldsymbol{X}_{\\text{vlm}} created estimatePopsize function called. context models implemented singleRcapture, matrix can written : 𝐗vlm=(𝐗1𝟎…𝟎𝟎𝐗2…𝟎⋮⋮⋱⋮𝟎𝟎…𝐗p) \\begin{equation}\\label{X_vlm-definition} \\boldsymbol{X}_{\\text{vlm}}= \\begin{pmatrix} \\boldsymbol{X}_{1} & \\boldsymbol{0} &\\dotso &\\boldsymbol{0}\\\\ \\boldsymbol{0} & \\boldsymbol{X}_{2} &\\dotso &\\boldsymbol{0}\\\\ \\vdots & \\vdots & \\ddots & \\vdots\\\\ \\boldsymbol{0} & \\boldsymbol{0} &\\dotso &\\boldsymbol{X}_{p} \\end{pmatrix} \\end{equation} 𝐗i\\boldsymbol{X}_{} corresponds model matrix associated user specified formula.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"algorithm-1-the-modified-irls-algorithm-used-in-the-singlercapture-package","dir":"Articles","previous_headings":"Theoretical background > Fitting method","what":"Algorithm 1: The modified IRLS algorithm used in the singleRcapture package","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Initialize iter ← 1, 𝛈\\boldsymbol{\\eta} ← start, 𝐖\\boldsymbol{W} ← , ℓ\\ell ← ℓ(𝛃)\\ell(\\boldsymbol{\\beta}) Store values previous step:ℓ−\\ell_{-} ← ℓ\\ell, 𝐖−\\boldsymbol{W}_{-} ← 𝐖\\boldsymbol{W}, 𝛃−\\boldsymbol{\\beta}_{-} ← 𝛃\\boldsymbol{\\beta} (last assignment omitted first iteration), assign values current iteration: 𝛈\\displaystyle\\boldsymbol{\\eta} ← 𝐗vlm𝛃+𝐨\\boldsymbol{X}_{\\text{vlm}}\\boldsymbol{\\beta}+\\boldsymbol{o} 𝐖(k)\\boldsymbol{W}_{(k)} ← 𝔼[−∂2ℓ∂𝛈(k)⊤∂𝛈(k)]\\mathbb{E}\\left[-\\frac{\\partial^{2}\\ell}{\\partial\\boldsymbol{\\eta}_{(k)}^\\top\\partial\\boldsymbol{\\eta}_{(k)}}\\right] 𝐙(k)\\boldsymbol{Z}_{(k)} ← 𝛈(k)+∂ℓ∂𝛈(k)𝐖(k)−1−𝐨(k)\\boldsymbol{\\eta}_{(k)}+\\frac{\\partial\\ell}{\\partial\\boldsymbol{\\eta}_{(k)}}\\boldsymbol{W}_{(k)}^{-1}-\\boldsymbol{o}_{(k)} 𝐨\\boldsymbol{o} denotes offset. Assign current coefficient value:𝛃\\boldsymbol{\\beta} ← (𝐗vlm𝐖𝐗vlm)−1𝐗vlm𝐖𝐙\\left(\\boldsymbol{X}_{\\text{vlm}}\\boldsymbol{W}\\boldsymbol{X}_{\\text{vlm}}\\right)^{-1}\\boldsymbol{X}_{\\text{vlm}}\\boldsymbol{W}\\boldsymbol{Z} ℓ(𝛃)<ℓ(𝛃−)\\ell(\\boldsymbol{\\beta})<\\ell(\\boldsymbol{\\beta}_{-}) try selecting smallest value hh 𝛃h\\boldsymbol{\\beta}_{h} ← 2−h(𝛃+𝛃−)2^{-h}\\left(\\boldsymbol{\\beta}+\\boldsymbol{\\beta}_{-}\\right) inequality ℓ(𝛃h)>ℓ(𝛃−)\\ell(\\boldsymbol{\\beta}_{h})>\\ell(\\boldsymbol{\\beta}_{-}) holds successful 𝛃\\boldsymbol{\\beta} ← 𝛃h\\boldsymbol{\\beta}_{h}, else stop algorithm. convergence achieved iter higher maxiter, stop algorithm, else iter ← 1 + iter return step 2. case multi-parameter families, get matrix linear predictors 𝛈\\boldsymbol{\\eta} instead vector, number columns matching number parameters distribution. “Weights” (matrix 𝐖\\boldsymbol{W}) modified information matrices 𝔼[−∂2ℓ∂𝛈(k)⊤∂𝛈(k)]\\displaystyle\\mathbb{E}\\left[-\\frac{\\partial^{2}\\ell}{\\partial\\boldsymbol{\\eta}_{(k)}^\\top\\partial\\boldsymbol{\\eta}_{(k)}}\\right], ℓ\\ell log-likelihood function 𝛈(k)\\boldsymbol{\\eta}_{(k)} kk-th row 𝛈\\boldsymbol{\\eta}, typical IRLS scalars 𝔼[−∂2ℓ∂ηk2]\\displaystyle\\mathbb{E}\\left[-\\frac{\\partial^{2}\\ell}{\\partial\\eta_{k}^{2}}\\right], often just −∂2ℓ∂η2\\displaystyle-\\frac{\\partial^{2}\\ell}{\\partial\\eta^{2}}.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-boostrap","dir":"Articles","previous_headings":"Theoretical background","what":"Bootstrap variance estimators","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"implemented three types bootstrap algorithms: parametric (adapted theory Zwane Van der Heijden (2003), Norris Pollock (1996) multiple source setting covariates), semi-parametric (see e.g. Böhning Friedl (2021)) nonparametric. nonparametric version usual bootstrap algorithm; typically underestimate variance N̂\\hat{N}. section, focus first two approaches. idea semi-parametric bootstrap modify usual bootstrap include additional uncertainty resulting fact sample size random variable. type bootstrap performed steps listed Algorithm 2.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"algorithm-2-semi-parametric-bootstrap","dir":"Articles","previous_headings":"Theoretical background > Bootstrap variance estimators","what":"Algorithm 2: Semi-parametric bootstrap","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Draw sample size Nobs′∼Binomial(N′,NobsN′)N_{obs}'\\sim\\text{Binomial}\\left(N', \\frac{N_{obs}}{N'}\\right), N′=⌊N̂⌋+Bernoulli(⌊N̂⌋−N̂)N'=\\lfloor\\hat{N}\\rfloor+\\text{Bernoulli}\\left(\\lfloor\\hat{N}\\rfloor-\\hat{N}\\right) Draw Nobs′N_{obs}' units data uniformly without replacement Obtain new population size estimate NbN_b using bootstrap data Repeat 1-3 steps BB times words, first draw sample size sample conditional sample size. Note using semi-parametric bootstrap one implicitly assumes population size estimate N̂\\hat{N} accurate. last implemented bootstrap type parametric algorithm, first draws finite population size ≈N̂\\approx\\hat{N} superpopulation model samples population according selected model, described Algorithm 3.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"algorithm-3-parametric-bootstrap","dir":"Articles","previous_headings":"Theoretical background > Bootstrap variance estimators","what":"Algorithm 3: Parametric bootstrap","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Draw number covariates equal ⌊N̂⌋+Bernoulli(⌊N̂⌋−N̂)\\lfloor\\hat{N}\\rfloor+\\text{Bernoulli}\\left(\\lfloor\\hat{N}\\rfloor-\\hat{N}\\right) proportional estimated contribution (ℙ[Yk>0|𝐱k])−1(\\mathbb{P}\\left[Y_{k}>0|\\boldsymbol{x}_{k}\\right])^{-1} replacement Using fitted model regression coefficients 𝛃̂\\hat{\\boldsymbol{\\beta}} draw covariate YY value corresponding probability measure ℕ∪{0}\\mathbb{N}\\cup\\{0\\} Truncate units drawn YY value equal 00 Obtain population size estimate NbN_b based truncated data Repeat 1-4 steps BB times Note order type algorithm result consistent standard error estimates, imperative estimated model entire superpopulation probability space consistent, may much less realistic case semi-parametric bootstrap. parametric bootstrap algorithm default option singleRcapture.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"the-estimatepopsize-function","dir":"Articles","previous_headings":"The main function","what":"The estimatePopsize function","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"singleRcapture package built around estimatePopsize function. main design objective make using estimatePopsize similar possible standard stats::glm function packages fitting zero-truncated regression models, countreg (e.g. countreg::zerotrunc function). estimatePopsize function used first fit appropriate (vector) generalized linear model estimate population size along variance. assumed response vector (.e. dependent variable) corresponds number times given unit observed source. important arguments given Table ; obligatory ones formula, data, model. important step using estimatePopsize specifying model parameter, indicates type model used estimating unobserved part population. instance, fit Chao’s Zelterman’s model one select chao zelterman , assuming one-inflation present, one can select one zero-truncated one-inflated (ztoi*^\\ast) one-inflated zero-truncated (oizt*^\\ast) models, oiztpoisson Poisson ztoinegbin NB2. assumed heterogeneity observed NB2 models, one can specify formula controlModel argument controlModel function alphaFormula argument. enables user provide formula dispersion parameter NB2 models. heterogeneity assumed ztoi*^\\ast oizt*^\\ast, one can specify omegaFormula argument, corresponds ω\\omega parameter models. Finally, covariates assumed available hurdle models (ztHurdle*^\\ast Hurdlezt*^\\ast), piFormula can specified, provides formula probability parameter models.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"controlling-variance-estimation-with-controlpopvar","dir":"Articles","previous_headings":"The main function","what":"Controlling variance estimation with controlPopVar","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"estimatePopsize function makes possible specify variance estimation method via popVar (e.g. analytic variance bootstrap) control estimation process specifying controlPopVar. control function controlPopVar user can specify bootType argument, three possible values: \"parametric\", \"semiparametric\" \"nonparametric\". Additional arguments accepted contorlPopVar function, relevant bootstrap, include: alpha, B – significance level number bootstrap samples performed, respectively, 0.050.05 500500 default options. cores – number process cores used bootstrap (1 default); parallel computing enabled doParallel (Microsoft Weston 2022a), foreach (Microsoft Weston 2022b) parallel packages (R Core Team 2023). keepbootStat – logical value indicating whether keep vector statistics produced bootstrap. traceBootstrapSize, bootstrapVisualTrace – logical values indicating whether sample population size tracked (FALSE default); work cores = 1. fittingMethod, bootstrapFitcontrol – fitting method (default one used original call) control parameters (controlMethod) model fitting bootstrap. addition, user can specify type confidence interval means confType type covariance matrix using covType analytical variance estimator (observed Fisher information matrix). next sections present case study involving use simple zero-truncated Poisson regression advanced model: one-inflated zero-truncated geometric regression cloglog link function. First, present example dataset, describe estimate population size assess quality diagnostics measures. Finally, show estimate population size user-specified sub-populations.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-study","dir":"Articles","previous_headings":"","what":"Data analysis example","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"package can installed standard manner using: , need load package using following code:","code":"install.packages(\"singleRcapture\") library(singleRcapture)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"dataset","dir":"Articles","previous_headings":"Data analysis example","what":"Dataset","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"use dataset Heijden et al. (2003), contains information immigrants four Dutch cities (Amsterdam, Rotterdam, Hague Utrecht), staying country without legal permit 1995 appeared police records year. dataset included package called netherlandsimmigrant: number times individual appeared records included capture variable. available covariates include gender, age, reason, nation; last two represent reason captured region world given person comes : One notable characteristic dataset contains disproportionately large number individuals observed (.e. 1645). basic syntax estimatePopsize similar glm, can said output summary method except additional results population size estimates (denoted Population size estimation results). output regarding population size contains point estimate, observed proportion (based input dataset), standard error two confidence intervals: one relating point estimate, second – observed proportion. According simple model, population size 12,500, 15% units observed register. 95% CI normality indicates true population size likely 7,000-18,000, 10-26% target population observed register. Since reasonable suspicion act observing unit dataset may lead undesirable consequences person concerned (case, possible deportation, detention something similar). reasons, user may consider one-inflated models, one-inflated zero-truncated geometric model (specified oiztgeom family) presented . According approach, population size 7,000, 5,000 less case naive Poisson approach. comparison AIC BIC suggests one-inflation model fits data better BIC oiztgeom 1727 1757 ztpoisson. can access population size estimates using following code, returns list numerical results. decision whether use zero-truncated Poisson one-inflated zero-truncated geometric model based assessment model assumptions regarding data generation process. One possible method selection based likelihood ratio test, can computed quickly conveniently lmtest (Zeileis Hothorn (2002)) interface: However, standard method model selection SSCR. next sections dedicated detailed description assess results using standard statistical tests diagnostics.","code":"data(netherlandsimmigrant) head(netherlandsimmigrant) ## capture gender age reason nation ## 1 1 male <40yrs Other reason North Africa ## 2 1 male <40yrs Other reason North Africa ## 3 1 male <40yrs Other reason North Africa ## 4 1 male <40yrs Other reason Asia ## 5 1 male <40yrs Other reason Asia ## 6 2 male <40yrs Other reason North Africa summary(netherlandsimmigrant) ## capture gender age reason ## Min. :1.000 female: 398 <40yrs:1769 Illegal stay: 259 ## 1st Qu.:1.000 male :1482 >40yrs: 111 Other reason:1621 ## Median :1.000 ## Mean :1.162 ## 3rd Qu.:1.000 ## Max. :6.000 ## nation ## American and Australia: 173 ## Asia : 284 ## North Africa :1023 ## Rest of Africa : 243 ## Surinam : 64 ## Turkey : 93 table(netherlandsimmigrant$capture) ## ## 1 2 3 4 5 6 ## 1645 183 37 13 1 1 basicModel <- estimatePopsize( formula = capture ~ gender + age + nation, model = ztpoisson(), data = netherlandsimmigrant, controlMethod = controlMethod(silent = TRUE) ) summary(basicModel) ## ## Call: ## estimatePopsize.default(formula = capture ~ gender + age + nation, ## data = netherlandsimmigrant, model = ztpoisson(), controlMethod = controlMethod(silent = TRUE)) ## ## Pearson Residuals: ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -0.486442 -0.486442 -0.298080 0.002093 -0.209444 13.910844 ## ## Coefficients: ## ----------------------- ## For linear predictors associated with: lambda ## Estimate Std. Error z value P(>|z|) ## (Intercept) -1.3411 0.2149 -6.241 4.35e-10 *** ## gendermale 0.3972 0.1630 2.436 0.014832 * ## age>40yrs -0.9746 0.4082 -2.387 0.016972 * ## nationAsia -1.0926 0.3016 -3.622 0.000292 *** ## nationNorth Africa 0.1900 0.1940 0.979 0.327398 ## nationRest of Africa -0.9106 0.3008 -3.027 0.002468 ** ## nationSurinam -2.3364 1.0136 -2.305 0.021159 * ## nationTurkey -1.6754 0.6028 -2.779 0.005445 ** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## AIC: 1712.901 ## BIC: 1757.213 ## Residual deviance: 1128.553 ## ## Log-likelihood: -848.4504 on 1872 Degrees of freedom ## Number of iterations: 8 ## ----------------------- ## Population size estimation results: ## Point estimate 12690.35 ## Observed proportion: 14.8% (N obs = 1880) ## Std. Error 2808.169 ## 95% CI for the population size: ## lowerBound upperBound ## normal 7186.444 18194.26 ## logNormal 8431.275 19718.32 ## 95% CI for the share of observed population: ## lowerBound upperBound ## normal 10.332927 26.16037 ## logNormal 9.534281 22.29793 set.seed(123456) modelInflated <- estimatePopsize( formula = capture ~ nation, model = oiztgeom(omegaLink = \"cloglog\"), data = netherlandsimmigrant, controlModel = controlModel( omegaFormula = ~ gender + age ), popVar = \"bootstrap\", controlPopVar = controlPopVar(bootType = \"semiparametric\", B = 50) ) summary(modelInflated) ## ## Call: ## estimatePopsize.default(formula = capture ~ nation, data = netherlandsimmigrant, ## model = oiztgeom(omegaLink = \"cloglog\"), popVar = \"bootstrap\", ## controlModel = controlModel(omegaFormula = ~gender + age), ## controlPopVar = controlPopVar(bootType = \"semiparametric\", ## B = 50)) ## ## Pearson Residuals: ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -0.41643 -0.41643 -0.30127 0.00314 -0.18323 13.88376 ## ## Coefficients: ## ----------------------- ## For linear predictors associated with: lambda ## Estimate Std. Error z value P(>|z|) ## (Intercept) -1.2552 0.2149 -5.840 5.22e-09 *** ## nationAsia -0.8193 0.2544 -3.220 0.00128 ** ## nationNorth Africa 0.2057 0.1838 1.119 0.26309 ## nationRest of Africa -0.6692 0.2548 -2.627 0.00862 ** ## nationSurinam -1.5205 0.6271 -2.425 0.01532 * ## nationTurkey -1.1888 0.4343 -2.737 0.00619 ** ## ----------------------- ## For linear predictors associated with: omega ## Estimate Std. Error z value P(>|z|) ## (Intercept) -1.4577 0.3884 -3.753 0.000175 *** ## gendermale -0.8738 0.3602 -2.426 0.015267 * ## age>40yrs 1.1745 0.5423 2.166 0.030326 * ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## AIC: 1677.125 ## BIC: 1726.976 ## Residual deviance: 941.5416 ## ## Log-likelihood: -829.5625 on 3751 Degrees of freedom ## Number of iterations: 10 ## ----------------------- ## Population size estimation results: ## Point estimate 6699.953 ## Observed proportion: 28.1% (N obs = 1880) ## Boostrap sample skewness: 0.5209689 ## 0 skewness is expected for normally distributed variable ## --- ## Bootstrap Std. Error 1579.235 ## 95% CI for the population size: ## lowerBound upperBound ## 5107.533 10738.242 ## 95% CI for the share of observed population: ## lowerBound upperBound ## 17.50752 36.80838 popSizeEst(basicModel) # alternative: basicModel$populationSize ## Point estimate: 12690.35 ## Variance: 7885812 ## 95% confidence intervals: ## lowerBound upperBound ## normal 7186.444 18194.26 ## logNormal 8431.275 19718.32 popSizeEst(modelInflated) # alternative: modelInflated$populationSize ## Point estimate: 6699.953 ## Variance: 2493985 ## 95% confidence intervals: ## lowerBound upperBound ## 5107.533 10738.242 library(lmtest) lrtest(basicModel, modelInflated, name = function(x) { if (family(x)$family == \"ztpoisson\") \"Basic model\" else \"Inflated model\" }) ## Likelihood ratio test ## ## Model 1: Basic model ## Model 2: Inflated model ## #Df LogLik Df Chisq Pr(>Chisq) ## 1 8 -848.45 ## 2 9 -829.56 1 37.776 7.936e-10 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"testing-marginal-frequencies","dir":"Articles","previous_headings":"Data analysis example","what":"Testing marginal frequencies","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"popular method testing model fit single source capture-recapture studies consists comparing fitted marginal frequencies ∑j=1Nobsℙ̂[Yj=k|𝐱j,Yj>0]\\displaystyle\\sum_{j=1}^{N_{obs}}\\hat{\\mathbb{P}}\\left[Y_{j}=k|\\boldsymbol{x}_{j}, Y_{j} > 0\\right] observed marginal frequencies ∑j=1Nℐ{k}(Yj)=∑j=1Nobsℐ{k}(Yj)\\displaystyle\\sum_{j=1}^{N}\\mathcal{}_{\\{k\\}}(Y_{j})=\\sum_{j=1}^{N_{obs}}\\mathcal{}_{\\{k\\}}(Y_{j}) k≥1k\\geq1. fitted model bears sufficient resemblance real data collection process, quantities quite close GG χ2\\chi^{2} tests can used test statistical significance discrepancy following singleRcapture syntax Poisson model (rather poor fit): one-inflated model (better fit): dropl5 argument used indicate handle cells less 55 fitted observations. Note, however, currently continuity correction.","code":"margFreq <- marginalFreq(basicModel) summary(margFreq, df = 1, dropl5 = \"group\") ## Test for Goodness of fit of a regression model: ## ## Test statistics df P(>X^2) ## Chi-squared test 50.06 1 1.5e-12 ## G-test 34.31 1 4.7e-09 ## ## -------------------------------------------------------------- ## Cells with fitted frequencies of < 5 have been grouped ## Names of cells used in calculating test(s) statistic: 1 2 3 margFreq_inf <- marginalFreq(modelInflated) summary(margFreq_inf, df = 1, dropl5 = \"group\") ## Test for Goodness of fit of a regression model: ## ## Test statistics df P(>X^2) ## Chi-squared test 1.88 1 0.17 ## G-test 2.32 1 0.13 ## ## -------------------------------------------------------------- ## Cells with fitted frequencies of < 5 have been grouped ## Names of cells used in calculating test(s) statistic: 1 2 3 4"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"diagnostics","dir":"Articles","previous_headings":"Data analysis example","what":"Diagnostics","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"singleRStaticCountData class plot method implementing several types quick demonstrative plots, rootogram (Kleiber Zeileis 2016), comparing fitted marginal frequencies, can generated following syntax: Rootograms ztpoisson (left) oiztgeom (right) models plots suggest oiztgeom model fits data better. Another important issue population size estimation conduct model diagnostics order verify whether influential observations present data. purpose leave-one-(LOO) diagnostic implemented dfbeta stats package adapted shown (multiplied factor hundred better readability): result dfbeta can used dfpopsize function, can used quantify LOO population size. Note warning bootstap variance estimation applied. Figure 2 shows comparison effect deleting observation population size estimate inverse probability weights, refer contribution given observation population size estimate: Results ztpoisson (left) oiztgeom (right) model plots show population size changes given observation removed. instance, remove observation 542, population size increase 4236 ztpoisson model. case oiztgeom, largest change equal 457 observation 900. full list plot types along list optional arguments can passed call plot method base R graphics functions can found help file plot method.","code":"plot( basicModel, plotType = \"rootogram\", main = \"ZT Poisson model\") plot(modelInflated, plotType = \"rootogram\", main = \"OI ZT Geometric model\") dfb <- dfbeta(basicModel) round(t(apply(dfb, 2, quantile)*100), 4) ## 0% 25% 50% 75% 100% ## (Intercept) -0.9909 -0.1533 0.0191 0.0521 8.6619 ## gendermale -9.0535 -0.0777 -0.0283 0.1017 2.2135 ## age>40yrs -2.0010 0.0179 0.0379 0.0691 16.0061 ## nationAsia -9.5559 -0.0529 0.0066 0.0120 17.9914 ## nationNorth Africa -9.6605 -0.0842 -0.0177 0.0087 3.1260 ## nationRest of Africa -9.4497 -0.0244 0.0030 0.0083 10.9787 ## nationSurinam -9.3140 -0.0066 0.0020 0.0035 99.3383 ## nationTurkey -9.6198 -0.0220 0.0079 0.0143 32.0980 dfi <- dfbeta(modelInflated) round(t(apply(dfi, 2, quantile)*100), 4) ## 0% 25% 50% 75% 100% ## (Intercept) -1.4640 0.0050 0.0184 0.0557 9.0600 ## nationAsia -6.6331 -0.0346 0.0157 0.0347 12.2406 ## nationNorth Africa -7.2770 -0.0768 -0.0170 0.0085 1.9415 ## nationRest of Africa -6.6568 -0.0230 0.0081 0.0262 7.1710 ## nationSurinam -6.2308 -0.0124 0.0162 0.0421 62.2045 ## nationTurkey -6.4795 -0.0273 0.0204 0.0462 21.1338 ## (Intercept):omega -6.8668 -0.0193 0.0476 0.0476 9.3389 ## gendermale:omega -2.2733 -0.2227 0.1313 0.2482 11.1234 ## age>40yrs:omega -30.2130 -0.2247 -0.1312 -0.0663 2.0393 dfb_pop <- dfpopsize(basicModel, dfbeta = dfb) dfi_pop <- dfpopsize(modelInflated, dfbeta = dfi) summary(dfb_pop) ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -4236.412 2.664 2.664 5.448 17.284 117.448 summary(dfi_pop) ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -456.6443 -3.1121 -0.7243 3.4333 5.1535 103.5949 plot(basicModel, plotType = \"dfpopContr\", dfpop = dfb_pop, xlim = c(-4500, 150)) plot(modelInflated, plotType = \"dfpopContr\", dfpop = dfi_pop, xlim = c(-4500, 150)) ?plot.singleRStaticCountData"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"the-stratifypopsize-function","dir":"Articles","previous_headings":"Data analysis example","what":"The stratifyPopsize function","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Researchers may interested total population size also size specific sub-populations (e.g. males, females, particular age groups). reason created stratifyPopsize function, estimates size strata defined coefficients model (default option). following output presents results based ztpoisson oiztgeom models. stratifyPopsize function prepared handle objects singleRStaticCountData class, accepts three optional parameters strata, alpha, cov, used specifying sub-populations, significance levels covariance matrix used computing standard errors. example full call presented . provided integration sandwich (Zeileis, Köll, Graham 2020) package correct variance-covariance matrix δ\\delta method. code used vcovHC method singleRStaticCountData class sandwich package, different significance levels confidence intervals stratum formula specify want estimates males females grouped nation age. strata parameter can specified either : formula empty left hand side, shown example (e.g. ~ gender * age), logical vector number entries equal number rows dataset, case one stratum created (e.g. netherlandsimmigrant$gender == \"male\"), vector names explanatory variables, result every level explanatory variable sub-population variable specified (e.g. c(\"gender\", \"age\")), supplied , case strata correspond levels factor data without interactions (string vectors converted factors convenience user), (named) list element logical vector; names list used specify variable names returned object, example: One can also specify plotType = \"strata\" plot function, results plot point CI estimates population size. Population size covariates ztpoisson (left) oiztgeom (right) model logNormal type confidence interval used plotting since studentized confidence intervals often result negative lower bounds.","code":"popSizestrata <- stratifyPopsize(basicModel) cols <- c(\"name\", \"Observed\", \"Estimated\", \"logNormalLowerBound\", \"logNormalUpperBound\") popSizestrata_report <- popSizestrata[, cols] cols_custom <- c(\"Name\", \"Obs\", \"Estimated\", \"LowerBound\", \"UpperBound\") names(popSizestrata_report) <- cols_custom popSizestrata_report ## Name Obs Estimated LowerBound UpperBound ## 1 gender==female 398 3811.0924 2189.0439 6902.140 ## 2 gender==male 1482 8879.2613 6090.7752 13354.889 ## 3 age==<40yrs 1769 10506.8994 7359.4140 15426.465 ## 4 age==>40yrs 111 2183.4543 872.0130 5754.881 ## 5 nation==American and Australia 173 708.3688 504.6086 1037.331 ## 6 nation==Asia 284 2742.3147 1755.2548 4391.590 ## 7 nation==North Africa 1023 3055.2033 2697.4900 3489.333 ## 8 nation==Rest of Africa 243 2058.1533 1318.7466 3305.786 ## 9 nation==Surinam 64 2386.4544 505.2460 12288.008 ## 10 nation==Turkey 93 1739.8592 638.0497 5068.959 popSizestrata_inflated <- stratifyPopsize(modelInflated) popSizestrata_inflated_report <- popSizestrata_inflated[, cols] names(popSizestrata_inflated_report) <- cols_custom popSizestrata_inflated_report ## Name Obs Estimated LowerBound UpperBound ## 1 nation==American and Australia 173 516.2432 370.8463 768.4919 ## 2 nation==Asia 284 1323.5377 831.1601 2258.9954 ## 3 nation==North Africa 1023 2975.8801 2254.7071 4119.3050 ## 4 nation==Rest of Africa 243 1033.9753 667.6106 1716.4484 ## 5 nation==Surinam 64 354.2236 193.8891 712.4739 ## 6 nation==Turkey 93 496.0934 283.1444 947.5309 ## 7 gender==female 398 1109.7768 778.7197 1728.7066 ## 8 gender==male 1482 5590.1764 3838.4550 8644.0776 ## 9 age==<40yrs 1769 6437.8154 4462.3472 9862.2147 ## 10 age==>40yrs 111 262.1379 170.9490 492.0347 library(sandwich) popSizestrataCustom <- stratifyPopsize( object = basicModel, strata = ~ gender + age, alpha = rep(c(0.1, 0.05), each=2), cov = vcovHC(basicModel, type = \"HC4\") ) popSizestrataCustom_report <- popSizestrataCustom[, c(cols, \"confLevel\")] names(popSizestrataCustom_report) <- c(cols_custom, \"alpha\") popSizestrataCustom_report ## Name Obs Estimated LowerBound UpperBound alpha ## 1 gender==female 398 3811.092 2275.6410 6602.168 0.10 ## 2 gender==male 1482 8879.261 6261.5109 12930.760 0.10 ## 3 age==<40yrs 1769 10506.899 7297.2057 15580.151 0.05 ## 4 age==>40yrs 111 2183.454 787.0673 6464.016 0.05 list( \"Stratum 1\" = netherlandsimmigrant$gender == \"male\" & netherlandsimmigrant$nation == \"Suriname\", \"Stratum 2\" = netherlandsimmigrant$gender == \"female\" & netherlandsimmigrant$nation == \"North Africa\" ) plot(basicModel, plotType = \"strata\") plot(modelInflated, plotType = \"strata\")"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-methods","dir":"Articles","previous_headings":"","what":"Classes and S3Methods","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"created number classes. main ones : singleRStaticCountData, singleRfamily, supplementary : popSizeEstResults, summarysingleRmargin summarysingleRStaticCountData, make possible extract relevant information regarding population size. instance, popSizeEst function can used extract information estimated size population given : resulting object popEst popSizeEstResults class contains following fields: pointEstimate, variance – numerics containing point estimate variance estimate. confidenceInterval – data.frame confidence intervals. boot – bootstrap performed numeric vector containing N̂\\hat{N} values bootstrap, character vector value \"bootstrap performed\" otherwise. control – controlPopVar object controls used obtain object. explicitly defined method popSizeEstResults, summarysingleRmargin summarysingleRStaticCountData classes print method, former one also accepts R primitives like coef: analogously glm stats. singleRfamily inherits family class stats explicitly defined print simulate methods. Example usage presented full list explicitly defined methods singleRStaticCountData methods presented Table .","code":"(popEst <- popSizeEst(basicModel)) ## Point estimate: 12690.35 ## Variance: 7885812 ## 95% confidence intervals: ## lowerBound upperBound ## normal 7186.444 18194.26 ## logNormal 8431.275 19718.32 coef(summary(basicModel)) ## Estimate Std. Error z value P(>|z|) ## (Intercept) -1.3410661 0.2148870 -6.2407965 4.353484e-10 ## gendermale 0.3971793 0.1630155 2.4364504 1.483220e-02 ## age>40yrs -0.9746058 0.4082420 -2.3873235 1.697155e-02 ## nationAsia -1.0925990 0.3016259 -3.6223642 2.919228e-04 ## nationNorth Africa 0.1899980 0.1940007 0.9793677 3.273983e-01 ## nationRest of Africa -0.9106361 0.3008092 -3.0272880 2.467587e-03 ## nationSurinam -2.3363962 1.0135645 -2.3051282 2.115939e-02 ## nationTurkey -1.6753917 0.6027744 -2.7794674 5.444812e-03 set.seed(1234567890) N <- 10000 gender <- rbinom(N, 1, 0.2) eta <- -1 + 0.5*gender counts <- simulate(ztpoisson(), eta = cbind(eta), seed = 1) summary(data.frame(gender, eta, counts)) ## gender eta counts ## Min. :0.0000 Min. :-1.0000 Min. :0.0000 ## 1st Qu.:0.0000 1st Qu.:-1.0000 1st Qu.:0.0000 ## Median :0.0000 Median :-1.0000 Median :0.0000 ## Mean :0.2036 Mean :-0.8982 Mean :0.4196 ## 3rd Qu.:0.0000 3rd Qu.:-1.0000 3rd Qu.:1.0000 ## Max. :1.0000 Max. :-0.5000 Max. :5.0000"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"concluding-remarks","dir":"Articles","previous_headings":"","what":"Concluding remarks","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"paper introduced singleRcapture package single source capture-recapture models. package implement state---art methods estimating population size based single data set multiple counts. package implements different methods account heterogeneity capture probabilities, modelled using covariates, well behavioural change, modelled using one-inflation. built package facilitate implementation new models using family objects; application exemplified Section 7. example implementing custom family described Section 8 presented replication materials. Furthermore, since many R users familiar countreg VGAM packages, implemented lightweight extension called singleRcaptureExtra, available Github (), can used integrate singleRcapture packages. future work plan implement Bayesian estimation using Stan (e.g. via brms package; Carpenter et al. (2017), Bürkner (2017)) one-inflation models can use recent approach proposed Tuoto, Di Cecco, Tancredi (2022) implement families using brms package.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"Acknowledgements","dir":"Articles","previous_headings":"","what":"Acknowledgements","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"authors’ work financed National Science Centre Poland, OPUS 20, grant . 2020/39/B/HS4/00941. authors like thank Peter van der Heijden, Maarten Cruyff, Dankmar Böhning, Łukasz Chrostowski Layna Dennett useful comments helped improve functionality package. addition, like thank Marcin Szymkowiak Tymon Świtalski valuable comments considerably improved paper.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-estimatePopsizeFit","dir":"Articles","previous_headings":"Detailed information","what":"The estimatePopsizeFit function","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"section provide step--step description prepare data order use estimatePopsizeFit function, may useful users, e.g. wishing make modifications N̂\\hat{N} estimate bootstrap. order show apply function fit zero truncated geometric model data Böhning et al. (2013) covariate dependency: log(λ)=β1,1+β1,2log_distance+β1,3C_TYPE+β1,4log_size,logit(ω)=β2,1+β2,2log_distance+β2,3C_TYPE.\\begin{align*} \\log(\\lambda) &= \\beta_{1, 1} + \\beta_{1, 2} \\text{log\\_distance} + \\beta_{1, 3} \\text{C\\_TYPE} + \\beta_{1, 4} \\text{log\\_size}, \\\\ \\text{logit}(\\omega) &= \\beta_{2, 1} + \\beta_{2, 2} \\text{log\\_distance} + \\beta_{2, 3} \\text{C\\_TYPE}. \\end{align*} equivalent following esimatePopsize call: Create data matrix 𝐗vlm\\boldsymbol{X}_{\\text{vlm}} Fill first nn rows model.matrix according specified formula specify attribute attr(X, \"hwm\") informs function elements design matrix correspond linear predictor (covariates counts covariates one-inflation) Obtain starting 𝛃\\boldsymbol{\\beta} parameters using glm.fit function. Use estimatePopsizeFit function fit model assuming zero-truncated one-inflated geometric distribution specified family argument. Compare results obtained applying stats::optim function. default maxiter parameter \"optim\" fitting 10001000, needed increase since optim converge 10001000 steps “gets stuck” plateau, results lower log-likelihood value compared standard \"IRLS\". situation rather typical. conduct formal numerical analyses, seems one attempts model one parameter distribution covariate dependent optim algorithms, \"Nelder-Mead\" \"L-BFGS-B\" seem ill-suited task despite provided analytically computed gradient. one reasons \"IRLS\" default fitting method.","code":"estimatePopsize( TOTAL_SUB ~ ., data = farmsubmission, model = ztoigeom(), controlModel( omegaFormula = ~ 1 + log_size + C_TYPE ) ) X <- matrix(data = 0, nrow = 2 * NROW(farmsubmission), ncol = 7) X[1:NROW(farmsubmission), 1:4] <- model.matrix( ~ 1 + log_size + log_distance + C_TYPE, farmsubmission ) X[-(1:NROW(farmsubmission)), 5:7] <- model.matrix( ~ 1 + log_distance + C_TYPE, farmsubmission ) attr(X, \"hwm\") <- c(4, 3) start <- glm.fit( y = farmsubmission$TOTAL_SUB, x = X[1:NROW(farmsubmission), 1:4], family = poisson() )$coefficients start ## [1] -0.82583943 0.33254499 -0.03277732 0.32746933 res <- estimatePopsizeFit( y = farmsubmission$TOTAL_SUB, X = X, method = \"IRLS\", priorWeights = 1, family = ztoigeom(), control = controlMethod(silent = TRUE), coefStart = c(start, 0, 0, 0), etaStart = matrix(X %*% c(start, 0, 0, 0), ncol = 2), offset = cbind(rep(0, NROW(farmsubmission)), rep(0, NROW(farmsubmission))) ) ll <- ztoigeom()$makeMinusLogLike(y = farmsubmission$TOTAL_SUB, X = X) res2 <- estimatePopsizeFit( y = farmsubmission$TOTAL_SUB, X = X, method = \"optim\", priorWeights = 1, family = ztoigeom(), coefStart = c(start, 0, 0, 0), control = controlMethod(silent = TRUE, maxiter = 10000), offset = cbind(rep(0, NROW(farmsubmission)), rep(0, NROW(farmsubmission))) ) data.frame(IRLS = round(c(res$beta, -ll(res$beta), res$iter), 4), optim = round(c(res2$beta, -ll(res2$beta), res2$iter[1]), 4)) ## IRLS optim ## 1 -2.7845 -2.5971 ## 2 0.6170 0.6163 ## 3 -0.0646 -0.0825 ## 4 0.5346 0.5431 ## 5 -3.1745 -0.1504 ## 6 0.1281 -0.1586 ## 7 -1.0865 -1.0372 ## 8 -17278.7613 -17280.1189 ## 9 15.0000 1696.0000"},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-family","dir":"Articles","previous_headings":"Detailed information","what":"Structure of a family function","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"section provide details regarding family object singleRcapture package. object contains additional parameters comparison standard family object stats package.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/articles/singleRcapture.html","id":"sec-custom","dir":"Articles","previous_headings":"","what":"Implementing a custom singleRcapture family function","title":"singleRcapture: An R Package for Single-Source Capture-Recapture Models","text":"Suppose want implement specific zero truncated family function singleRcapture, corresponds following “untruncated” distribution: ℙ[Y=y|λ,π]={1−12λ−12πwhen: y=012πwhen: y=112λwhen: y=2, \\mathbb{P}[Y=y|\\lambda, \\pi] = \\begin{cases} 1 - \\frac{1}{2}\\lambda - \\frac{1}{2}\\pi & \\text{: } y=0\\\\ \\frac{1}{2}\\pi & \\text{: } y=1\\\\ \\frac{1}{2}\\lambda & \\text{: } y=2, \\end{cases} λ,π∈(0,1)\\lambda, \\pi\\\\left(0, 1\\right) dependent covariates. provide possible way implementing model, lambda, pi meaning 12λ,12π\\frac{1}{2}\\lambda,\\frac{1}{2}\\pi. provide simple example shows proposed approach works expected. quick tests shows us implementation fact works: link functions, singleRcapture:::singleRinternalcloglogLink, just internal functions singleRcapture compute link functions, inverses derivatives links inverse links third order: One , course, include code computing manually.","code":"myFamilyFunction <- function(lambdaLink = c(\"logit\", \"cloglog\", \"probit\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ...) { if (missing(lambdaLink)) lambdaLink <- \"logit\" if (missing(piLink)) piLink <- \"logit\" links <- list() attr(links, \"linkNames\") <- c(lambdaLink, piLink) lambdaLink <- switch(lambdaLink, \"logit\" = singleRcapture:::singleRinternallogitLink, \"cloglog\" = singleRcapture:::singleRinternalcloglogLink, \"probit\" = singleRcapture:::singleRinternalprobitLink ) piLink <- switch(piLink, \"logit\" = singleRcapture:::singleRinternallogitLink, \"cloglog\" = singleRcapture:::singleRinternalcloglogLink, \"probit\" = singleRcapture:::singleRinternalprobitLink ) links[1:2] <- c(lambdaLink, piLink) mu.eta <- function(eta, type = \"trunc\", deriv = FALSE, ...) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 if (!deriv) { switch (type, \"nontrunc\" = pi + 2 * lambda, \"trunc\" = 1 + lambda / (pi + lambda) ) } else { # Only necessary if one wishes to use standard errors in predict method switch (type, \"nontrunc\" = { matrix(c(2, 1) * c( lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2, piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2 ), ncol = 2) }, \"trunc\" = { matrix(c( pi / (pi + lambda) ^ 2, -lambda / (pi + lambda) ^ 2 ) * c( lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2, piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2 ), ncol = 2) } ) } } variance <- function(eta, type = \"nontrunc\", ...) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 switch (type, \"nontrunc\" = pi * (1 - pi) + 4 * lambda * (1 - lambda - pi), \"trunc\" = lambda * (1 - lambda) / (pi + lambda) ) } Wfun <- function(prior, y, eta, ...) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 G01 <- ((lambda + pi) ^ (-2)) * piLink(eta[, 2], inverse = TRUE, deriv = 1) * lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) * prior / 4 G00 <- ((lambda + pi) ^ (-2)) - (pi ^ (-2)) - lambda / ((lambda + pi) * (pi ^ 2)) G00 <- G00 * prior * (piLink(eta[, 2], inverse = TRUE, deriv = 1) ^ 2) / 4 G11 <- ((lambda + pi) ^ (-2)) - (((lambda + pi) * lambda) ^ -1) G11 <- G11 * prior * (lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) ^ 2) / 4 matrix( -c(G11, # lambda G01, # mixed G01, # mixed G00 # pi ), dimnames = list(rownames(eta), c(\"lambda\", \"mixed\", \"mixed\", \"pi\")), ncol = 4 ) } funcZ <- function(eta, weight, y, prior, ...) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 weight <- weight / prior G0 <- (2 - y) / pi - ((lambda + pi) ^ -1) G1 <- (y - 1) / lambda - ((lambda + pi) ^ -1) G1 <- G1 * lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2 G0 <- G0 * piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2 uMatrix <- matrix(c(G1, G0), ncol = 2) weight <- lapply(X = 1:nrow(weight), FUN = function (x) { matrix(as.numeric(weight[x, ]), ncol = 2) }) pseudoResid <- sapply(X = 1:length(weight), FUN = function (x) { #xx <- chol2inv(chol(weight[[x]])) # less computationally demanding xx <- solve(weight[[x]]) # more stable xx %*% uMatrix[x, ] }) pseudoResid <- t(pseudoResid) dimnames(pseudoResid) <- dimnames(eta) pseudoResid } minusLogLike <- function(y, X, offset, weight = 1, NbyK = FALSE, vectorDer = FALSE, deriv = 0, ...) { y <- as.numeric(y) if (is.null(weight)) { weight <- 1 } if (missing(offset)) { offset <- cbind(rep(0, NROW(X) / 2), rep(0, NROW(X) / 2)) } if (!(deriv %in% c(0, 1, 2))) stop(\"Only score function and derivatives up to 2 are supported.\") deriv <- deriv + 1 switch (deriv, function(beta) { eta <- matrix(as.matrix(X) %*% beta, ncol = 2) + offset pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 -sum(weight * ((2 - y) * log(pi) + (y - 1) * log(lambda) - log(pi + lambda))) }, function(beta) { eta <- matrix(as.matrix(X) %*% beta, ncol = 2) + offset pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 G0 <- (2 - y) / pi - ((lambda + pi) ^ -1) G1 <- (y - 1) / lambda - ((lambda + pi) ^ -1) G1 <- G1 * weight * lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2 G0 <- G0 * weight * piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2 if (NbyK) { XX <- 1:(attr(X, \"hwm\")[1]) return(cbind(as.data.frame(X[1:nrow(eta), XX]) * G1, as.data.frame(X[-(1:nrow(eta)), -XX]) * G0)) } if (vectorDer) { return(cbind(G1, G0)) } as.numeric(c(G1, G0) %*% X) }, function (beta) { lambdaPredNumber <- attr(X, \"hwm\")[1] eta <- matrix(as.matrix(X) %*% beta, ncol = 2) + offset pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 res <- matrix(nrow = length(beta), ncol = length(beta), dimnames = list(names(beta), names(beta))) # pi^2 derivative dpi <- (2 - y) / pi - (lambda + pi) ^ -1 G00 <- ((lambda + pi) ^ (-2)) - (2 - y) / (pi ^ 2) G00 <- t(as.data.frame(X[-(1:(nrow(X) / 2)), -(1:lambdaPredNumber)] * (G00 * ((piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2) ^ 2) + dpi * piLink(eta[, 2], inverse = TRUE, deriv = 2) / 2) * weight)) %*% as.matrix(X[-(1:(nrow(X) / 2)), -(1:lambdaPredNumber)]) # mixed derivative G01 <- (lambda + pi) ^ (-2) G01 <- t(as.data.frame(X[1:(nrow(X) / 2), 1:lambdaPredNumber]) * G01 * (lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2) * (piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2) * weight) %*% as.matrix(X[-(1:(nrow(X) / 2)), -(1:lambdaPredNumber)]) # lambda^2 derivative G11 <- ((lambda + pi) ^ (-2)) - (y - 1) / (lambda ^ 2) dlambda <- (y - 1) / lambda - ((lambda + pi) ^ -1) G11 <- t(as.data.frame(X[1:(nrow(X) / 2), 1:lambdaPredNumber] * (G11 * ((lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2) ^ 2) + dlambda * lambdaLink(eta[, 1], inverse = TRUE, deriv = 2) / 2) * weight)) %*% X[1:(nrow(X) / 2), 1:lambdaPredNumber] res[-(1:lambdaPredNumber), -(1:lambdaPredNumber)] <- G00 res[1:lambdaPredNumber, 1:lambdaPredNumber] <- G11 res[1:lambdaPredNumber, -(1:lambdaPredNumber)] <- t(G01) res[-(1:lambdaPredNumber), 1:lambdaPredNumber] <- G01 res } ) } validmu <- function(mu) { (sum(!is.finite(mu)) == 0) && all(0 < mu) && all(2 > mu) } # this is optional devResids <- function(y, eta, wt, ...) { 0 } pointEst <- function (pw, eta, contr = FALSE, ...) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 N <- pw / (lambda + pi) if(!contr) { N <- sum(N) } N } popVar <- function (pw, eta, cov, Xvlm, ...) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 bigTheta1 <- -pw / (pi + lambda) ^ 2 # w.r to pi bigTheta1 <- bigTheta1 * piLink(eta[, 2], inverse = TRUE, deriv = 1) / 2 bigTheta2 <- -pw / (pi + lambda) ^ 2 # w.r to lambda bigTheta2 <- bigTheta2 * lambdaLink(eta[, 1], inverse = TRUE, deriv = 1) / 2 # w.r to lambda bigTheta <- t(c(bigTheta2, bigTheta1) %*% Xvlm) f1 <- t(bigTheta) %*% as.matrix(cov) %*% bigTheta f2 <- sum(pw * (1 - pi - lambda) / ((pi + lambda) ^ 2)) f1 + f2 } dFun <- function (x, eta, type = c(\"trunc\", \"nontrunc\")) { if (missing(type)) type <- \"trunc\" pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 switch (type, \"trunc\" = { (pi * as.numeric(x == 1) + lambda * as.numeric(x == 2)) / (pi + lambda) }, \"nontrunc\" = { (1 - pi - lambda) * as.numeric(x == 0) + pi * as.numeric(x == 1) + lambda * as.numeric(x == 2) } ) } simulate <- function(n, eta, lower = 0, upper = Inf) { pi <- piLink(eta[, 2], inverse = TRUE) / 2 lambda <- lambdaLink(eta[, 1], inverse = TRUE) / 2 CDF <- function(x) { ifelse(x == Inf, 1, ifelse(x < 0, 0, ifelse(x < 1, 1 - pi - lambda, ifelse(x < 2, 1 - lambda, 1)))) } lb <- CDF(lower) ub <- CDF(upper) p_u <- stats::runif(n, lb, ub) sims <- rep(0, n) cond <- CDF(sims) <= p_u while (any(cond)) { sims[cond] <- sims[cond] + 1 cond <- CDF(sims) <= p_u } sims } getStart <- expression( if (method == \"IRLS\") { etaStart <- cbind( family$links[[1]](mean(observed == 2) * (1 + 0 * (observed == 2))), # lambda family$links[[2]](mean(observed == 1) * (1 + 0 * (observed == 1))) # pi ) + offset } else if (method == \"optim\") { init <- c( family$links[[1]](weighted.mean(observed == 2, priorWeights) * 1 + .0001), family$links[[2]](weighted.mean(observed == 1, priorWeights) * 1 + .0001) ) if (attr(terms, \"intercept\")) { coefStart <- c(init[1], rep(0, attr(Xvlm, \"hwm\")[1] - 1)) } else { coefStart <- rep(init[1] / attr(Xvlm, \"hwm\")[1], attr(Xvlm, \"hwm\")[1]) } if (\"(Intercept):pi\" %in% colnames(Xvlm)) { coefStart <- c(coefStart, init[2], rep(0, attr(Xvlm, \"hwm\")[2] - 1)) } else { coefStart <- c(coefStart, rep(init[2] / attr(Xvlm, \"hwm\")[2], attr(Xvlm, \"hwm\")[2])) } } ) structure( list( makeMinusLogLike = minusLogLike, densityFunction = dFun, links = links, mu.eta = mu.eta, valideta = function (eta) {TRUE}, variance = variance, Wfun = Wfun, funcZ = funcZ, devResids = devResids, validmu = validmu, pointEst = pointEst, popVar = popVar, family = \"myFamilyFunction\", etaNames = c(\"lambda\", \"pi\"), simulate = simulate, getStart = getStart, extraInfo = c( mean = \"pi / 2 + lambda\", variance = paste0(\"(pi / 2) * (1 - pi / 2) + 2 * lambda * (1 - lambda / 2 - pi / 2)\"), popSizeEst = \"(1 - (pi + lambda) / 2) ^ -1\", meanTr = \"1 + lambda / (pi + lambda)\", varianceTr = paste0(\"lambda * (1 - lambda / 2) / (pi + lambda)\") ) ), class = c(\"singleRfamily\", \"family\") ) } set.seed(123) Y <- simulate( myFamilyFunction(lambdaLink = \"logit\", piLink = \"logit\"), nsim = 1000, eta = matrix(0, nrow = 1000, ncol = 2), truncated = FALSE ) mm <- estimatePopsize( formula = Y ~ 1, data = data.frame(Y = Y[Y > 0]), model = myFamilyFunction(lambdaLink = \"logit\", piLink = \"logit\"), # the usual observed information matrix # is ill-suited for this distribution controlPopVar = controlPopVar(covType = \"Fisher\") ) summary(mm) ## ## Call: ## estimatePopsize.default(formula = Y ~ 1, data = data.frame(Y = Y[Y > ## 0]), model = myFamilyFunction(lambdaLink = \"logit\", piLink = \"logit\"), ## controlPopVar = controlPopVar(covType = \"Fisher\")) ## ## Pearson Residuals: ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -0.8198 -0.8198 0.8099 0.0000 0.8099 0.8099 ## ## Coefficients: ## ----------------------- ## For linear predictors associated with: lambda ## Estimate Std. Error z value P(>|z|) ## (Intercept) 0.01217 0.20253 0.06 0.952 ## ----------------------- ## For linear predictors associated with: pi ## Estimate Std. Error z value P(>|z|) ## (Intercept) -0.01217 0.08926 -0.136 0.892 ## ## AIC: 687.4249 ## BIC: 695.8259 ## Residual deviance: 0 ## ## Log-likelihood: -341.7124 on 984 Degrees of freedom ## Number of iterations: 2 ## ----------------------- ## Population size estimation results: ## Point estimate 986 ## Observed proportion: 50% (N obs = 493) ## Std. Error 70.30092 ## 95% CI for the population size: ## lowerBound upperBound ## normal 848.2127 1123.787 ## logNormal 866.3167 1144.053 ## 95% CI for the share of observed population: ## lowerBound upperBound ## normal 43.86951 58.12221 ## logNormal 43.09241 56.90759 singleRcapture:::singleRinternalcloglogLink ## function (x, inverse = FALSE, deriv = 0) ## { ## deriv <- deriv + 1 ## if (isFALSE(inverse)) { ## res <- switch(deriv, log(-log(1 - x)), -1/((1 - x) * ## log(1 - x)), -(1 + log(1 - x))/((x - 1)^2 * log(1 - ## x)^2), (2 * log(1 - x)^2 + 3 * log(1 - x) + 2)/(log(1 - ## x)^3 * (x - 1)^3)) ## } ## else { ## res <- switch(deriv, 1 - exp(-exp(x)), exp(x - exp(x)), ## (1 - exp(x)) * exp(x - exp(x)), (exp(2 * x) - 3 * ## exp(x) + 1) * exp(x - exp(x))) ## } ## res ## } ## ## "},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Piotr Chlebicki. Author, contributor. Maciej Beręsewicz. Author, maintainer.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Chlebicki P, Beręsewicz M (2025). singleRcapture: Single-Source Capture-Recapture Models. R package version 0.2.3, https://github.com/ncn-foreigners/singleRcapture.","code":"@Manual{, title = {singleRcapture: Single-Source Capture-Recapture Models}, author = {Piotr Chlebicki and Maciej Beręsewicz}, year = {2025}, note = {R package version 0.2.3}, url = {https://github.com/ncn-foreigners/singleRcapture}, }"},{"path":"https://ncn-foreigners.github.io/singleRcapture/index.html","id":"overview","dir":"","previous_headings":"","what":"Single-Source Capture-Recapture Models","title":"Single-Source Capture-Recapture Models","text":"Capture-recapture type experiments used estimate total population size situations observing part population feasible. recent years types experiments seen interest. Single-source models distinct capture-recapture models estimate population size based many units observed two three sources standard approach. Instead single-source models utilize count data regression models positive distributions (.e. counts greater 0) dependent variable number times particular unit observed source data. package aims implement already existing introduce new methods estimating population size single source simplify research process. Currently, implemented frequentist approaches used literature : Zero-truncated Poisson, geometric negative binomial regression. Zero-truncated one-inflated one-inflated zero-truncated Poisson geometric model. Zero-one-truncated Poisson geometric negative binomial models. Generalized Chao’s Zelterman’s models based logistic regression. Three types bootstrap parametric, semi-parametric nonparametric. wide range additional functionalities associated (vector) generalized linear models relevant topic. details see singleRcapture: R Package Single-Source Capture-Recapture Models vignette CRAN pkgdown website.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Single-Source Capture-Recapture Models","text":"can install current version singleRcapture main branch GitHub : install stable version CRAN :","code":"# install.packages(\"devtools\") remotes::install_github(\"ncn-foreigners/singleRcapture\") install.packages(singleRcapture)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/index.html","id":"examples","dir":"","previous_headings":"Installation","what":"Examples","title":"Single-Source Capture-Recapture Models","text":"main function package estimatePopsize fitts regression specified distribution uses fitted regression estimate population size. Lets look model 2003 publication (Van Der Heijden, P. G., Bustami, R., Cruyff, M. J., Engbersen, G., & Van Houwelingen, H. C. (2003). Point interval estimation population size using truncated Poisson regression model. Statistical Modelling, 3(4), 305-322.). call estimatePopsize look similar anyone used stats::glm function: implemented method plot function visualise model fit useful diagnostic information. One rootogram, type plot compares fitted observed marginal frequencies: possible values plotType argument : qq - normal quantile-quantile plot pearson residuals (default), marginal - matplot comparing fitted observed marginal frequencies, fitresid - plot linear predictor values contrasted pearson residuals, bootHist - histogram bootstrap sample, rootogram - rootogram, example presented , dfpopContr - contrasting two deletion effects identify presence influential observations, dfpopBox - boxplot results dfpopsize function see documentation, scaleLoc - scale-location plot, cooks - plot cooks.values distributions defined, hatplot - plot hatvalues, strata - plot confidence intervals selected populations. User can also pass arguments specify additional information plot title, subtitle etc. similar calling plot data. info check plot.singleR method documentation. seen significant differences fitted observed marginal frequencies. check intuition let’s perform goodness fit test fitted observed marginal frequencies. call summary function marginalFreq function computes marginal frequencies fitted singleR class object: Finally let us check influential observations. comparing deletion effect every observation population size estimate removing entirely model (population size estimate regression) omitting pop size estimation (called contribution observation). observation influential two actions approximately effect: easy deduce plot influential observations dataset (one particular). Lastly singleRcapture offers posthoc procedures example function stratifyPopsize estimates sizes user specified sub populations returns data.frame: strata argument may specified various ways example: package designed convenience mind, example possible specify weights provided call interpreted number occurrences units row: Methods regression diagnostics adjusted (values weights reduced instead rows removed etc.) also included option use common non standard argument significance levels different usual 5%: option estimate standard error population size estimate bootstrap, models one distribution parameter dependent covariates non standard link functions example: results significantly different (warning issued concerns second derivative test existence local minimum, inconclusive manually checked fitting process found optimal regression coefficients ’s provide information user): information criteria support second model:","code":"library(singleRcapture) model <- estimatePopsize( formula = capture ~ gender + age + nation, # specify formula data = netherlandsimmigrant, popVar = \"analytic\", # specify model = \"ztpoisson\", # distribution used method = \"IRLS\", # fitting method one of three currently supported controlMethod = controlMethod(silent = TRUE) # ignore convergence at half step warning ) summary(model) # a summary method for singleR class with standard glm-like output and population size estimation resutls #> #> Call: #> estimatePopsize.default(formula = capture ~ gender + age + nation, #> data = netherlandsimmigrant, model = \"ztpoisson\", method = \"IRLS\", #> popVar = \"analytic\", controlMethod = controlMethod(silent = TRUE)) #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.486442 -0.486442 -0.298080 0.002093 -0.209444 13.910844 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.3411 0.2149 -6.241 4.35e-10 *** #> gendermale 0.3972 0.1630 2.436 0.014832 * #> age>40yrs -0.9746 0.4082 -2.387 0.016972 * #> nationAsia -1.0926 0.3016 -3.622 0.000292 *** #> nationNorth Africa 0.1900 0.1940 0.979 0.327398 #> nationRest of Africa -0.9106 0.3008 -3.027 0.002468 ** #> nationSurinam -2.3364 1.0136 -2.305 0.021159 * #> nationTurkey -1.6754 0.6028 -2.779 0.005445 ** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> #> AIC: 1712.901 #> BIC: 1757.213 #> Residual deviance: 1128.553 #> #> Log-likelihood: -848.4504 on 1872 Degrees of freedom #> Number of iterations: 8 #> ----------------------- #> Population size estimation results: #> Point estimate 12690.35 #> Observed proportion: 14.8% (N obs = 1880) #> Std. Error 2808.165 #> 95% CI for the population size: #> lowerBound upperBound #> normal 7186.449 18194.25 #> logNormal 8431.277 19718.31 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 10.332933 26.16035 #> logNormal 9.534288 22.29793 plot(model, plotType = \"rootogram\") summary(marginalFreq(model), df = 2, dropl5 = \"group\") #> Test for Goodness of fit of a regression model: #> #> Test statistics df P(>X^2) #> Chi-squared test 50.06 2 1.3e-11 #> G-test 34.31 2 3.6e-08 #> #> -------------------------------------------------------------- #> Cells with fitted frequencies of < 5 have been grouped #> Names of cells used in calculating test(s) statistic: 1 2 3 plot(model, plotType = \"dfpopContr\") stratifyPopsize(model, alpha = c(.01, .02, .03, .05), # different significance level for each sub population strata = list( \"Females from Surinam\" = netherlandsimmigrant$gender == \"female\" & netherlandsimmigrant$nation == \"Surinam\", \"Males from Turkey\" = netherlandsimmigrant$gender == \"male\" & netherlandsimmigrant$nation == \"Turkey\", \"Younger males\" = netherlandsimmigrant$gender == \"male\" & netherlandsimmigrant$age == \"<40yrs\", \"Older males\" = netherlandsimmigrant$gender == \"male\" & netherlandsimmigrant$age == \">40yrs\" )) #> name Observed Estimated ObservedPercentage StdError #> 1 Females from Surinam 20 931.4677 2.147149 955.0657 #> 2 Males from Turkey 78 1291.2513 6.040652 741.0066 #> 3 Younger males 1391 7337.0708 18.958520 1282.1402 #> 4 Older males 91 1542.1886 5.900705 781.4747 #> normalLowerBound normalUpperBound logNormalLowerBound logNormalUpperBound #> 1 -1528.61853 3391.554 119.2661 8389.158 #> 2 -432.58790 3015.090 405.4127 4573.791 #> 3 4554.71057 10119.431 5134.8122 10834.785 #> 4 10.52637 3073.851 630.7551 3992.674 #> confLevel #> 1 0.01 #> 2 0.02 #> 3 0.03 #> 4 0.05 stratifyPopsize(model, strata = ~ gender / age) #> name Observed Estimated ObservedPercentage StdError #> 1 gender==female 398 3811.0911 10.443203 1153.9733 #> 2 gender==male 1482 8879.2594 16.690581 1812.0790 #> 3 genderfemale:age<40yrs 378 3169.8263 11.924944 880.9478 #> 4 gendermale:age<40yrs 1391 7337.0708 18.958520 1282.1402 #> 5 genderfemale:age>40yrs 20 641.2648 3.118836 407.5264 #> 6 gendermale:age>40yrs 91 1542.1886 5.900705 781.4747 #> normalLowerBound normalUpperBound logNormalLowerBound logNormalUpperBound #> 1 1549.34513 6072.837 2189.0443 6902.133 #> 2 5327.64991 12430.869 6090.7762 13354.880 #> 3 1443.20030 4896.452 1904.3126 5484.617 #> 4 4824.12208 9850.019 5306.3306 10421.082 #> 5 -157.47223 1440.002 212.3382 2026.726 #> 6 10.52637 3073.851 630.7551 3992.674 #> confLevel #> 1 0.05 #> 2 0.05 #> 3 0.05 #> 4 0.05 #> 5 0.05 #> 6 0.05 df <- netherlandsimmigrant[, c(1:3,5)] df$ww <- 0 ### this is dplyr::count without dependencies df <- aggregate(ww ~ ., df, FUN = length) summary(estimatePopsize( formula = capture ~ nation + age + gender, data = df, model = ztpoisson, weights = df$ww, controlModel = controlModel(weightsAsCounts = TRUE) )) #> #> Call: #> estimatePopsize.default(formula = capture ~ nation + age + gender, #> data = df, model = ztpoisson, weights = df$ww, controlModel = controlModel(weightsAsCounts = TRUE)) #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -317.6467 -2.4060 3.7702 0.0803 13.4920 183.2108 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.3411 0.2149 -6.241 4.35e-10 *** #> nationAsia -1.0926 0.3016 -3.622 0.000292 *** #> nationNorth Africa 0.1900 0.1940 0.979 0.327398 #> nationRest of Africa -0.9106 0.3008 -3.027 0.002468 ** #> nationSurinam -2.3364 1.0136 -2.305 0.021159 * #> nationTurkey -1.6754 0.6028 -2.779 0.005445 ** #> age>40yrs -0.9746 0.4082 -2.387 0.016972 * #> gendermale 0.3972 0.1630 2.436 0.014832 * #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> #> AIC: 1712.901 #> BIC: 1757.213 #> Residual deviance: 1128.553 #> #> Log-likelihood: -848.4504 on 1872 Degrees of freedom #> Number of iterations: 8 #> ----------------------- #> Population size estimation results: #> Point estimate 12690.35 #> Observed proportion: 14.8% (N obs = 1880) #> Std. Error 2808.169 #> 95% CI for the population size: #> lowerBound upperBound #> normal 7186.444 18194.26 #> logNormal 8431.275 19718.32 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 10.332927 26.16037 #> logNormal 9.534281 22.29793 set.seed(123) modelInflated <- estimatePopsize( formula = capture ~ gender + age, data = netherlandsimmigrant, model = \"oiztgeom\", method = \"IRLS\", # control parameters for population size estimation check documentation of controlPopVar controlPopVar = controlPopVar( alpha = .01, # significance level ) ) summary(modelInflated) #> #> Call: #> estimatePopsize.default(formula = capture ~ gender + age, data = netherlandsimmigrant, #> model = \"oiztgeom\", method = \"IRLS\", controlPopVar = controlPopVar(alpha = 0.01, #> )) #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.357193 -0.357193 -0.357193 0.000343 -0.287637 10.233608 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.5346 0.1846 -8.312 < 2e-16 *** #> gendermale 0.3863 0.1380 2.800 0.00512 ** #> age>40yrs -0.7788 0.2942 -2.648 0.00810 ** #> ----------------------- #> For linear predictors associated with: omega #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.7591 0.3765 -4.673 2.97e-06 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> #> AIC: 1736.854 #> BIC: 1759.01 #> Residual deviance: 1011.271 #> #> Log-likelihood: -864.4272 on 3756 Degrees of freedom #> Number of iterations: 6 #> ----------------------- #> Population size estimation results: #> Point estimate 5661.522 #> Observed proportion: 33.2% (N obs = 1880) #> Std. Error 963.9024 #> 99% CI for the population size: #> lowerBound upperBound #> normal 3178.674 8144.370 #> logNormal 3861.508 9096.681 #> 99% CI for the share of observed population: #> lowerBound upperBound #> normal 23.08343 59.14416 #> logNormal 20.66688 48.68564 modelInflated2 <- estimatePopsize( formula = capture ~ age, data = netherlandsimmigrant, popVar = \"bootstrap\", model = oiztgeom(omegaLink = \"cloglog\"), method = \"IRLS\", controlPopVar = controlPopVar( B = 500,# number of boostrap samples alpha = .01, # significance level # type of bootstrap see documentation for estimatePopsize bootType = \"semiparametric\", # control regression fitting on bootstrap samples bootstrapFitcontrol = controlMethod( epsilon = .Machine$double.eps, silent = TRUE, stepsize = 2 ) ), controlModel = controlModel(omegaFormula = ~ gender) # put covariates on omega i.e. the inflation parameter ) #> Warning in estimatePopsize.default(formula = capture ~ age, data = netherlandsimmigrant, : The (analytically computed) hessian of the score function is not negative define. #> NOTE: Second derivative test failing does not #> necessarily mean that the maximum of score function that was found #> numericaly is invalid since R^k is not a bounded space. #> Additionally in one inflated and hurdle models second derivative test often fails even on valid arguments. #> Warning in estimatePopsize.default(formula = capture ~ age, data = #> netherlandsimmigrant, : Switching from observed information matrix to Fisher #> information matrix because hessian of log-likelihood is not negative define. popSizeEst(modelInflated2) #> Point estimate: 5496.376 #> Variance: 1217986 #> 99% confidence intervals: #> lowerBound upperBound #> 4002.763 10231.716 plot(modelInflated2, plotType = \"bootHist\", labels = TRUE, ylim = c(0, 175), breaks = 15) #> First model: AIC = 1736.854 BIC = 1759.01 #> Second model: AIC = 1734.803 BIC = 1756.959"},{"path":"https://ncn-foreigners.github.io/singleRcapture/index.html","id":"funding","dir":"","previous_headings":"","what":"Funding","title":"Single-Source Capture-Recapture Models","text":"Work package supported National Science Centre, OPUS 20 grant . 2020/39/B/HS4/00941.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/carcassubmission.html","id":null,"dir":"Reference","previous_headings":"","what":"The British farm carcass submissions data — carcassubmission","title":"The British farm carcass submissions data — carcassubmission","text":"Data British animal farms submissions AHVLA. British farms able submit samples AHVLA cause death animal determined private veterinary surgeon decides submit , unless notifiable disease suspected submission required. data set contains information farms. submissions included data frame submissions carcasses .e. submissions blood samples etc. excluded.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/carcassubmission.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"The British farm carcass submissions data — carcassubmission","text":"","code":"data(\"carcassubmission\")"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/carcassubmission.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"The British farm carcass submissions data — carcassubmission","text":"Data frame 1,858 rows 4 columns. TOTAL_SUB Number submissions animal carcasses. log_size Numerical value equal logarithm size farm. log_distance Numerical value equal logarithm distance nearest AHVLA center. C_TYPE Factor describing type activity farm animals used . Either Dairy Beef","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/carcassubmission.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"The British farm carcass submissions data — carcassubmission","text":"data set description provided publication: Böhning, D., Vidal Diez, ., Lerdsuwansri, R., Viwatwongkasem, C., Arnold, M. (2013). \"generalization Chao's estimator covariate information\". Biometrics, 69(4), 1033-1042. doi:10.1111/biom.12082","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/confint.singleRStaticCountData.html","id":null,"dir":"Reference","previous_headings":"","what":"Confidence intervals for model parameters — confint.singleRStaticCountData","title":"Confidence intervals for model parameters — confint.singleRStaticCountData","text":"function computes studentized confidence intervals model coefficients.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/confint.singleRStaticCountData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confidence intervals for model parameters — confint.singleRStaticCountData","text":"","code":"# S3 method for class 'singleRStaticCountData' confint(object, parm, level = 0.95, ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/confint.singleRStaticCountData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confidence intervals for model parameters — confint.singleRStaticCountData","text":"object object singleRStaticCountData class. parm names parameters confidence intervals computed, missing parameters considered. level confidence level intervals. ... currently nothing.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/confint.singleRStaticCountData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confidence intervals for model parameters — confint.singleRStaticCountData","text":"object named columns include upper lower limit confidence intervals.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlMethod.html","id":null,"dir":"Reference","previous_headings":"","what":"Control parameters for regression — controlMethod","title":"Control parameters for regression — controlMethod","text":"controlMethod constructs list necessary control parameters regression fitting estimatePopsizeFit estimatePopsize.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlMethod.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control parameters for regression — controlMethod","text":"","code":"controlMethod( epsilon = 1e-08, maxiter = 1000, verbose = 0, printEveryN = 1L, coefStart = NULL, etaStart = NULL, optimMethod = \"Nelder-Mead\", silent = FALSE, optimPass = FALSE, stepsize = 1, checkDiagWeights = TRUE, weightsEpsilon = 1e-08, momentumFactor = 0, saveIRLSlogs = FALSE, momentumActivation = 5, criterion = c(\"coef\", \"abstol\", \"reltol\") )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlMethod.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control parameters for regression — controlMethod","text":"epsilon tolerance level fitting algorithms default 1e-8. maxiter maximum number iterations. verbose numeric value indicating whether trace steps fitting algorithm IRLS fitting method different values verbose give following information: 1 – Returns information number current iteration current log-likelihood. 2 – Returns information vector regression parameters current iteration (). 3 – Returns information reduction log-likelihood current iteration (). 4 – Returns information value log-likelihood function gradient current iteration (). 5 – Returns information convergence criterion values taken account considering convergence (). optim method chosen verbose passed stats::optim() trace. printEveryN integer value indicating often print information specified verbose, default set 1. coefStart, etaStart initial parameters regression coefficients linear predictors NULL. IRLS fitting etaStart needed coefStart provided converted etaStart, optim fitting coefStart necessary argument etaStart ignored. optimMethod method stats::optim() used \"Nelder-Mead\" default . silent logical value, indicating whether warnings IRLS method suppressed. optimPass optional list parameters passed stats::optim(..., control = optimPass) FALSE list control parameters inferred parameters. stepsize IRLS, scaling updates beta vector lower value means slower convergence accuracy default 1. general fitting algorithm fails lowering value tends effective correcting . checkDiagWeights logical value indicating whether check diagonal elements working weights matrixes IRLS sufficiently positive matrixes positive defined. default TRUE. weightsEpsilon small number ensure positive definedness weights matrixes. matters checkDiagWeights set TRUE. default 1e-8. momentumFactor experimental parameter IRLS allowing taking previous step account current step, .e instead updating regression parameters : _() = _(-1) + stepsize step_() update made : _() = _(-1) + stepsize (step_() + momentumstep_(-1)) saveIRLSlogs logical value indicating information specified verbose saved output object, default FALSE. momentumActivation value log-likelihood reduction bellow momentum apply. criterion criterion used determine convergence IRLS, multiple values may provided. default c(\"coef\", \"abstol\").","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlMethod.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control parameters for regression — controlMethod","text":"List selected parameters, also possible call list directly.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlMethod.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Control parameters for regression — controlMethod","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlModel.html","id":null,"dir":"Reference","previous_headings":"","what":"Control parameters specific to some models — controlModel","title":"Control parameters specific to some models — controlModel","text":"controlModel constructs list necessary control parameters estimatePopsize either specific selected model fit anywhere else. Specifying additional formulas done using right hand side formula also now variables additional formulas also included \"main\" formula.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlModel.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control parameters specific to some models — controlModel","text":"","code":"controlModel( weightsAsCounts = FALSE, omegaFormula = ~1, alphaFormula = ~1, piFormula = ~1 )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlModel.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control parameters specific to some models — controlModel","text":"weightsAsCounts boolean value indicating whether treat weights argument number occurrences row data adjust necessary methods functionalities, like adjustments bootstrap decreasing weights dfbeta instead deleting rows data, accommodate form model specification. omegaFormula formula inflation parameter one inflated zero truncated zero truncated one inflated models. alphaFormula formula dispersion parameter negative binomial based models. piFormula formula probability parameter pseudo hurdle zero truncated zero truncated pseudo hurdle models.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlModel.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control parameters specific to some models — controlModel","text":"list selected parameters, also possible call list directly.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlModel.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Control parameters specific to some models — controlModel","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlPopVar.html","id":null,"dir":"Reference","previous_headings":"","what":"Control parameters for population size estimation — controlPopVar","title":"Control parameters for population size estimation — controlPopVar","text":"Creating control parameters population size estimation respective standard error variance estimation.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlPopVar.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control parameters for population size estimation — controlPopVar","text":"","code":"controlPopVar( alpha = 0.05, bootType = c(\"parametric\", \"semiparametric\", \"nonparametric\"), B = 500, confType = c(\"percentilic\", \"normal\", \"basic\"), keepbootStat = TRUE, traceBootstrapSize = FALSE, bootstrapVisualTrace = FALSE, fittingMethod = c(\"optim\", \"IRLS\"), bootstrapFitcontrol = NULL, sd = c(\"sqrtVar\", \"normalMVUE\"), covType = c(\"observedInform\", \"Fisher\"), cores = 1L )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlPopVar.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control parameters for population size estimation — controlPopVar","text":"alpha significance level, 0.05 used default. bootType bootstrap type used. Default \"parametric\", possible values : \"semiparametric\" \"nonparametric\". B number bootstrap samples performed (default 500). confType type confidence interval bootstrap confidence interval, \"percentile\" default. possibilities: \"studentized\" \"basic\". keepbootStat boolean value indicating whether keep vector statistics produced bootstrap. traceBootstrapSize boolean value indicating whether print size bootstrapped sample truncation semi- fully parametric bootstraps. bootstrapVisualTrace boolean value indicating whether plot bootstrap statistics real time cores = 1 cores > 1 instead indicates whether make progress bar. fittingMethod method used fitting models bootstrap samples. bootstrapFitcontrol control parameters regression works exactly like controlMethod fitting models bootstrap samples. sd character indicating compute standard deviation population size estimator either : =var(N) sqrt (slightly biased N normal distribution) normalMVUE unbiased minimal variance estimator normal distribution: =var(N) (N_obs-12)(N_obs2) N_obs2 ration involving gamma functions computed log gamma function. covType type covariance matrix regression parameters default observed information matrix. cores bootstrap , number processor cores used, number greater 1 activates code designed doParallel, foreach parallel packages. Note now using parallel computing makes tracing impossible traceBootstrapSize bootstrapVisualTrace parameters ignored case.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlPopVar.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control parameters for population size estimation — controlPopVar","text":"list selected parameters, also possible call list directly.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/controlPopVar.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Control parameters for population size estimation — controlPopVar","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":null,"dir":"Reference","previous_headings":"","what":"Single-source capture-recapture models — estimatePopsize","title":"Single-source capture-recapture models — estimatePopsize","text":"estimatePopsize first fits appropriate (v)glm model estimates full (observed unobserved) population size. types models assumed response vector (.e. dependent variable) corresponds number times given unit observed source. Population size usually estimated Horvitz-Thompson type estimator: N = _k=1^NI_kP(Y_k>0) = _k=1^N_obs11-P(Y_k=0) I_k=I_Y_k > 0 indicator variables, value 1 kth unit observed least 0 otherwise.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Single-source capture-recapture models — estimatePopsize","text":"","code":"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\"), 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, ratioReg = FALSE, offset, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Single-source capture-recapture models — estimatePopsize","text":"formula formula model fitted, applied \"main\" linear predictor. single response models available. ... additional optional arguments passed methods eg. estimatePopsizeFit. data data frame object coercible data.frame class containing data regression population size estimation. model model regression population estimate full description singleRmodels(). weights optional object prior weights used fitting model. Can used specify number occurrences rows data see controlModel() subset logical vector indicating observations used regression population size estimation. evaluated data argument provided call. naAction yet implemented. method method fitting values currently supported: iteratively reweighted least squares (IRLS) maximum likelihood (optim). popVar method constructing confidence interval estimating standard error either analytic bootstrap. Bootstrap confidence interval type may specified controlPopVar. also third possible value noEst skips population size estimate together. controlMethod list indicating parameters use fitting model may constructed singleRcapture::controlMethod function. information included controlMethod(). controlModel list indicating additional formulas regression (like formula inflation parameter/dispersion parameter) may constructed singleRcapture::controlModel function. information eventually included controlModel(). controlPopVar list indicating parameters use estimating variance population size estimation may constructed singleRcapture::controlPopVar function. information included controlPopVar(). modelFrame, x, y logical values indicating whether return model matrix, dependent vector model matrix part output. contrasts yet implemented. ratioReg yet implemented offset matrix offset values number columns matching number distribution parameters providing offset values linear predictors.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Single-source capture-recapture models — estimatePopsize","text":"Returns object class c(\"singleRStaticCountData\", \"singleR\", \"glm\", \"lm\") type list containing: y – Vector dependent variable specified function call. X – Model matrix specified function call. formula – list formula provided call additional formulas specified controlModel. call – Call matching original input. coefficients – vector fitted coefficients regression. control – list control parameters controlMethod controlModel, controlPopVar included populationSize. model – Model estimation population size regression built, object class family. deviance – Deviance model. priorWeights – Prior weight provided call. weights – IRLS method estimation chosen weights returned IRLS, otherwise priorWeights. residuals – Vector raw residuals. logL – Logarithm likelihood obtained final iteration. iter – Numbers iterations performed fitting stats::optim used number call loglikelihood function. dfResiduals – Residual degrees freedom. dfNull – Null degrees freedom. fittValues – Data frame fitted values mu (expected value) lambda (Poisson parameter). populationSize – list containing information population size estimate. modelFrame – Model frame specified call. linearPredictors – Vector fitted linear predictors. sizeObserved – Number observations original model frame. terms – terms attribute model frame used. contrasts – contrasts specified function call. naAction – naAction used. – list indicating observations used regression/population size estimation. fittingLog – log fitting information \"IRLS\" fitting specified controlMethod.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Single-source capture-recapture models — estimatePopsize","text":"generalized linear model characterized equation =X X (lm) model matrix. vector generalized linear model similarly characterized equations _k=X_k_k X_k (lm) model matrix constructed appropriate formula (specified controlModel parameter). vector constructed : =pmatrix _1 _2 _p pmatrix^T cases models package (vlm) model matrix constructed block matrix: X_vlm= pmatrix X_1 & 0 & &0 0 & X_2 & &0 & & & 0 & 0 & &X_p pmatrix differs convention VGAM package (consider special cases vglm models) just convention affect model, convention taken makes fitting IRLS (explanation algorithm estimatePopsizeFit()) algorithm easier. (constraints matrixes vglm match ones implicitly use vglm model matrix differs respect order kronecker multiplication X constraints.) package use observed likelihood fit regression models. mentioned usually population size estimation done via: N = _k=1^NI_kP(Y_k>0) = _k=1^N_obs11-P(Y_k=0) I_k=I_Y_k > 0 indicator variables, value 1 kth unit observed least 0 otherwise. P(Y_k>0) estimated maximum likelihood. following assumptions usually present using method estimation described : specified regression model correct. entails linear relationship independent variables dependent ones dependent variable generated appropriate distribution. unobserved heterogeneity. assumption broken possible (admittedly imperfect) workarounds see details singleRmodels(). population size constant relevant time frame. Depending confidence interval construction (asymptotic) normality N statistic assumed. two ways estimating variance estimate N, first \"analytic\" usually done application law total variance N: var(N)=E(var (N|I_1,...,I_n))+ var(E(N|I_1,...,I_n)) method N|I_1,... I_N: E(var (N|I_1,...,I_n))= .((N|I_1,...,I_N))^T cov() ((N|I_1,...,I_N)) |_= var(E(N|I_1,...,I_n)) term may derived analytically (assume independence observations) since N|I_1,...,I_n just constant. general gives us: aligned var(E(N|I_1,...,I_n))&= var(_k=1^NI_kP(Y_k>0)) &=_k=1^Nvar(I_kP(Y_k>0)) &=_k=1^N1P(Y_k>0)^2var(I_k) &=_k=1^N1P(Y_k>0)^2P(Y_k>0)(1-P(Y_k>0)) &=_k=1^N1P(Y_k>0)(1-P(Y_k>0)) &_k=1^NI_kP(Y_k>0)^2(1-P(Y_k>0)) &=_k=1^N_obs1-P(Y_k>0)P(Y_k>0)^2 aligned approximation 6th line appears 5th line sum units, includes unobserved units, since I_k independent I_k b(P(Y_k>0)) 6th line unbiased estimator 5th line. method estimating variance \"bootstrap\", since N_obs=_k=1^NI_k also random variable bootstrap simple just drawing N_obs units data replacement just computing N. Method described referred literature \"nonparametric\" bootstrap (see controlPopVar()), due ignoring variability observed sample size likely underestimate variance. sophisticated bootstrap procedure may described follows: Compute probability distribution : f_0N, f_1N, ..., f_yN f_n denotes observed marginal frequency units observed exactly n times. Draw N units distribution (N integer draw N + b(N-N)), floor function. Truncated units y=0. covariates draw original data replacement uniform distribution. example unit drawn new data y=2 choose one covariate vectors original data associated unit observed 2 times. Regress y_new X_vlm new obtain _new, starting point make slightly faster, use compute N_new. Repeat 2-5 unit least B statistics obtained. Compute confidence intervals based alpha confType specified controlPopVar(). step 1 procedure convenient first draw binary vector length N + b(N-N) probability 1-f_0N, sum elements vector determine sample size draw sample size uniformly data. procedure known literature \"semiparametric\" bootstrap necessary assume correct estimate N order use type bootstrap. Lastly \"paramteric\" bootstrap assume probabilistic model used obtain N correct bootstrap procedure may described : Draw N + b(N-N) covariate information vectors replacement data according probability distribution proportional : N_k, N_k contribution kth unit .e. 1P(Y_k>0). Determine matrix using estimate . Generate y (dependent variable) vector using probability mass function associated chosen model. Truncated units y=0 construct y_new X_vlm new. Regress y_new X_vlm new obtain _new use compute N_new. Repeat 1-5 unit least B statistics obtained. Compute confidence intervals based alpha confType specified controlPopVar() also worth noting \"analytic\" method estimatePopsize uses \"standard\" covariance matrix estimation. possible improper covariance matrix estimate part estimation assumptions violated. cases post-hoc procedures implemented package address issue. Lastly confidence intervals N computed (analytic case) either assuming follows normal distribution variable (N-N) follows normal distribution. estimates may found using either summary.singleRStaticCountData method popSizeEst.singleRStaticCountData function. labelled normal logNormal respectively.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Single-source capture-recapture models — estimatePopsize","text":"General single source capture recapture literature: Zelterman, Daniel (1988). ‘Robust estimation truncated discrete distributions application capture-recapture experiments’. : Journal statistical planning inference 18.2, pp. 225–237. Heijden, Peter GM van der et al. (2003). ‘Point interval estimation population size using truncated Poisson regression model’. : Statistical Modelling 3.4, pp. 305–322. doi: 10.1191/1471082X03st057oa. Cruyff, Maarten J. L. F. Peter G. M. van der Heijden (2008). ‘Point Interval Estimation Population Size Using Zero-Truncated Negative Binomial Regression Model’. : Biometrical Journal 50.6, pp. 1035–1050. doi: 10.1002/bimj.200810455 Böhning, Dankmar Peter G. M. van der Heijden (2009). ‘covariate adjustment zero-truncated approaches estimating size hidden elusive populations’. : Annals Applied Statistics 3.2, pp. 595–610. doi: 10.1214/08-AOAS214. Böhning, Dankmar, Alberto Vidal-Diez et al. (2013). ‘Generalization Chao’s Estimator Covariate Information’. : Biometrics 69.4, pp. 1033– 1042. doi: 10.1111/biom.12082 Böhning, Dankmar Peter G. M. van der Heijden (2019). ‘identity zero-truncated, one-inflated likelihood zero-one-truncated likelihood general count densities application drink-driving Britain’. : Annals 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 robust estimation population size zero-truncated clustered Data. Biom J. 2008 Aug;50(4):584-96. doi: 10.1002/bimj.200710441. Böhning D. equivalence one-inflated zero-truncated 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 sparse count data. Stat Methods Appl 30, 1197–1217 (2021). doi: 10.1007/s10260-021-00556-8 Bootstrap: Zwane, PGM EN Van der Heijden, Implementing parametric bootstrap capture-recapture models continuous covariates 2003 Statistics & probability letters 65.2 pp 121-125 Norris, James L Pollock, Kenneth H Including model uncertainty estimating variances multiple capture studies 1996 Environmental Ecological Statistics 3.3 pp 235-244 Vector generalized linear models: Yee, T. W. (2015). Vector Generalized Linear Additive Models: Implementation R. New York, USA: Springer. ISBN 978-1-4939-2817-0.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Single-source capture-recapture models — estimatePopsize","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsize.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Single-source capture-recapture models — estimatePopsize","text":"","code":"# \\donttest{ # 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) #> #> Call: #> estimatePopsize.default(formula = capture ~ gender + age + nation, #> data = netherlandsimmigrant, model = ztpoisson) #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.486442 -0.486442 -0.298080 0.002093 -0.209444 13.910844 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.3411 0.2149 -6.241 4.35e-10 *** #> gendermale 0.3972 0.1630 2.436 0.014832 * #> age>40yrs -0.9746 0.4082 -2.387 0.016972 * #> nationAsia -1.0926 0.3016 -3.622 0.000292 *** #> nationNorth Africa 0.1900 0.1940 0.979 0.327398 #> nationRest of Africa -0.9106 0.3008 -3.027 0.002468 ** #> nationSurinam -2.3364 1.0136 -2.305 0.021159 * #> nationTurkey -1.6754 0.6028 -2.779 0.005445 ** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 1712.901 #> BIC: 1757.213 #> Residual deviance: 1128.553 #> #> Log-likelihood: -848.4504 on 1872 Degrees of freedom #> Number of iterations: 8 #> ----------------------- #> Population size estimation results: #> Point estimate 12690.35 #> Observed proportion: 14.8% (N obs = 1880) #> Std. Error 2808.169 #> 95% CI for the population size: #> lowerBound upperBound #> normal 7186.444 18194.26 #> logNormal 8431.275 19718.32 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 10.332927 26.16037 #> logNormal 9.534281 22.29793 # Graphical presentation of model fit plot(model, \"rootogram\") # Statistical test # see documentation for summary.singleRmargin summary(marginalFreq(model), df = 1, \"group\") #> Test for Goodness of fit of a regression model: #> #> Test statistics df P(>X^2) #> Chi-squared test 50.06 1 1.5e-12 #> G-test 34.31 1 4.7e-09 #> #> -------------------------------------------------------------- #> Cells with fitted frequencies of < 5 have been grouped #> Names of cells used in calculating test(s) statistic: 1 2 3 # 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) #> #> Call: #> estimatePopsize.default(formula = TOTAL_SUB ~ ., data = farmsubmission, #> model = ztnegbin, method = \"optim\") #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.71322 -0.33627 -0.14256 0.00001 0.14745 7.01427 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -3.17536 0.25947 -12.238 < 2e-16 *** #> log_size 0.63932 0.01771 36.102 < 2e-16 *** #> log_distance -0.07935 0.02228 -3.561 0.000369 *** #> C_TYPEDairy 0.65919 0.03412 19.317 < 2e-16 *** #> ----------------------- #> For linear predictors associated with: alpha #> Estimate Std. Error z value P(>|z|) #> (Intercept) 0.58238 0.07299 7.979 1.48e-15 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 34538.73 #> BIC: 34575.71 #> Residual deviance: 17730.07 #> #> Log-likelihood: -17264.37 on 24067 Degrees of freedom #> Number of calls to log-likelihood function: 654 #> ----------------------- #> Population size estimation results: #> Point estimate 41019.07 #> Observed proportion: 29.3% (N obs = 12036) #> Std. Error 1888.039 #> 95% CI for the population size: #> lowerBound upperBound #> normal 37318.59 44719.56 #> logNormal 37548.53 44961.73 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 26.91440 32.25203 #> logNormal 26.76943 32.05452 summary(marginalFreq(modelNegBin)) #> Test for Goodness of fit of a regression model: #> #> Test statistics df P(>X^2) #> Chi-squared test 30.93 26 0.23 #> G-test 19.12 26 0.83 #> #> -------------------------------------------------------------- #> Cells with fitted frequencies of < 5 have been dropped #> Names of cells used in calculating test(s) statistic: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 # 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) ) #> Iteration number 1 log-likelihood: -846.77533 #> Parameter vector: -1.52435898 -0.62008047 0.16074142 -0.49971856 -0.85750609 -0.78860226 -0.42067526 -0.44312806 -0.70241852 #> log-likelihood reduction: Inf #> Value of gradient at current step: #> 142.04204576 8.81177229 108.34506498 9.81769037 -0.39315787 1.30854693 2.40548998 -74.87532567 -61.35856914 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 1.524359 #> ---- #> Iteration number 2 log-likelihood: -828.37292 #> Parameter vector: -1.11072318 -0.66579168 0.16032836 -0.51705318 -1.27720523 -0.93384649 -0.55851513 -0.52578104 -0.41829231 #> log-likelihood reduction: 18.402407 #> Value of gradient at current step: #> -30.198518684 -2.367348700 -20.882807839 -2.990134863 -0.033406007 -0.236178150 -0.291286777 12.908733472 8.061651997 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.41969914 #> ---- #> Iteration number 3 log-likelihood: -827.03041 #> Parameter vector: -1.26212005 -0.65481997 0.16367571 -0.51638838 -1.22088469 -0.89969898 -0.52141633 -0.61358371 -0.51802941 #> log-likelihood reduction: 1.3425075 #> Value of gradient at current step: #> -0.399477106 -0.125534668 -0.025207083 -0.124263770 -0.012272383 -0.001036293 -0.037255028 -0.402440790 -0.559697165 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.15139687 #> ---- #> Iteration number 4 log-likelihood: -827.01868 #> Parameter vector: -1.28179260 -0.65559457 0.16445074 -0.51702724 -1.22154349 -0.89783555 -0.52232876 -0.64032726 -0.52639838 #> log-likelihood reduction: 0.011729135 #> Value of gradient at current step: #> 0.01965800195 -0.00376668640 0.02342526604 0.00085753707 -0.00131148043 0.00040402353 -0.00468611749 -0.01113423867 -0.00978879207 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.026743552 #> ---- #> Iteration number 5 log-likelihood: -827.01868 #> Parameter vector: -1.28177518 -0.65568959 0.16449297 -0.51701807 -1.22190483 -0.89779857 -0.52262758 -0.64032669 -0.52640250 #> log-likelihood reduction: 0.0000018094989 #> Value of gradient at current step: #> -0.0001561899387 0.0000207886459 -0.0000413107753 -0.0000259493362 0.0000040518562 -0.0000068413444 -0.0000222504320 0.0000011784080 0.0000010016067 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.00036133989 #> ---- #> Iteration number 6 log-likelihood: -827.01868 #> Parameter vector: -1.28177959 -0.65568717 0.16449471 -0.51701668 -1.22190170 -0.89779724 -0.52262830 -0.64033172 -0.52640214 #> log-likelihood reduction: 0.00000000032207481 #> Value of gradient at current step: #> 0.00000138172839925 -0.00000029541573543 0.00000194942825438 0.00000005064943620 -0.00000001912655101 0.00000005032669892 -0.00000167462238743 -0.00000000020190338 -0.00000000017657165 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.0000050277134 #> ---- #> Value of analytically computed hessian at fitted regression coefficients: #> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] -600.647579 -45.430239 -437.78550 -46.3057511 -3.648625 -9.9715730 #> [2,] -45.430239 -45.430239 0.00000 0.0000000 0.000000 0.0000000 #> [3,] -437.785496 0.000000 -437.78550 0.0000000 0.000000 0.0000000 #> [4,] -46.305751 0.000000 0.00000 -46.3057511 0.000000 0.0000000 #> [5,] -3.648625 0.000000 0.00000 0.0000000 -3.648625 0.0000000 #> [6,] -9.971573 0.000000 0.00000 0.0000000 0.000000 -9.9715730 #> [7,] -17.976683 -2.320732 -11.24212 -0.6903141 -2.003224 -0.2486649 #> [8,] 328.022454 23.801161 241.35686 24.3769265 1.870670 5.1505625 #> [9,] 280.048801 20.260808 211.90055 19.7419682 1.462128 4.6637718 #> [,7] [,8] [,9] #> [1,] -17.9766828 328.022454 280.048801 #> [2,] -2.3207316 23.801161 20.260808 #> [3,] -11.2421165 241.356859 211.900549 #> [4,] -0.6903141 24.376927 19.741968 #> [5,] -2.0032237 1.870670 1.462128 #> [6,] -0.2486649 5.150563 4.663772 #> [7,] -17.9766828 9.477666 8.492258 #> [8,] 9.4776658 -197.098079 -168.419176 #> [9,] 8.4922579 -168.419176 -168.419176 #> The matrix above has the following eigen values: #> -3.121074 -6.868861 -9.331036 -16.61098 -18.10422 -33.99724 -45.94396 -112.7247 -1280.581 summary(pseudoHurdleModel) #> #> Call: #> estimatePopsize.default(formula = capture ~ nation + age, data = netherlandsimmigrant, #> model = Hurdleztgeom, method = \"IRLS\", controlMethod = controlMethod(verbose = 5), #> controlModel = controlModel(piFormula = ~gender)) #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.428461 -0.428461 -0.288574 0.004918 -0.181672 13.696149 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.2818 0.1858 -6.899 5.22e-12 *** #> nationAsia -0.6557 0.1994 -3.289 0.00101 ** #> nationNorth Africa 0.1645 0.1417 1.161 0.24561 #> nationRest of Africa -0.5170 0.1979 -2.612 0.00900 ** #> nationSurinam -1.2219 0.5552 -2.201 0.02775 * #> nationTurkey -0.8978 0.3439 -2.611 0.00903 ** #> age>40yrs -0.5226 0.2469 -2.117 0.03429 * #> ----------------------- #> For linear predictors associated with: pi #> Estimate Std. Error z value P(>|z|) #> (Intercept) -0.6403 0.2945 -2.174 0.02969 * #> gendermale -0.5264 0.2043 -2.577 0.00996 ** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 1672.037 #> BIC: 1721.889 #> Residual deviance: 1492.301 #> #> Log-likelihood: -827.0187 on 3751 Degrees of freedom #> Number of iterations: 6 #> ----------------------- #> Population size estimation results: #> Point estimate 6446.833 #> Observed proportion: 29.2% (N obs = 1880) #> Std. Error 1126.716 #> 95% CI for the population size: #> lowerBound upperBound #> normal 4238.511 8655.156 #> logNormal 4715.983 9234.051 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 21.72116 44.35520 #> logNormal 20.35943 39.86443 # Assessing model fit plot(pseudoHurdleModel, \"rootogram\") summary(marginalFreq(pseudoHurdleModel), \"group\", df = 1) #> Test for Goodness of fit of a regression model: #> #> Test statistics df P(>X^2) #> Chi-squared test 1.89 1 0.17 #> G-test 2.13 1 0.14 #> #> -------------------------------------------------------------- #> Cells with fitted frequencies of < 5 have been grouped #> Names of cells used in calculating test(s) statistic: 1 2 3 4 # 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)) #> Test for Goodness of fit of a regression model: #> #> Test statistics df P(>X^2) #> Chi-squared test 54.98 11 7.8e-08 #> G-test 23.06 11 1.7e-02 #> #> -------------------------------------------------------------- #> Cells with fitted frequencies of < 5 have been dropped #> Names of cells used in calculating test(s) statistic: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 summary(Model) #> #> Call: #> estimatePopsize.default(formula = TOTAL_SUB ~ ., data = farmsubmission, #> model = oiztgeom(omegaLink = \"cloglog\"), method = \"IRLS\", #> controlMethod = controlMethod(stepsize = 0.85, momentumFactor = 1.2, #> epsilon = 1e-10, silent = TRUE), controlModel = controlModel(omegaFormula = ~C_TYPE + #> log_size)) #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.891103 -0.644972 -0.443066 0.005967 0.295374 20.809832 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -2.76388 0.23858 -11.585 < 2e-16 *** #> log_size 0.62734 0.01787 35.110 < 2e-16 *** #> log_distance -0.07200 0.02004 -3.593 0.000327 *** #> C_TYPEDairy 0.50965 0.04032 12.640 < 2e-16 *** #> ----------------------- #> For linear predictors associated with: omega #> Estimate Std. Error z value P(>|z|) #> (Intercept) -5.0973 0.8268 -6.165 7.03e-10 *** #> C_TYPEDairy -1.4002 0.3700 -3.784 0.000154 *** #> log_size 0.4461 0.1330 3.354 0.000795 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 34579.91 #> BIC: 34631.68 #> Residual deviance: 12327.24 #> #> Log-likelihood: -17282.96 on 24065 Degrees of freedom #> Number of iterations: 13 #> ----------------------- #> Population size estimation results: #> Point estimate 27249.03 #> Observed proportion: 44.2% (N obs = 12036) #> Std. Error 972.0123 #> 95% CI for the population size: #> lowerBound upperBound #> normal 25343.92 29154.13 #> logNormal 25460.09 29276.36 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 41.28402 47.49069 #> logNormal 41.11166 47.27399 # }"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":null,"dir":"Reference","previous_headings":"","what":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"estimatePopsizeFit estimatePopsize glm.fit glm. internally called estimatePopsize. Since estimatePopsize much just regression fitting estimatePopsizeFit much faster.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"","code":"estimatePopsizeFit( y, X, family, control, method, priorWeights, coefStart, etaStart, offset, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"y vector dependent variables. X model matrix, vglm one. family model estimatePopsize. control control parameters created controlModel. method method estimation estimatePopsize. priorWeights vector prior weights argument weights estimatePopsize. etaStart, coefStart initial value regression parameters linear predictors. offset offset passed default passed estimatePopsize(). ... arguments pass methods.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"List regression parameters, working weights (IRLS fitting method) chosen number iterations taken.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"method argument set \"optim\" stats::optim function used fit regression analytically computed gradient (minus) log likelihood functions gr fn arguments. Unfortunately optim allow hessian specified. information modify optim fitting included controlMethod(). method argument set \"IRLS\" iteratively reweighted least squares. algorithm well know generalised linear models. Thomas W. Yee later extended algorithm vector generalised linear models general terms can roughly described (Yee's description changing conventions): Initialize : converged <- FALSE iter <- 1 <- start W <- prior <- () converged iter > Maxiter move step 7. Store values previous algorithm step: W_- <- W _- <- _- <- assign values current step: <- X_vlm Z_i <- _i+_i_i E(^2_i _i^T_i)^-1 W_ij <- E(^2 _j^T_i) _i ith component log likelihood function, _i vector linear predictors associated ith row E(^2_i _i^T_i) corresponds weights associated ith row W block matrix, made diagonal matrixes E(^2 _j^T_i) Regress Z X_vlm obtain : = (X_vlm^TWX_vlm)^-1 X_vlm^TWZ Assign: converged <- ()-_- < _- ||-_-||_ < iter <- iter + 1 relative tolerance level, default 1e-8. Return step 2. Return , W, iter. package use different conventions X_vlm matrix hence slight differences present algorithm description results identical.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"Yee, T. W. (2015). Vector Generalized Linear Additive Models: Implementation R. New York, USA: Springer. ISBN 978-1-4939-2817-0.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"Piotr Chlebicki, Maciej Beresewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/estimatePopsizeFit.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Regression fitting in single-source capture-recapture models — estimatePopsizeFit","text":"","code":"# \\donttest{ summary(farmsubmission) #> TOTAL_SUB log_size log_distance C_TYPE #> Min. : 1.00 Min. : 0.000 Min. : 4.102 Beef :5336 #> 1st Qu.: 1.00 1st Qu.: 4.673 1st Qu.:10.351 Dairy:6700 #> Median : 1.00 Median : 5.347 Median :10.778 #> Mean : 2.34 Mean : 5.259 Mean :10.662 #> 3rd Qu.: 3.00 3rd Qu.: 5.940 3rd Qu.:11.099 #> Max. :47.00 Max. :10.480 Max. :12.097 # construct vglm model matrix X <- matrix(data = 0, nrow = 2 * NROW(farmsubmission), ncol = 7) X[1:NROW(farmsubmission), 1:4] <- model.matrix( ~ 1 + log_size + log_distance + C_TYPE, farmsubmission ) X[-(1:NROW(farmsubmission)), 5:7] <- X[1:NROW(farmsubmission), c(1, 3, 4)] # this attribute tells the function which elements of the design matrix # correspond to which linear predictor attr(X, \"hwm\") <- c(4, 3) # get starting points start <- glm.fit( y = farmsubmission$TOTAL_SUB, x = X[1:NROW(farmsubmission), 1:4], family = poisson() )$coefficients res <- estimatePopsizeFit( y = farmsubmission$TOTAL_SUB, X = X, method = \"IRLS\", priorWeights = 1, family = ztoigeom(), control = controlMethod(verbose = 5), coefStart = c(start, 0, 0, 0), etaStart = matrix(X %*% c(start, 0, 0, 0), ncol = 2), offset = cbind(rep(0, NROW(farmsubmission)), rep(0, NROW(farmsubmission))) ) #> Iteration number 1 log-likelihood: -17455.372 #> Parameter vector: -2.255494347 0.521900283 -0.048255922 0.321168020 -1.297382847 0.049409082 -0.726587214 #> log-likelihood reduction: Inf #> Value of gradient at current step: #> 639.53919 4035.62183 6732.72078 672.31223 -316.39394 -3358.16739 -229.50394 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 2.2554943 #> ---- #> Iteration number 2 log-likelihood: -17289.531 #> Parameter vector: -2.859491920 0.627917105 -0.063516471 0.573159952 -2.327571214 0.074464787 -0.734988992 #> log-likelihood reduction: 165.84115 #> Value of gradient at current step: #> 77.37365182 329.72667483 823.92206208 0.28711463 -53.27713944 -568.21808076 -29.69092406 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 1.0301884 #> ---- #> Iteration number 3 log-likelihood: -17279.272 #> Parameter vector: -2.710874025 0.613067896 -0.069548715 0.537208696 -2.550651004 0.071488122 -0.939145580 #> log-likelihood reduction: 10.258788 #> Value of gradient at current step: #> 35.9649654 218.1210745 385.4441808 32.8759028 -6.8429684 -71.8589804 -5.7178443 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.22307979 #> ---- #> Iteration number 4 log-likelihood: -17278.776 #> Parameter vector: -2.78426085 0.61628333 -0.06440012 0.53843272 -3.10491635 0.12060422 -1.04138882 #> log-likelihood reduction: 0.49548535 #> Value of gradient at current step: #> 1.67966432 11.13935043 16.42827781 1.15147049 -0.53787945 -5.57182317 -0.74695785 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.55426534 #> ---- #> Iteration number 5 log-likelihood: -17278.762 #> Parameter vector: -2.77818073 0.61674992 -0.06504016 0.53517478 -3.10447410 0.12145802 -1.08163762 #> log-likelihood reduction: 0.014133264 #> Value of gradient at current step: #> 0.232501334 2.204257359 2.694809270 0.131590616 -0.071608376 -0.605938875 -0.064356213 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.040248796 #> ---- #> Iteration number 6 log-likelihood: -17278.761 #> Parameter vector: -2.78602286 0.61698772 -0.06441877 0.53495927 -3.19325142 0.12969021 -1.08314735 #> log-likelihood reduction: 0.00072206104 #> Value of gradient at current step: #> -0.0149254818 -0.0442854059 -0.2585639448 -0.0671445437 -0.0089103073 -0.1428452786 -0.0408361062 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.088777321 #> ---- #> Iteration number 7 log-likelihood: -17278.761 #> Parameter vector: -2.783307402 0.617006834 -0.064659772 0.534565433 -3.160032510 0.126742033 -1.087078105 #> log-likelihood reduction: 0.000086867327 #> Value of gradient at current step: #> 0.0219006963 0.2137543748 0.2878052109 0.0210725209 -0.0038258075 -0.0055588958 0.0088000042 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.033218913 #> ---- #> Iteration number 8 log-likelihood: -17278.761 #> Parameter vector: -2.785132183 0.617029483 -0.064506904 0.534668321 -3.181900933 0.128724679 -1.085840518 #> log-likelihood reduction: 0.00002149725 #> Value of gradient at current step: #> -0.00917986045 -0.07823752476 -0.12764140888 -0.01528913767 0.00031447068 -0.01459257984 -0.00776040766 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.021868422 #> ---- #> Iteration number 9 log-likelihood: -17278.761 #> Parameter vector: -2.784182050 0.617023943 -0.064588093 0.534586386 -3.170374939 0.127687086 -1.086727858 #> log-likelihood reduction: 0.0000064244196 #> Value of gradient at current step: #> 0.00580810485 0.05244014331 0.07853720973 0.00778331027 -0.00057098473 0.00429221924 0.00373823937 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.011525994 #> ---- #> Iteration number 10 log-likelihood: -17278.761 #> Parameter vector: -2.784725925 0.617028507 -0.064541975 0.534626993 -3.176948180 0.128280435 -1.086273279 #> log-likelihood reduction: 0.0000019945583 #> Value of gradient at current step: #> -0.00307033641 -0.02728421582 -0.04201045320 -0.00448214637 0.00022935424 -0.00326931975 -0.00221219809 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.006573241 #> ---- #> Iteration number 11 log-likelihood: -17278.761 #> Parameter vector: -2.78442528 0.61702627 -0.06456754 0.53460327 -3.17330966 0.12795232 -1.08653540 #> log-likelihood reduction: 0.00000061988248 #> Value of gradient at current step: #> 0.00175710834 0.01568170298 0.02390375513 0.00247668338 -0.00014882078 0.00161926855 0.00120723718 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.0036385179 #> ---- #> Iteration number 12 log-likelihood: -17278.761 #> Parameter vector: -2.784593634 0.617027580 -0.064553239 0.534616288 -3.175346365 0.128136053 -1.086390890 #> log-likelihood reduction: 0.00000019314757 #> Value of gradient at current step: #> -0.000968762326 -0.008641334478 -0.013216142966 -0.001385713893 0.000077984443 -0.000953809247 -0.000679710380 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.0020367031 #> ---- #> Iteration number 13 log-likelihood: -17278.761 #> Parameter vector: -2.784499807 0.617026860 -0.064561213 0.534608978 -3.174211159 0.128033659 -1.086471902 #> log-likelihood reduction: 0.000000060121238 #> Value of gradient at current step: #> 0.000543879327 0.004849594744 0.007409081517 0.000772957752 -0.000044801247 0.000519451071 0.000377932800 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.0011352061 #> ---- #> Iteration number 14 log-likelihood: -17278.761 #> Parameter vector: -2.784552191 0.617027265 -0.064556762 0.534613048 -3.174844941 0.128090828 -1.086426773 #> log-likelihood reduction: 0.000000018728315 #> Value of gradient at current step: #> -0.00030256413 -0.00269909107 -0.00412482670 -0.00043127033 0.00002466148 -0.00029328220 -0.00021122304 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.00063378216 #> ---- #> Iteration number 15 log-likelihood: -17278.761 #> Parameter vector: -2.784522964 0.617027040 -0.064559245 0.534610775 -3.174491334 0.128058932 -1.086451974 #> log-likelihood reduction: 0.00000000583168 #> Value of gradient at current step: #> 0.000169118291 0.001508137320 0.002304647175 0.000240720362 -0.000013855243 0.000162719756 0.000117791115 #> Algorithm will terminate if one of following conditions will be met: #> The increase to minus log-likelihood will be bellow chosen value of epsilon 1e-08 #> Maximum change to the vector of regression parameters will be bellow the chosen value of epsilon. #> At current step the highest change was: 0.0003536072 #> ---- #> Value of analytically computed hessian at fitted regression coefficients: #> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] -5533.0360 -31139.1628 -58786.3824 -3921.3952 407.46348 23473.8262 #> [2,] -31139.1628 -179723.7217 -330742.8394 -22956.5461 4362.01544 1060.0139 #> [3,] -58786.3824 -330742.8394 -627035.9660 -41504.3671 185.81715 4362.0154 #> [4,] -3921.3952 -22956.5461 -41504.3671 -3921.3952 2193.72685 46845.5137 #> [5,] 407.4635 185.8172 46845.5137 1060.0139 -88.14760 -948.1115 #> [6,] 2193.7268 4362.0154 1971.9380 1971.9380 -948.11154 -10234.8910 #> [7,] 4362.0154 23473.8262 185.8172 185.8172 -28.97964 -312.6869 #> [,7] #> [1,] 1971.93804 #> [2,] 185.81715 #> [3,] 1971.93804 #> [4,] 185.81715 #> [5,] -28.97964 #> [6,] -312.68692 #> [7,] -28.97964 #> The matrix above has the following eigen values: #> -811159.7+0i -17207.51+0i -2161.919+9274.748i -2161.919-9274.748i 6057.218+0i 1581.239+0i -1513.504+0i # extract results # regression coefficient vector res$beta #> [1] -2.78452296 0.61702704 -0.06455925 0.53461077 -3.17449133 0.12805893 #> [7] -1.08645197 # check likelihood ll <- ztoigeom()$makeMinusLogLike(y = farmsubmission$TOTAL_SUB, X = X) -ll(res$beta) #> [1] -17278.76 # number of iterations res$iter #> [1] 15 # working weights head(res$weights) #> lambda mixed mixed omega #> [1,] 0.22688312 -0.03207963 -0.03207963 0.006351956 #> [2,] 0.66642253 -0.03199578 -0.03199578 0.006238854 #> [3,] 0.08469406 -0.01202233 -0.01202233 0.001899477 #> [4,] 0.14084340 -0.01990317 -0.01990317 0.003397031 #> [5,] 0.34099080 -0.04762290 -0.04762290 0.012045206 #> [6,] 0.42290801 -0.05782236 -0.05782236 0.018478738 # Compare with optim call res2 <- estimatePopsizeFit( y = farmsubmission$TOTAL_SUB, X = X, method = \"optim\", priorWeights = 1, family = ztoigeom(), coefStart = c(start, 0, 0, 0), control = controlMethod(verbose = 1, silent = TRUE), offset = cbind(rep(0, NROW(farmsubmission)), rep(0, NROW(farmsubmission))) ) #> Nelder-Mead direct search function minimizer #> function value for initial parameters = 18634.249443 #> Scaled convergence tolerance is 0.000186342 #> Stepsize computed as 0.082584 #> BUILD 8 20695.993313 18634.249443 #> LO-REDUCTION 10 20521.906450 18634.249443 #> REFLECTION 12 19390.030449 18203.536957 #> LO-REDUCTION 14 18936.678302 18203.536957 #> LO-REDUCTION 16 18749.996003 18203.536957 #> LO-REDUCTION 18 18737.148786 18203.536957 #> LO-REDUCTION 20 18718.703486 18203.536957 #> EXTENSION 22 18670.005025 17895.311480 #> LO-REDUCTION 24 18634.249443 17895.311480 #> LO-REDUCTION 26 18560.534560 17895.311480 #> EXTENSION 28 18449.746468 17588.420920 #> LO-REDUCTION 30 18295.895431 17588.420920 #> LO-REDUCTION 32 18222.396059 17588.420920 #> LO-REDUCTION 34 18203.536957 17588.420920 #> LO-REDUCTION 36 18087.422161 17588.420920 #> LO-REDUCTION 38 18005.031702 17588.420920 #> REFLECTION 40 18001.913029 17584.422405 #> REFLECTION 42 17895.311480 17527.021914 #> LO-REDUCTION 44 17780.944181 17527.021914 #> LO-REDUCTION 46 17712.559384 17527.021914 #> HI-REDUCTION 48 17643.578220 17527.021914 #> EXTENSION 50 17621.199586 17473.997274 #> LO-REDUCTION 52 17602.520321 17473.997274 #> HI-REDUCTION 54 17594.799573 17473.997274 #> LO-REDUCTION 56 17588.420920 17473.997274 #> LO-REDUCTION 58 17584.422405 17473.997274 #> EXTENSION 60 17556.846275 17447.303959 #> EXTENSION 62 17555.104630 17408.736552 #> LO-REDUCTION 64 17528.536402 17408.736552 #> LO-REDUCTION 66 17527.021914 17408.736552 #> EXTENSION 68 17511.009990 17375.624732 #> LO-REDUCTION 70 17506.001244 17375.624732 #> LO-REDUCTION 72 17473.997274 17375.624732 #> LO-REDUCTION 74 17459.682283 17375.624732 #> REFLECTION 76 17447.303959 17374.438952 #> EXTENSION 78 17431.820752 17359.678457 #> REFLECTION 80 17410.856537 17352.512930 #> LO-REDUCTION 82 17408.736552 17352.512930 #> LO-REDUCTION 84 17392.430571 17352.512930 #> LO-REDUCTION 86 17383.843739 17352.512930 #> LO-REDUCTION 88 17375.624732 17352.512930 #> HI-REDUCTION 90 17374.438952 17352.512930 #> REFLECTION 92 17364.440518 17351.391717 #> LO-REDUCTION 94 17361.269788 17351.391717 #> HI-REDUCTION 96 17359.678457 17351.391717 #> LO-REDUCTION 98 17359.333428 17351.391717 #> EXTENSION 100 17359.195000 17340.073149 #> LO-REDUCTION 102 17355.280449 17340.073149 #> LO-REDUCTION 104 17354.737924 17340.073149 #> LO-REDUCTION 106 17352.512930 17340.073149 #> LO-REDUCTION 108 17352.283989 17340.073149 #> EXTENSION 110 17351.931319 17334.816229 #> LO-REDUCTION 112 17351.391717 17334.816229 #> LO-REDUCTION 114 17349.077477 17334.816229 #> LO-REDUCTION 116 17346.861518 17334.816229 #> EXTENSION 118 17344.774811 17327.221865 #> LO-REDUCTION 120 17344.768718 17327.221865 #> EXTENSION 122 17340.363390 17314.895018 #> LO-REDUCTION 124 17340.073149 17314.895018 #> LO-REDUCTION 126 17337.014069 17314.895018 #> LO-REDUCTION 128 17336.611433 17314.895018 #> LO-REDUCTION 130 17334.816229 17314.895018 #> EXTENSION 132 17330.280767 17308.580216 #> LO-REDUCTION 134 17327.221865 17308.580216 #> LO-REDUCTION 136 17324.616040 17308.580216 #> REFLECTION 138 17320.961818 17307.339443 #> LO-REDUCTION 140 17320.314061 17307.339443 #> REFLECTION 142 17316.412981 17307.294606 #> LO-REDUCTION 144 17314.895018 17307.294606 #> HI-REDUCTION 146 17311.221319 17307.294606 #> REFLECTION 148 17310.240780 17305.855235 #> LO-REDUCTION 150 17309.024781 17305.855235 #> HI-REDUCTION 152 17308.580216 17305.855235 #> REFLECTION 154 17307.909389 17304.751271 #> LO-REDUCTION 156 17307.607430 17304.751271 #> HI-REDUCTION 158 17307.339443 17304.751271 #> EXTENSION 160 17307.294606 17303.969236 #> LO-REDUCTION 162 17306.726648 17303.969236 #> LO-REDUCTION 164 17306.486915 17303.969236 #> LO-REDUCTION 166 17306.013269 17303.969236 #> LO-REDUCTION 168 17305.855235 17303.969236 #> REFLECTION 170 17305.566500 17303.365745 #> HI-REDUCTION 172 17304.769833 17303.365745 #> LO-REDUCTION 174 17304.751271 17303.365745 #> EXTENSION 176 17304.679762 17302.760257 #> LO-REDUCTION 178 17304.415232 17302.760257 #> LO-REDUCTION 180 17304.272835 17302.760257 #> EXTENSION 182 17304.232531 17301.382173 #> LO-REDUCTION 184 17303.969236 17301.382173 #> LO-REDUCTION 186 17303.740306 17301.382173 #> LO-REDUCTION 188 17303.561302 17301.382173 #> LO-REDUCTION 190 17303.365745 17301.382173 #> REFLECTION 192 17303.285629 17301.216054 #> EXTENSION 194 17302.760257 17300.566315 #> EXTENSION 196 17302.374881 17299.438766 #> EXTENSION 198 17302.365881 17298.338665 #> EXTENSION 200 17301.538607 17296.617465 #> LO-REDUCTION 202 17301.386247 17296.617465 #> LO-REDUCTION 204 17301.382173 17296.617465 #> LO-REDUCTION 206 17301.216054 17296.617465 #> EXTENSION 208 17300.566315 17294.656203 #> EXTENSION 210 17299.438766 17292.415140 #> LO-REDUCTION 212 17298.338665 17292.415140 #> LO-REDUCTION 214 17297.787001 17292.415140 #> REFLECTION 216 17297.283737 17292.315917 #> REFLECTION 218 17296.776034 17290.819569 #> EXTENSION 220 17296.617465 17289.284957 #> LO-REDUCTION 222 17294.656203 17289.284957 #> LO-REDUCTION 224 17294.447369 17289.284957 #> LO-REDUCTION 226 17292.619840 17289.284957 #> REFLECTION 228 17292.415140 17289.050671 #> LO-REDUCTION 230 17292.315917 17289.050671 #> HI-REDUCTION 232 17290.819569 17289.050671 #> LO-REDUCTION 234 17290.333239 17289.050671 #> HI-REDUCTION 236 17290.198503 17289.050671 #> LO-REDUCTION 238 17290.030554 17289.050671 #> HI-REDUCTION 240 17289.707101 17289.050671 #> REFLECTION 242 17289.446684 17289.049956 #> REFLECTION 244 17289.402572 17288.762931 #> LO-REDUCTION 246 17289.314216 17288.762931 #> LO-REDUCTION 248 17289.284957 17288.762931 #> LO-REDUCTION 250 17289.237020 17288.755874 #> REFLECTION 252 17289.231432 17288.591829 #> LO-REDUCTION 254 17289.050671 17288.591829 #> HI-REDUCTION 256 17289.049956 17288.591829 #> LO-REDUCTION 258 17288.965069 17288.591829 #> LO-REDUCTION 260 17288.779011 17288.591829 #> LO-REDUCTION 262 17288.766114 17288.591829 #> REFLECTION 264 17288.762931 17288.553874 #> LO-REDUCTION 266 17288.760612 17288.553874 #> LO-REDUCTION 268 17288.755874 17288.553874 #> REFLECTION 270 17288.712718 17288.530741 #> LO-REDUCTION 272 17288.644400 17288.530741 #> EXTENSION 274 17288.613052 17288.437051 #> HI-REDUCTION 276 17288.606964 17288.437051 #> EXTENSION 278 17288.591829 17288.369092 #> LO-REDUCTION 280 17288.588782 17288.369092 #> LO-REDUCTION 282 17288.553874 17288.369092 #> EXTENSION 284 17288.542682 17288.275532 #> LO-REDUCTION 286 17288.531198 17288.275532 #> LO-REDUCTION 288 17288.530741 17288.275532 #> LO-REDUCTION 290 17288.469459 17288.275532 #> EXTENSION 292 17288.461014 17288.127850 #> LO-REDUCTION 294 17288.437051 17288.127850 #> LO-REDUCTION 296 17288.369092 17288.127850 #> LO-REDUCTION 298 17288.347618 17288.127850 #> LO-REDUCTION 300 17288.313219 17288.127850 #> EXTENSION 302 17288.295935 17288.071792 #> EXTENSION 304 17288.275532 17287.915686 #> LO-REDUCTION 306 17288.214888 17287.915686 #> LO-REDUCTION 308 17288.211032 17287.915686 #> EXTENSION 310 17288.173100 17287.842214 #> LO-REDUCTION 312 17288.141906 17287.842214 #> LO-REDUCTION 314 17288.127850 17287.842214 #> EXTENSION 316 17288.071792 17287.733682 #> EXTENSION 318 17288.054470 17287.663282 #> EXTENSION 320 17287.989272 17287.507624 #> LO-REDUCTION 322 17287.919537 17287.507624 #> LO-REDUCTION 324 17287.915686 17287.507624 #> LO-REDUCTION 326 17287.856498 17287.507624 #> REFLECTION 328 17287.842214 17287.490634 #> LO-REDUCTION 330 17287.733682 17287.490634 #> REFLECTION 332 17287.663282 17287.438068 #> LO-REDUCTION 334 17287.555894 17287.438068 #> LO-REDUCTION 336 17287.551441 17287.438068 #> REFLECTION 338 17287.547247 17287.422322 #> REFLECTION 340 17287.542002 17287.418701 #> REFLECTION 342 17287.507624 17287.368868 #> LO-REDUCTION 344 17287.490634 17287.368868 #> LO-REDUCTION 346 17287.444486 17287.368868 #> LO-REDUCTION 348 17287.438762 17287.368868 #> HI-REDUCTION 350 17287.438068 17287.368868 #> EXTENSION 352 17287.422322 17287.329022 #> EXTENSION 354 17287.418701 17287.274393 #> LO-REDUCTION 356 17287.391509 17287.274393 #> LO-REDUCTION 358 17287.381359 17287.274393 #> LO-REDUCTION 360 17287.375030 17287.274393 #> LO-REDUCTION 362 17287.371807 17287.274393 #> LO-REDUCTION 364 17287.368868 17287.274393 #> REFLECTION 366 17287.329022 17287.274032 #> LO-REDUCTION 368 17287.327098 17287.274032 #> EXTENSION 370 17287.322765 17287.246248 #> LO-REDUCTION 372 17287.316574 17287.246248 #> EXTENSION 374 17287.308329 17287.210843 #> LO-REDUCTION 376 17287.304794 17287.210843 #> LO-REDUCTION 378 17287.279608 17287.210843 #> REFLECTION 380 17287.274393 17287.210366 #> REFLECTION 382 17287.274032 17287.209122 #> LO-REDUCTION 384 17287.264744 17287.209122 #> REFLECTION 386 17287.246248 17287.183411 #> LO-REDUCTION 388 17287.223877 17287.183411 #> LO-REDUCTION 390 17287.214413 17287.183411 #> LO-REDUCTION 392 17287.213088 17287.183411 #> EXTENSION 394 17287.210843 17287.178084 #> LO-REDUCTION 396 17287.210366 17287.178084 #> LO-REDUCTION 398 17287.209122 17287.178084 #> REFLECTION 400 17287.197803 17287.172953 #> EXTENSION 402 17287.196607 17287.164829 #> LO-REDUCTION 404 17287.192398 17287.164829 #> EXTENSION 406 17287.183411 17287.148789 #> LO-REDUCTION 408 17287.183094 17287.148789 #> LO-REDUCTION 410 17287.181404 17287.148789 #> LO-REDUCTION 412 17287.178084 17287.148789 #> LO-REDUCTION 414 17287.173517 17287.148789 #> LO-REDUCTION 416 17287.172953 17287.148789 #> LO-REDUCTION 418 17287.165027 17287.148789 #> EXTENSION 420 17287.164829 17287.142664 #> LO-REDUCTION 422 17287.164534 17287.142664 #> EXTENSION 424 17287.161998 17287.140674 #> LO-REDUCTION 426 17287.160519 17287.140674 #> EXTENSION 428 17287.154476 17287.127103 #> LO-REDUCTION 430 17287.153672 17287.127103 #> LO-REDUCTION 432 17287.148789 17287.127103 #> LO-REDUCTION 434 17287.147540 17287.127103 #> LO-REDUCTION 436 17287.146752 17287.127103 #> LO-REDUCTION 438 17287.142664 17287.127103 #> LO-REDUCTION 440 17287.140674 17287.127103 #> REFLECTION 442 17287.138106 17287.127061 #> EXTENSION 444 17287.131886 17287.110761 #> LO-REDUCTION 446 17287.130480 17287.110761 #> LO-REDUCTION 448 17287.129088 17287.110761 #> LO-REDUCTION 450 17287.128934 17287.110761 #> LO-REDUCTION 452 17287.128336 17287.110761 #> LO-REDUCTION 454 17287.127103 17287.110761 #> LO-REDUCTION 456 17287.127061 17287.110761 #> EXTENSION 458 17287.122784 17287.105926 #> LO-REDUCTION 460 17287.121627 17287.105926 #> EXTENSION 462 17287.120146 17287.101582 #> LO-REDUCTION 464 17287.118771 17287.101582 #> LO-REDUCTION 466 17287.117855 17287.101582 #> EXTENSION 468 17287.117130 17287.090721 #> LO-REDUCTION 470 17287.110761 17287.090721 #> LO-REDUCTION 472 17287.108359 17287.090721 #> LO-REDUCTION 474 17287.107134 17287.090721 #> EXTENSION 476 17287.105926 17287.081849 #> LO-REDUCTION 478 17287.104244 17287.081849 #> EXTENSION 480 17287.101582 17287.080130 #> LO-REDUCTION 482 17287.096149 17287.080130 #> EXTENSION 484 17287.095793 17287.074699 #> LO-REDUCTION 486 17287.093227 17287.074699 #> LO-REDUCTION 488 17287.090721 17287.074699 #> LO-REDUCTION 490 17287.086551 17287.074699 #> REFLECTION 492 17287.086412 17287.074418 #> LO-REDUCTION 494 17287.081849 17287.074418 #> LO-REDUCTION 496 17287.080130 17287.074418 #> REFLECTION 498 17287.077153 17287.073950 #> REFLECTION 500 17287.076483 17287.072432 #> LO-REDUCTION 502 17287.075898 17287.072432 #> LO-REDUCTION 504 17287.075565 17287.072432 #> LO-REDUCTION 506 17287.075074 17287.072432 #> LO-REDUCTION 508 17287.074699 17287.072432 #> LO-REDUCTION 510 17287.074418 17287.072432 #> HI-REDUCTION 512 17287.073950 17287.072432 #> LO-REDUCTION 514 17287.073404 17287.072432 #> EXTENSION 516 17287.072984 17287.071689 #> LO-REDUCTION 518 17287.072957 17287.071689 #> EXTENSION 520 17287.072911 17287.071281 #> LO-REDUCTION 522 17287.072872 17287.071281 #> EXTENSION 524 17287.072566 17287.070932 #> LO-REDUCTION 526 17287.072496 17287.070932 #> REFLECTION 528 17287.072432 17287.070705 #> LO-REDUCTION 530 17287.072040 17287.070705 #> EXTENSION 532 17287.071689 17287.069928 #> LO-REDUCTION 534 17287.071602 17287.069928 #> LO-REDUCTION 536 17287.071281 17287.069928 #> LO-REDUCTION 538 17287.071085 17287.069928 #> REFLECTION 540 17287.070932 17287.069704 #> LO-REDUCTION 542 17287.070818 17287.069704 #> REFLECTION 544 17287.070705 17287.069688 #> REFLECTION 546 17287.070279 17287.069497 #> REFLECTION 548 17287.070113 17287.069324 #> HI-REDUCTION 550 17287.070091 17287.069324 #> LO-REDUCTION 552 17287.070013 17287.069324 #> REFLECTION 554 17287.069928 17287.069224 #> LO-REDUCTION 556 17287.069704 17287.069224 #> EXTENSION 558 17287.069688 17287.069019 #> EXTENSION 560 17287.069605 17287.068864 #> LO-REDUCTION 562 17287.069502 17287.068864 #> LO-REDUCTION 564 17287.069497 17287.068864 #> EXTENSION 566 17287.069324 17287.068482 #> LO-REDUCTION 568 17287.069285 17287.068482 #> EXTENSION 570 17287.069224 17287.068173 #> EXTENSION 572 17287.069019 17287.067727 #> LO-REDUCTION 574 17287.068980 17287.067727 #> EXTENSION 576 17287.068959 17287.066896 #> EXTENSION 578 17287.068864 17287.065841 #> LO-REDUCTION 580 17287.068771 17287.065841 #> EXTENSION 582 17287.068482 17287.064747 #> LO-REDUCTION 584 17287.068173 17287.064747 #> EXTENSION 586 17287.067970 17287.063322 #> LO-REDUCTION 588 17287.067727 17287.063322 #> EXTENSION 590 17287.066896 17287.061580 #> LO-REDUCTION 592 17287.066709 17287.061580 #> LO-REDUCTION 594 17287.066510 17287.061580 #> EXTENSION 596 17287.065841 17287.057767 #> LO-REDUCTION 598 17287.064747 17287.057767 #> EXTENSION 600 17287.063788 17287.053859 #> LO-REDUCTION 602 17287.063322 17287.053859 #> LO-REDUCTION 604 17287.062792 17287.053859 #> LO-REDUCTION 606 17287.062126 17287.053859 #> EXTENSION 608 17287.061580 17287.050184 #> EXTENSION 610 17287.058435 17287.045782 #> LO-REDUCTION 612 17287.057767 17287.045782 #> LO-REDUCTION 614 17287.057359 17287.045782 #> EXTENSION 616 17287.057193 17287.037166 #> LO-REDUCTION 618 17287.053911 17287.037166 #> LO-REDUCTION 620 17287.053859 17287.037166 #> LO-REDUCTION 622 17287.050184 17287.037166 #> LO-REDUCTION 624 17287.048790 17287.037166 #> EXTENSION 626 17287.046966 17287.027006 #> LO-REDUCTION 628 17287.045782 17287.027006 #> EXTENSION 630 17287.041585 17287.015525 #> LO-REDUCTION 632 17287.037975 17287.015525 #> LO-REDUCTION 634 17287.037776 17287.015525 #> LO-REDUCTION 636 17287.037537 17287.015525 #> EXTENSION 638 17287.037166 17287.002045 #> LO-REDUCTION 640 17287.029130 17287.002045 #> LO-REDUCTION 642 17287.027006 17287.002045 #> EXTENSION 644 17287.021112 17286.982852 #> LO-REDUCTION 646 17287.020505 17286.982852 #> LO-REDUCTION 648 17287.020369 17286.982852 #> EXTENSION 650 17287.015525 17286.962921 #> LO-REDUCTION 652 17287.006234 17286.962921 #> LO-REDUCTION 654 17287.003316 17286.962921 #> LO-REDUCTION 656 17287.002045 17286.962921 #> LO-REDUCTION 658 17286.999773 17286.962921 #> EXTENSION 660 17286.994995 17286.933690 #> LO-REDUCTION 662 17286.982852 17286.933690 #> LO-REDUCTION 664 17286.977870 17286.933690 #> LO-REDUCTION 666 17286.975300 17286.933690 #> LO-REDUCTION 668 17286.974307 17286.933690 #> EXTENSION 670 17286.969127 17286.897589 #> LO-REDUCTION 672 17286.962921 17286.897589 #> LO-REDUCTION 674 17286.956414 17286.897589 #> EXTENSION 676 17286.943420 17286.853826 #> LO-REDUCTION 678 17286.937677 17286.853826 #> LO-REDUCTION 680 17286.935539 17286.853826 #> EXTENSION 682 17286.933690 17286.809961 #> LO-REDUCTION 684 17286.911841 17286.809961 #> LO-REDUCTION 686 17286.906427 17286.809961 #> EXTENSION 688 17286.897589 17286.764565 #> EXTENSION 690 17286.877846 17286.704552 #> LO-REDUCTION 692 17286.872431 17286.704552 #> EXTENSION 694 17286.853826 17286.604256 #> LO-REDUCTION 696 17286.822022 17286.604256 #> LO-REDUCTION 698 17286.811029 17286.604256 #> LO-REDUCTION 700 17286.809961 17286.604256 #> EXTENSION 702 17286.764565 17286.493497 #> LO-REDUCTION 704 17286.736274 17286.493497 #> EXTENSION 706 17286.704552 17286.355870 #> LO-REDUCTION 708 17286.657383 17286.355870 #> LO-REDUCTION 710 17286.628318 17286.355870 #> EXTENSION 712 17286.621506 17286.141094 #> LO-REDUCTION 714 17286.604256 17286.141094 #> LO-REDUCTION 716 17286.503365 17286.141094 #> LO-REDUCTION 718 17286.493497 17286.141094 #> EXTENSION 720 17286.414390 17285.877458 #> LO-REDUCTION 722 17286.366513 17285.877458 #> LO-REDUCTION 724 17286.355870 17285.877458 #> LO-REDUCTION 726 17286.251140 17285.877458 #> EXTENSION 728 17286.244105 17285.662233 #> EXTENSION 730 17286.223061 17285.393569 #> LO-REDUCTION 732 17286.141094 17285.393569 #> LO-REDUCTION 734 17285.992524 17285.393569 #> LO-REDUCTION 736 17285.964793 17285.393569 #> EXTENSION 738 17285.889261 17284.967393 #> LO-REDUCTION 740 17285.877458 17284.967393 #> EXTENSION 742 17285.662233 17284.823201 #> EXTENSION 744 17285.587027 17284.571260 #> EXTENSION 746 17285.430175 17284.208648 #> LO-REDUCTION 748 17285.411444 17284.208648 #> LO-REDUCTION 750 17285.393569 17284.208648 #> LO-REDUCTION 752 17285.061522 17284.208648 #> LO-REDUCTION 754 17284.967393 17284.208648 #> LO-REDUCTION 756 17284.823201 17284.208648 #> LO-REDUCTION 758 17284.663334 17284.208648 #> EXTENSION 760 17284.571260 17284.082158 #> EXTENSION 762 17284.471298 17283.933635 #> REFLECTION 764 17284.370237 17283.918499 #> LO-REDUCTION 766 17284.326906 17283.918499 #> LO-REDUCTION 768 17284.242090 17283.918499 #> LO-REDUCTION 770 17284.232223 17283.918499 #> EXTENSION 772 17284.208648 17283.684327 #> HI-REDUCTION 774 17284.082158 17283.684327 #> LO-REDUCTION 776 17284.006206 17283.684327 #> LO-REDUCTION 778 17283.954602 17283.684327 #> LO-REDUCTION 780 17283.943643 17283.684327 #> EXTENSION 782 17283.941150 17283.629046 #> LO-REDUCTION 784 17283.933635 17283.629046 #> EXTENSION 786 17283.918499 17283.432835 #> LO-REDUCTION 788 17283.855866 17283.432835 #> LO-REDUCTION 790 17283.737787 17283.432835 #> EXTENSION 792 17283.707141 17283.177089 #> LO-REDUCTION 794 17283.691961 17283.177089 #> LO-REDUCTION 796 17283.684327 17283.177089 #> LO-REDUCTION 798 17283.629046 17283.177089 #> EXTENSION 800 17283.480788 17283.019801 #> EXTENSION 802 17283.464836 17282.857567 #> LO-REDUCTION 804 17283.432835 17282.857567 #> LO-REDUCTION 806 17283.427379 17282.857567 #> REFLECTION 808 17283.273719 17282.810344 #> LO-REDUCTION 810 17283.192011 17282.810344 #> EXTENSION 812 17283.177089 17282.773026 #> LO-REDUCTION 814 17283.100216 17282.773026 #> EXTENSION 816 17283.019801 17282.431349 #> LO-REDUCTION 818 17282.924383 17282.431349 #> LO-REDUCTION 820 17282.882981 17282.431349 #> LO-REDUCTION 822 17282.857567 17282.431349 #> LO-REDUCTION 824 17282.826993 17282.431349 #> EXTENSION 826 17282.810344 17282.134774 #> LO-REDUCTION 828 17282.773026 17282.134774 #> LO-REDUCTION 830 17282.673630 17282.134774 #> EXTENSION 832 17282.551561 17281.917158 #> LO-REDUCTION 834 17282.507799 17281.917158 #> LO-REDUCTION 836 17282.441034 17281.917158 #> EXTENSION 838 17282.431349 17281.805083 #> EXTENSION 840 17282.328334 17281.485386 #> LO-REDUCTION 842 17282.207399 17281.485386 #> EXTENSION 844 17282.134774 17281.177471 #> LO-REDUCTION 846 17281.971962 17281.177471 #> LO-REDUCTION 848 17281.930907 17281.177471 #> LO-REDUCTION 850 17281.917158 17281.177471 #> LO-REDUCTION 852 17281.805083 17281.177471 #> LO-REDUCTION 854 17281.637799 17281.177471 #> LO-REDUCTION 856 17281.542150 17281.177471 #> LO-REDUCTION 858 17281.485386 17281.177471 #> LO-REDUCTION 860 17281.450381 17281.177471 #> EXTENSION 862 17281.448390 17280.945651 #> LO-REDUCTION 864 17281.369614 17280.945651 #> LO-REDUCTION 866 17281.303934 17280.945651 #> EXTENSION 868 17281.250802 17280.800450 #> LO-REDUCTION 870 17281.238533 17280.800450 #> LO-REDUCTION 872 17281.223261 17280.800450 #> EXTENSION 874 17281.177471 17280.488585 #> LO-REDUCTION 876 17281.024470 17280.488585 #> LO-REDUCTION 878 17280.950337 17280.488585 #> LO-REDUCTION 880 17280.945651 17280.488585 #> LO-REDUCTION 882 17280.939912 17280.488585 #> LO-REDUCTION 884 17280.816046 17280.488585 #> LO-REDUCTION 886 17280.800450 17280.488585 #> REFLECTION 888 17280.738456 17280.447101 #> REFLECTION 890 17280.664631 17280.390325 #> LO-REDUCTION 892 17280.577249 17280.390325 #> LO-REDUCTION 894 17280.566783 17280.390325 #> LO-REDUCTION 896 17280.538991 17280.390325 #> LO-REDUCTION 898 17280.511395 17280.390325 #> LO-REDUCTION 900 17280.488585 17280.390325 #> LO-REDUCTION 902 17280.459344 17280.390325 #> LO-REDUCTION 904 17280.447101 17280.390325 #> REFLECTION 906 17280.446459 17280.382631 #> LO-REDUCTION 908 17280.422497 17280.382631 #> LO-REDUCTION 910 17280.420917 17280.381469 #> LO-REDUCTION 912 17280.406656 17280.381469 #> LO-REDUCTION 914 17280.406429 17280.381469 #> LO-REDUCTION 916 17280.394455 17280.379401 #> LO-REDUCTION 918 17280.390325 17280.379401 #> HI-REDUCTION 920 17280.388261 17280.379401 #> REFLECTION 922 17280.387657 17280.375301 #> LO-REDUCTION 924 17280.387214 17280.375301 #> REFLECTION 926 17280.382631 17280.374067 #> HI-REDUCTION 928 17280.382496 17280.374067 #> REFLECTION 930 17280.381469 17280.373924 #> LO-REDUCTION 932 17280.379656 17280.373924 #> HI-REDUCTION 934 17280.379401 17280.373924 #> LO-REDUCTION 936 17280.377978 17280.373666 #> REFLECTION 938 17280.377712 17280.372196 #> EXTENSION 940 17280.375615 17280.367543 #> LO-REDUCTION 942 17280.375301 17280.367543 #> LO-REDUCTION 944 17280.374265 17280.367543 #> LO-REDUCTION 946 17280.374067 17280.367543 #> LO-REDUCTION 948 17280.373924 17280.367543 #> REFLECTION 950 17280.373666 17280.366638 #> REFLECTION 952 17280.372196 17280.366393 #> LO-REDUCTION 954 17280.370941 17280.366393 #> EXTENSION 956 17280.369039 17280.360078 #> LO-REDUCTION 958 17280.368943 17280.360078 #> LO-REDUCTION 960 17280.368258 17280.360078 #> LO-REDUCTION 962 17280.367543 17280.360078 #> LO-REDUCTION 964 17280.366638 17280.360078 #> LO-REDUCTION 966 17280.366395 17280.360078 #> EXTENSION 968 17280.366393 17280.358415 #> EXTENSION 970 17280.364882 17280.356231 #> EXTENSION 972 17280.364704 17280.352703 #> EXTENSION 974 17280.361998 17280.350130 #> EXTENSION 976 17280.360738 17280.346336 #> LO-REDUCTION 978 17280.360395 17280.346336 #> LO-REDUCTION 980 17280.360078 17280.346336 #> REFLECTION 982 17280.358415 17280.344675 #> LO-REDUCTION 984 17280.356231 17280.344675 #> LO-REDUCTION 986 17280.352703 17280.344675 #> LO-REDUCTION 988 17280.350130 17280.344675 #> LO-REDUCTION 990 17280.349130 17280.344675 #> EXTENSION 992 17280.348501 17280.341423 #> LO-REDUCTION 994 17280.347252 17280.341423 #> LO-REDUCTION 996 17280.346336 17280.341423 #> LO-REDUCTION 998 17280.346022 17280.341423 #> LO-REDUCTION 1000 17280.345873 17280.341423 #> Exiting from Nelder Mead minimizer #> 1002 function evaluations used # extract results # regression coefficient vector res2$beta #> [1] -2.64077894 0.62582753 -0.08293688 0.53247068 -0.12437312 -0.16298836 #> [7] -1.10550227 # check likelihood -ll(res2$beta) #> [1] -17280.34 # number of calls to log lik function # since optim does not return the number of # iterations res2$iter #> function gradient #> 1002 NA # optim does not calculated working weights head(res2$weights) #> [1] 1 # }"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/farmsubmission.html","id":null,"dir":"Reference","previous_headings":"","what":"The British farm submissions data — farmsubmission","title":"The British farm submissions data — farmsubmission","text":"Data British animal farms submissions AHVLA. British farms able submit samples AHVLA cause death animal determined private veterinary surgeon decides submit , unless notifiable disease suspected submission required. data set contains information farms. submissions farms included data frame carcasses also blood samples etc.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/farmsubmission.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"The British farm submissions data — farmsubmission","text":"","code":"data(\"farmsubmission\")"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/farmsubmission.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"The British farm submissions data — farmsubmission","text":"Data frame 12,036 rows 4 columns. TOTAL_SUB Number submissions animal material. log_size Numerical value equal logarithm size farm. log_distance Numerical value equal logarithm distance nearest AHVLA center. C_TYPE Factor describing type activity farm animals used . Either Dairy Beef","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/farmsubmission.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"The British farm submissions data — farmsubmission","text":"data set description provided publication: Böhning, D., Vidal Diez, ., Lerdsuwansri, R., Viwatwongkasem, C., Arnold, M. (2013). \"generalization Chao's estimator covariate information\". Biometrics, 69(4), 1033-1042. doi:10.1111/biom.12082","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/marginalFreq.html","id":null,"dir":"Reference","previous_headings":"","what":"Observed and fitted marginal frequencies — marginalFreq","title":"Observed and fitted marginal frequencies — marginalFreq","text":"function given fitted singleR class object computed marginal frequencies sum probability density functions unit data point .e. kth element marginal frequency table given _j=1^N_obsP(Y_j=k|_j). k=0 (specified call) computed N-N_obs f_0 assumed unobserved part studied population. frequencies useful diagnostics count data regression, assessment fit.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/marginalFreq.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Observed and fitted marginal frequencies — marginalFreq","text":"","code":"marginalFreq( object, includeones = TRUE, includezeros = TRUE, onecount = NULL, range, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/marginalFreq.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Observed and fitted marginal frequencies — marginalFreq","text":"object object singleR class. includeones logical value indicating whether include estimated number zero counts. includezeros logical value indicating whether include one counts zero-one truncated models. onecount numeric value indicating number one counts null trcount object assumed number one counts. range optional argument specifying range selected Y values. ... currently nothing.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/marginalFreq.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Observed and fitted marginal frequencies — marginalFreq","text":"list observed name fitted model family degrees freedom observed fitted marginal frequencies.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/marginalFreq.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Observed and fitted marginal frequencies — marginalFreq","text":"Piotr Chlebicki","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/netherlandsimmigrant.html","id":null,"dir":"Reference","previous_headings":"","what":"Immigration data in the Netherlands — netherlandsimmigrant","title":"Immigration data in the Netherlands — netherlandsimmigrant","text":"data set contains information immigrants four cities (Amsterdam, Rotterdam, Hague Utrecht) Netherlands staying country illegally 1995 appeared police records year.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/netherlandsimmigrant.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Immigration data in the Netherlands — netherlandsimmigrant","text":"","code":"data(\"netherlandsimmigrant\")"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/netherlandsimmigrant.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Immigration data in the Netherlands — netherlandsimmigrant","text":"Data frame 1,880 rows 5 columns. capture Number times person captured police. gender Factor describing gender apprehended person. age Factor describing age apprehended person. Either bellow 40 years old. reason Factor describing reason apprehended police either illegal stay Netherlands reasons. nation Factor nation origin captured person. 6 levels variable: \"American Australia\", \"Asia\", \"North Africa\", \"Rest Africa\", \"Surinam\", \"Turkey\".","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/netherlandsimmigrant.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Immigration data in the Netherlands — netherlandsimmigrant","text":"data set description provided publication: van Der Heijden, P. G., Bustami, R., Cruyff, M. J., Engbersen, G., Van Houwelingen, H. C. (2003). Point interval estimation population size using truncated Poisson regression model. Statistical Modelling, 3(4), 305-322. doi:10.1191/1471082X03st057oa","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/plot.singleRStaticCountData.html","id":null,"dir":"Reference","previous_headings":"","what":"Diagnostic plots for regression and population size estimation — plot.singleRStaticCountData","title":"Diagnostic plots for regression and population size estimation — plot.singleRStaticCountData","text":"Simple diagnostic plots singleRStaticCountData class objects.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/plot.singleRStaticCountData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Diagnostic plots for regression and population size estimation — plot.singleRStaticCountData","text":"","code":"# S3 method for class 'singleRStaticCountData' plot( x, plotType = c(\"qq\", \"marginal\", \"fitresid\", \"bootHist\", \"rootogram\", \"dfpopContr\", \"dfpopBox\", \"scaleLoc\", \"cooks\", \"hatplot\", \"strata\"), confIntStrata = c(\"normal\", \"logNormal\"), histKernels = TRUE, dfpop, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/plot.singleRStaticCountData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Diagnostic plots for regression and population size estimation — plot.singleRStaticCountData","text":"x object singleRStaticCountData class. plotType character parameter (default \"qq\") specifying type plot made. following list presents briefly explains possible type plots: qq – quantile-quantile plot pearson residuals (standardized pearson residuals available model) .e. empirical quantiles residuals plotted theoretical quantiles standard distribution. marginal – plot made matplot fitted observed marginal frequencies labels. fitresid – Plot fitted linear predictors (standardized) pearson residuals. bootHist – Simple histogram statistics obtained bootstrapping (one performed statistics saved). rootogram – Rootogram, full explanation see: Kleiber Zeileis Visualizing Count Data Regressions Using Rootograms (2016), short barplot height square root observed marginal frequencies adjusted difference square root observed fitted marginal frequencies connected line representing fitted marginal frequencies. less difference 0 line beginning bar accurate fitt produced model. dfpopContr – Plot dfpopsize unit contribution. plot y = x line .e. deletion effect removing unit model effect regression coefficients. away observation line influential . dfpopBox – Boxplot dfpopsize getting general idea distribution \"influence\" unit population size estimate. scaleLoc – scale - location plot .e. square root absolute values (standardized) pearson residuals linear predictors column linear predictors. cooks – Plot cooks distance detecting influential observations. hatplot – Plot hat values linear predictor detecting influential observations. strata – Plot confidence intervals point estimates strata provided ... argument confIntStrata confidence interval type use strata plot. Currently supported values \"normal\" \"logNormal\". histKernels logical value indicating whether add density lines histogram. dfpop TODO ... additional optional arguments passed following functions: plotType = \"bootHist\" graphics::hist – x, main, xlab, ylab parameters fixed. plotType = \"rootogram\" graphics::barplot – height, offset, ylab, xlab, ylim parameters fixed. graphics::lines – x, y, pch, type, lwd, col parameters fixed. plotType = \"dfpopContr\" dfpopsize – model, observedPop parameters fixed. plot.default – x, y, xlab, main parameters fixed. plotType = \"dfpopBox\" dfpopsize – model, observedPop parameters fixed. graphics::boxplot – x, ylab, main parameters fixed. plotType = \"scaleLoc\" plot.default – x, y, xlab, ylab, main, sub parameters fixed. plotType = \"fitresid\" plot.default – x, y, xlab, ylab, main, sub parameters fixed. plotType = \"cooks\" plot.default – x, xlab, ylab, main parameters fixed. plotType = \"hatplot\" hatvalues.singleRStaticCountData plot.default – x, xlab, ylab, main parameters fixed. plotType = \"strata\" stratifyPopsize.singleRStaticCountData","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/plot.singleRStaticCountData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Diagnostic plots for regression and population size estimation — plot.singleRStaticCountData","text":"return value plot made.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/plot.singleRStaticCountData.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Diagnostic plots for regression and population size estimation — plot.singleRStaticCountData","text":"Piotr Chlebicki","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/popSizeEst.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract population size estimation results — popSizeEst","title":"Extract population size estimation results — popSizeEst","text":"extractor function singleRStaticCountData method extracting important information regarding pop size estimate.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/popSizeEst.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract population size estimation results — popSizeEst","text":"","code":"popSizeEst(object, ...) # S3 method for class 'singleRStaticCountData' popSizeEst(object, ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/popSizeEst.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract population size estimation results — popSizeEst","text":"object object population size estimates. ... additional optional arguments, currently used singleRStaticCountData class method.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/popSizeEst.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract population size estimation results — popSizeEst","text":"object class popSizeEstResults containing population size estimation results.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/predict.singleRStaticCountData.html","id":null,"dir":"Reference","previous_headings":"","what":"Predict method for singleRStaticCountData class — predict.singleRStaticCountData","title":"Predict method for singleRStaticCountData class — predict.singleRStaticCountData","text":"method predict function, works analogous predict.glm gives possibility get standard errors mean/distribution parameters directly get pop size estimates new data.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/predict.singleRStaticCountData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predict method for singleRStaticCountData class — predict.singleRStaticCountData","text":"","code":"# S3 method for class 'singleRStaticCountData' predict( object, newdata, type = c(\"response\", \"link\", \"mean\", \"popSize\", \"contr\"), se.fit = FALSE, na.action = NULL, weights, cov, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/predict.singleRStaticCountData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predict method for singleRStaticCountData class — predict.singleRStaticCountData","text":"object object singleRStaticCountData class. newdata optional data.frame containing new data. type type prediction required, possible values : \"response\"– matrix containing estimated distributions parameters. \"link\" – matrix linear predictors. \"mean\" – fitted values Y Y|Y>0. \"contr\" – inverse probability weights (named observation contribution population size estimate). \"popSize\" – population size estimation. Note results call redoPopEstimation usually better call function directly. default set \"response\". se.fit logical value indicating whether standard errors computed. matters type \"response\", \"mean\", \"link\". na.action nothing yet. weights optional vector weights type \"contr\", \"popSize\". cov optional matrix function character specifying either covariance matrix function compute covariance matrix. default vcov.singleRStaticCountData can set e.g. vcovHC. ... arguments passed functions, now affects vcov.singleRStaticCountData method cov function.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/predict.singleRStaticCountData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Predict method for singleRStaticCountData class — predict.singleRStaticCountData","text":"Depending type argument one \"response\", \"link\", \"mean\" matrix fitted values possibly standard errors se.fit argument set TRUE, type set \"contr\" vector inverses probabilities, finally \"popSize\" object class popSizeEstResults methods containing population size estimation results.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/predict.singleRStaticCountData.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Predict method for singleRStaticCountData class — predict.singleRStaticCountData","text":"Standard errors computed assumption regression coefficients asymptotically normally distributed, assumption holds linear predictors .e. row =X_vlm asymptotically normally distributed variances expressed well known formula. mean distribution parameters differentiable functions asymptotically normally distributed variables therefore variances can computed using (multivariate) delta method.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/redoPopEstimation.html","id":null,"dir":"Reference","previous_headings":"","what":"Updating population size estimation results — redoPopEstimation","title":"Updating population size estimation results — redoPopEstimation","text":"function applies post-hoc procedures taken (heteroscedastic consistent covariance matrix estimation bias reduction) population size estimation standard error estimation.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/redoPopEstimation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Updating population size estimation results — redoPopEstimation","text":"","code":"redoPopEstimation(object, newdata, ...) # S3 method for class 'singleRStaticCountData' redoPopEstimation( object, newdata, cov, weights, coef, control, popVar, offset, weightsAsCounts, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/redoPopEstimation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Updating population size estimation results — redoPopEstimation","text":"object object update population size estimation results done. newdata optional data.frame new data pop size estimation. ... additional optional arguments, currently used singleRStaticCountData class method. cov updated covariance matrix estimate. weights optional vector weights use population size estimation. coef optional vector coefficients regression base population size estimation. missing set coef(object). control similar controlPopVar estimatePopsize(). missing set controls provided call object. popVar similar popVar estimatePopsize(). missing set \"analytic\". offset offset argument new data weightsAsCounts singleRStaticCountData method used specify whether weights treated number occurrences rows data","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/redoPopEstimation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Updating population size estimation results — redoPopEstimation","text":"object class popSizeEstResults containing updated population size estimation results.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/redoPopEstimation.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Updating population size estimation results — redoPopEstimation","text":"non specified arguments inferred object","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/redoPopEstimation.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Updating population size estimation results — redoPopEstimation","text":"","code":"# Create simple model Model <- estimatePopsize( formula = capture ~ nation + gender, data = netherlandsimmigrant, model = ztpoisson, method = \"IRLS\" ) # Apply heteroscedasticity consistent covariance matrix estimation require(sandwich) #> Loading required package: sandwich cov <- vcovHC(Model, type = \"HC3\") summary(Model, cov = cov, popSizeEst = redoPopEstimation(Model, cov = cov)) #> #> Call: #> estimatePopsize.default(formula = capture ~ nation + gender, #> data = netherlandsimmigrant, model = ztpoisson, method = \"IRLS\") #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.479668 -0.479668 -0.351833 0.000449 -0.225717 14.058858 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.3977 0.2553 -5.475 4.37e-08 *** #> nationAsia -1.0560 0.3940 -2.680 0.00736 ** #> nationNorth Africa 0.2327 0.2399 0.970 0.33200 #> nationRest of Africa -0.8864 0.3514 -2.523 0.01164 * #> nationSurinam -2.3519 1.0273 -2.289 0.02205 * #> nationTurkey -1.6845 0.6110 -2.757 0.00583 ** #> gendermale 0.3833 0.2014 1.904 0.05695 . #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 1718.993 #> BIC: 1757.766 #> Residual deviance: 1136.645 #> #> Log-likelihood: -852.4963 on 1873 Degrees of freedom #> Number of iterations: 8 #> ----------------------- #> Population size estimation results: #> Point estimate 11879.92 #> Observed proportion: 15.8% (N obs = 1880) #> Std. Error 2531.196 #> 95% CI for the population size: #> lowerBound upperBound #> normal 6918.872 16840.98 #> logNormal 8015.862 18177.38 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 11.16325 27.17206 #> logNormal 10.34252 23.45350 # Compare to results with usual covariance matrix estimation summary(Model) #> #> Call: #> estimatePopsize.default(formula = capture ~ nation + gender, #> data = netherlandsimmigrant, model = ztpoisson, method = \"IRLS\") #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.479668 -0.479668 -0.351833 0.000449 -0.225717 14.058858 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.3977 0.2146 -6.514 7.33e-11 *** #> nationAsia -1.0560 0.3016 -3.501 0.000464 *** #> nationNorth Africa 0.2327 0.1939 1.200 0.230002 #> nationRest of Africa -0.8864 0.3009 -2.946 0.003224 ** #> nationSurinam -2.3519 1.0137 -2.320 0.020337 * #> nationTurkey -1.6845 0.6029 -2.794 0.005203 ** #> gendermale 0.3833 0.1630 2.352 0.018686 * #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 1718.993 #> BIC: 1757.766 #> Residual deviance: 1136.645 #> #> Log-likelihood: -852.4963 on 1873 Degrees of freedom #> Number of iterations: 8 #> ----------------------- #> Population size estimation results: #> Point estimate 11879.92 #> Observed proportion: 15.8% (N obs = 1880) #> Std. Error 2448.792 #> 95% CI for the population size: #> lowerBound upperBound #> normal 7080.380 16679.47 #> logNormal 8111.333 17927.69 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 11.27134 26.55225 #> logNormal 10.48657 23.17745 ## get confidence interval with larger significance level redoPopEstimation(Model, control = controlPopVar(alpha = .000001)) #> Point estimate: 11879.92 #> Variance: 5996583 #> 99.9999% confidence intervals: #> lowerBound upperBound #> normal 1880.000 23858.53 #> logNormal 4951.313 34438.87"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":null,"dir":"Reference","previous_headings":"","what":"Regression diagnostics in singleRcapture — regDiagSingleR","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"List regression diagnostics implemented singleRStaticCountData class. Functions either require changes glm class relevant context singleRcapture omitted.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"","code":"dfpopsize(model, ...) # S3 method for class 'singleRStaticCountData' dfpopsize(model, dfbeta = NULL, ...) # S3 method for class 'singleRStaticCountData' dfbeta(model, maxitNew = 1, trace = FALSE, cores = 1, ...) # S3 method for class 'singleRStaticCountData' hatvalues(model, ...) # S3 method for class 'singleRStaticCountData' residuals( object, type = c(\"pearson\", \"pearsonSTD\", \"response\", \"working\", \"deviance\", \"all\"), ... ) # S3 method for class 'singleRStaticCountData' cooks.distance(model, ...) # S3 method for class 'singleRStaticCountData' sigma(object, ...) # S3 method for class 'singleRStaticCountData' influence(model, do.coef = FALSE, ...) # S3 method for class 'singleRStaticCountData' rstudent(model, ...) # S3 method for class 'singleRStaticCountData' rstandard(model, type = c(\"deviance\", \"pearson\"), ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"model, object object singleRStaticCountData class. ... arguments passed methods. Notably dfpopsize.singleRStaticCountData calls dfbeta.singleRStaticCountData dfbeta argument provided controlMethod called dfbeta method. dfbeta dfbeta already obtained possible pass function need computed second time. maxitNew maximal number iterations regressions starting points data specified call model removal k'th row. default 1. trace logical value specifying whether tracking results cores > 1 result progress bar created. cores number processor cores used, number greater 1 activates code designed doParallel, foreach parallel packages. Note now using parallel computing makes tracing impossible trace parameter ignored case. type type residual return. .coef logical indicating dfbeta computation influence done. FALSE default.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"hatvalues – matrix n rows p columns n number observations data p number regression parameters. dfpopsize – vector k'th element corresponds difference point estimate population size estimation full data set point estimate population size estimation removal k'th unit data set. dfbeta – matrix n rows p observations p number units data p number regression parameters. K'th row matrix corresponds -_-k _-k vector estimates regression parameters removal k'th row data. cooks.distance – matrix single columns values cooks distance every unit model.matrix residuals.singleRStaticCountData – data.frame chosen residuals.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"dfpopsize dfbeta closely related. dfbeta fits regression removing specific row data returns difference regression coefficients estimated full data set data set obtained deletion row, repeats procedure every unit present data.dfpopsize population size estimation utilizing coefficients computed dfbeta. cooks.distance implemented (now) models single linear predictor works exactly like method glm class. sigma computes standard errors predicted means. Returns matrix two columns first truncated mean non-truncated mean. residuals.singleRStaticCountData (can abbreviated resid) works like residuals.glm exception : \"pearson\" – returns non standardized residuals. \"pearsonSTD\" – currently defined single predictors models extended models near future, families one distribution parameter multivariate residual. \"response\" – returns residuals computed truncated non truncated fitted value. \"working\" – possibly multivariate one linear predictor present. \"deviance\" – yet defined families singleRmodels() e.g. negative binomial based methods. \"\" – returns available residual types. hatvalues.singleRStaticCountData method singleRStaticCountData class extracting diagonal elements projection matrix. Since singleRcapture supports regular glm's also vglm's hatvalues returns matrix number columns corresponding number linear predictors model, kth column corresponds elements diagonal projection matrix associated kth linear predictor. glm's W^12X (X^TWX)^-1 X^TW^12 : W=E(Diag (^2^T )) X model (lm) matrix. vglm's present package instead : X_vlm (X_vlm^TWX_vlm)^-1 X_vlm^TW : W = E(bmatrix Diag(^2_1^T_1) & Diag(^2_1^T_2) & & Diag(^2_1^T_p) Diag(^2_2^T_1) & Diag(^2_2^T_2) & & Diag(^2_2^T_p) & & & Diag(^2_p^T_1) & Diag(^2_p^T_2) & & Diag(^2_p^T_p) bmatrix) block matrix constructed taking expected value diagonal matrixes corresponding second derivatives respect linear predictor (mixed derivatives) X_vlm model (vlm) matrix constructed using specifications controlModel call estimatePopsize. influence works like glm counterpart computing important influence measures.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/regDiagSingleR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Regression diagnostics in singleRcapture — regDiagSingleR","text":"","code":"# \\donttest{ # For singleRStaticCountData class # Get simple model Model <- estimatePopsize( formula = capture ~ nation + age + gender, data = netherlandsimmigrant, model = ztpoisson, method = \"IRLS\" ) # Get dfbeta dfb <- dfbeta(Model) # The dfpopsize results are obtained via (It is also possible to not provide # dfbeta then they will be computed manually): res <- dfpopsize(Model, dfbeta = dfb) summary(res) #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -4236.412 2.664 2.664 5.448 17.284 117.448 plot(res) # see vaious types of residuals: head(resid(Model, \"all\")) #> lambda truncatedResponse nontruncatedResponse pearson pearsonSTD #> 1 -0.9328875 -0.25364898 0.5294668 -0.4864422 -0.4867283 #> 2 -0.9328875 -0.25364898 0.5294668 -0.4864422 -0.4867283 #> 3 -0.9328875 -0.25364898 0.5294668 -0.4864422 -0.4867283 #> 4 -0.9791760 -0.06666172 0.8695135 -0.2554869 -0.2559964 #> 5 -0.9791760 -0.06666172 0.8695135 -0.2554869 -0.2559964 #> 6 2.7449807 0.74635102 1.5294668 1.4313347 1.4321768 #> deviance #> 1 -0.6992491 #> 2 -0.6992491 #> 3 -0.6992491 #> 4 -0.3631875 #> 5 -0.3631875 #> 6 1.0619767 # }"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/simulate.html","id":null,"dir":"Reference","previous_headings":"","what":"Generating data in singleRcapture — simulate","title":"Generating data in singleRcapture — simulate","text":"S3 method stats::simulate handle singleRStaticCountData singleRfamily classes.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/simulate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generating data in singleRcapture — simulate","text":"","code":"# S3 method for class 'singleRStaticCountData' simulate(object, nsim = 1, seed = NULL, ...) # S3 method for class 'singleRfamily' simulate(object, nsim, seed = NULL, eta, truncated = FALSE, ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/simulate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generating data in singleRcapture — simulate","text":"object object representing fitted model. nsim numeric scalar specifying: number response vectors simulate simulate.singleRStaticCountData, defaults 1L. number units draw simulate.singleRfamily, defaults NROW(eta). seed object specifying random number generator initialized (‘seeded’). ... additional optional arguments. eta matrix linear predictors truncated logical value indicating whether sample truncated full distribution.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/simulate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generating data in singleRcapture — simulate","text":"data.frame n rows nsim columns.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/simulate.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Generating data in singleRcapture — simulate","text":"Maciej Beręsewicz, Piotr Chlebicki","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/simulate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generating data in singleRcapture — simulate","text":"","code":"N <- 10000 ###gender <- rbinom(N, 1, 0.2) gender <- rep(0:1, c(8042, 1958)) eta <- -1 + 0.5*gender counts <- simulate(ztpoisson(), eta = cbind(eta), seed = 1) df <- data.frame(gender, eta, counts) df2 <- subset(df, counts > 0) ### check coverage with summary mod1 <- estimatePopsize( formula = counts ~ 1 + gender, data = df2, model = ztpoisson, controlMethod = list(silent = TRUE) ) mod1_sims <- simulate(mod1, nsim=10, seed = 1) colMeans(mod1_sims) #> sim_1 sim_2 sim_3 sim_4 sim_5 sim_6 sim_7 sim_8 #> 1.241014 1.259281 1.239246 1.244255 1.226871 1.237773 1.239540 1.234532 #> sim_9 sim_10 #> 1.230701 1.244844 mean(df2$counts) #> [1] 1.240424"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/singleRmodels.html","id":null,"dir":"Reference","previous_headings":"","what":"Family functions in singleRcapture package — chao","title":"Family functions in singleRcapture package — chao","text":"Package singleRcapture utilizes various family type functions specify variable parts population size estimation, regression, diagnostics necessary information depends model. functions used model argument estimatePopsize function.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/singleRmodels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Family functions in singleRcapture package — chao","text":"","code":"chao(lambdaLink = \"loghalf\", ...) Hurdleztgeom( lambdaLink = c(\"log\", \"neglog\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) Hurdleztnegbin( nSim = 1000, epsSim = 1e-08, eimStep = 6, lambdaLink = c(\"log\", \"neglog\"), alphaLink = c(\"log\", \"neglog\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) Hurdleztpoisson( lambdaLink = c(\"log\", \"neglog\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) oiztgeom( lambdaLink = c(\"log\", \"neglog\"), omegaLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) oiztnegbin( nSim = 1000, epsSim = 1e-08, eimStep = 6, lambdaLink = c(\"log\", \"neglog\"), alphaLink = c(\"log\", \"neglog\"), omegaLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) oiztpoisson( lambdaLink = c(\"log\", \"neglog\"), omegaLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) zelterman(lambdaLink = \"loghalf\", ...) zotgeom(lambdaLink = c(\"log\", \"neglog\"), ...) zotnegbin( nSim = 1000, epsSim = 1e-08, eimStep = 6, lambdaLink = c(\"log\", \"neglog\"), alphaLink = c(\"log\", \"neglog\"), ... ) zotpoisson(lambdaLink = c(\"log\", \"neglog\"), ...) ztHurdlegeom( lambdaLink = c(\"log\", \"neglog\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) ztHurdlenegbin( nSim = 1000, epsSim = 1e-08, eimStep = 6, lambdaLink = c(\"log\", \"neglog\"), alphaLink = c(\"log\", \"neglog\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) ztHurdlepoisson( lambdaLink = c(\"log\", \"neglog\"), piLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) ztgeom(lambdaLink = c(\"log\", \"neglog\"), ...) ztnegbin( nSim = 1000, epsSim = 1e-08, eimStep = 6, lambdaLink = c(\"log\", \"neglog\"), alphaLink = c(\"log\", \"neglog\"), ... ) ztoigeom( lambdaLink = c(\"log\", \"neglog\"), omegaLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) ztoinegbin( nSim = 1000, epsSim = 1e-08, eimStep = 6, lambdaLink = c(\"log\", \"neglog\"), alphaLink = c(\"log\", \"neglog\"), omegaLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) ztoipoisson( lambdaLink = c(\"log\", \"neglog\"), omegaLink = c(\"logit\", \"cloglog\", \"probit\"), ... ) ztpoisson(lambdaLink = c(\"log\", \"neglog\"), ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/singleRmodels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Family functions in singleRcapture package — chao","text":"lambdaLink link Poisson parameter, \"log\" default except zelterman's chao's models (x2) possible. ... Additional arguments, used now. piLink link probability parameter, \"logit\" default nSim, epsSim working weights computed analytically arguments specify maximum number simulations allowed precision level finding numerically respectively. eimStep non negative integer describing many values used step approximation information matrixes analytic solution available (e.g. \"ztnegbin\"), default varies depending function. Higher value usually means faster convergence may potentially cause issues convergence. alphaLink link dispersion parameter, \"log\" default omegaLink link inflation parameter, \"logit\" default","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/singleRmodels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Family functions in singleRcapture package — chao","text":"object class family containing objects: makeMinusLogLike – factory function creating following functions: (), , ^2^T functions y vector X_vlm matrix (just X applied model single linear predictor)deriv argument possible values c(0, 1, 2) determine derivative return; default value 0, represents minus log-likelihood. links – list link functions. mu.eta, variance – Functions linear predictors return expected value variance. type argument 2 possible values (\"trunc\" \"nontrunc\") specifies whether return E(Y|Y>0), var(Y|Y>0) E(Y), var(Y) respectively; deriv argument values c(0, 1, 2) used indicating derivative respect linear predictors, used providing standard errors predict method. family – string specifies name model. valideta, validmu – now returns TRUE. near future, used check whether applied linear predictors valid (.e. transformed elements parameter space subjected inverse link function). funcZ, Wfun – Functions create pseudo residuals working weights used IRLS algorithm. devResids – function given linear predictors prior weights vector response vector returns deviance residuals. family functions functions implemented yet. pointEst, popVar – Functions given prior weights linear predictors latter case also estimate cov() X_vlm matrix return point estimate population size analytic estimation variance.additional boolean parameter contr former function set true returns contribution unit. etaNames – Names linear predictors. densityFunction – function given linear predictors returns value PMF values x. Additional argument type specifies whether return P(Y|Y>0) P(Y). simulate – function generates values dependent vector given linear predictors. getStart – expression generating starting points.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/singleRmodels.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Family functions in singleRcapture package — chao","text":"functions based \"base\" distribution support N_0=N 0 describe distribution Y truncation. Currently include: P(Y=y|,)= arraycc ^ye^-y! & Poisson distribution (y+^-1)(^-1)y! (^-1^-1+)^^-1 (^-1+)^y & negative binomial distribution ^y(1+)^y+1 & geometric distribution array . Poisson parameter dispersion parameter. Geometric distribution special case negative binomial distribution =1 included negative binomial distribution quite troublesome numerical regression fitting. important know PMF negative binomial distribution approaches PMF Poisson distribution 0^+. Note literature single source capture recapture models dispersion parameter introduces greater variability negative binomial distribution compared Poisson distribution generally interpreted explaining unobserved heterogeneity .e. presence important unobserved independent variables. methods estimating population size tied Poisson processes hence use parameter symbol instead emphasize connection. Also hard see estimators derived modifying \"base\" distribution unbiased assumptions made respective models violated. zero-truncated models corresponding \"base\" distributions characterized relation: P(Y=y|Y>0)= arraycc P(Y=y)1-P(Y=0) & y 0 0 & y=0 array. allows us estimate parameter values using observed part population. models lead following estimates, respectively: aligned N &= _k=1^N_obs11-(-_k) & Poisson distribution N &= _k=1^N_obs11-(1+\\alpha_k_k)^-_k^-1 & negative binomial distribution N &= _k=1^N_obs1+_k_k & geometric distribution aligned One common way assumptions zero-truncated models violated presence one-inflation presence somewhat similar single source capture-recapture models zero-inflation usual count data analysis. two ways one-inflation may understood, relate whether P(Y=0) modified inflation. first approach inflate ( parameter) zero-truncated distribution : P_new(Y=y|Y>0) = arraycc + (1 - )P_old(Y=1|Y>0)& : y = 1 (1 - ) P_old(Y=y|Y>0) & : y 1 array. corresponds : P_new(Y=y) = arraycc P_old(Y=0) & : y = 0 (1 - P(Y=0)) + (1 - )P_old(Y=1) & : y = 1 (1 - ) P_old(Y=y) & : y > 1 array. zero-truncation. Models utilize approach commonly referred zero-truncated one-inflated models. Another way accommodating one-inflation SSCR putting inflation parameter base distribution : P_new(Y=y) = arraycc + (1 - )P_old(Y=1)& : y = 1 (1 - ) P_old(Y=y) & : y 1 array. becomes: P_new(Y=y|Y>0) = arraycc 1 - (1-)P_old(Y=0) + (1 - )1 - (1-)P_old(Y=0)P_old(Y=1)& : y = 1 (1 - )1 - (1-)P_old(Y=0)P_old(Y=y) & : y > 1 array. truncation. shown Böhning 2022 paper approaches equivalent terms maximizing likelihoods put formula . can however lead different population size estimates. zero-truncated one-inflated models formula population size estimate N change since P(y=0) remains estimation parameters changes calculations. one-inflated zero-truncated models population size estimates expressed, respectively : aligned N &= _k=1^N_obs11-(1-_k)(-_k) & base Poisson distribution N &= _k=1^N_obs11-(1-_k)(1+\\alpha_k_k)^-_k^-1 & base negative binomial distribution N &= _k=1^N_obs1+_k_k + _k & base geometric distribution aligned Zero-one-truncated models ignore one counts instead accommodating one-inflation utilizing identity _ztoi=f_1f_1N_obs +(N_obs-f_1)(1-f_1N_obs ) + _zot _zot log likelihood zero-one-truncated distribution characterized probability mass function: P(Y=y|Y>1)= arraycc P(Y=y)1-P(Y=0)-P(Y=1) & y > 1 0 & y 0, 1 array. P(Y) probability mass function \"base\" distribution. identity justifies use zero-one-truncated, unfortunately proven intercept models, however numerical simulations seem indicate even theorem extended (non trivial) regression population size estimation still possible. zero-one-truncated models population size estimates expressed : aligned N &= f_1 + _k=1^N_obs 1-_k(-_k)1-(-_k)-_k(-_k) & base Poisson distribution N &= f_1 + _k=1^N_obs 1-_k(1+_k_k)^-1-_k^-1 1-(1+_k_k)^-_k^-1-_k(1+_k_k)^-1-_k^-1 & base negative binomial distribution N &= f_1 + _k=1^N_obs _k^2+_k+1_k^2 & base geometric distribution aligned Pseudo hurdle models experimental yet described literature. Lastly chao zelterman models based logistic regression dummy variable Z = arraycc 0 & Y = 1 1 & Y = 2 array. based equation: logit(p_k)= (_k2)= x_k=_k _k Poisson parameter. zelterman estimator population size expressed : N=_k=1^N_obs1-(-_k) chao estimator form: N=N_obs+_k=1^f_1+f_2 1_k+ _k^22","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/singleRmodels.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Family functions in singleRcapture package — chao","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/stratifyPopsize.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate size of sub-populations — stratifyPopsize","title":"Estimate size of sub-populations — stratifyPopsize","text":"function estimates sizes specific sub populations based capture-recapture model whole population.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/stratifyPopsize.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate size of sub-populations — stratifyPopsize","text":"","code":"stratifyPopsize(object, strata, alpha, ...) # S3 method for class 'singleRStaticCountData' stratifyPopsize(object, strata, alpha, cov = NULL, ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/stratifyPopsize.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate size of sub-populations — stratifyPopsize","text":"object object population size estimates based singleRcapture package fitter singleRStaticCountData class object. strata specification sub populations given one : formula – formula applied model.frame extracted object. Logical vector number entries equal number rows dataset. (named) list element logical vector, names list used specify names variable returned object. Vector names explanatory variables. singleRStaticCountData method function specification strata parameter result every level explanatory variable sub population variable specified. value provided singleRStaticCountData method function create sub populations based levels factor variables model.frame. alpha significance level confidence intervals – Either single numeric value vector length equal number sub populations specified strata. missing set .05 singleRStaticCountData method. ... vector arguments passed functions. singleRStaticCountData method functions arguments ... passed either cov argument provided function vcov cov argument missing call. cov singleRStaticCountData method estimate variance-covariance matrix estimate regression parameters. possible pass function example sandwich::vcovHC called : foo(object, ...) user may specify additional arguments function ... argument. provided estimate covariance matrix set calling appropriate vcov method.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/stratifyPopsize.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate size of sub-populations — stratifyPopsize","text":"data.frame object row names names specified sub populations either provided inferred.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/stratifyPopsize.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Estimate size of sub-populations — stratifyPopsize","text":"single source capture-recapture models frequently used estimate population size Horvitz-Thompson type estimate: N = _k=1^NI_kP(Y_k>0) = _k=1^N_obs11-P(Y_k=0) I_k=I_Y_k > 0 indicator variables, value 1 kth unit observed least 0 otherwise inverse probabilistic weights weights units observed data 1P(Y_k>0) estimated using fitted linear predictors. estimates different sub populations made changing I_k=I_Y_k > 0 indicator variables refer population whole sub populations considered .e. changing values 1 0 kth unit member sub population considered moment. estimation variance estimates estimation variance estimate population size whole population follow relation one described .","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRStaticCountData.html","id":null,"dir":"Reference","previous_headings":"","what":"Summary statistics for model of singleRStaticCountData class — summary.singleRStaticCountData","title":"Summary statistics for model of singleRStaticCountData class — summary.singleRStaticCountData","text":"summary method singleRStaticCountData class","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRStaticCountData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summary statistics for model of singleRStaticCountData class — summary.singleRStaticCountData","text":"","code":"# S3 method for class 'singleRStaticCountData' summary( object, test = c(\"t\", \"z\"), resType = \"pearson\", correlation = FALSE, confint = FALSE, cov, popSizeEst, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRStaticCountData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summary statistics for model of singleRStaticCountData class — summary.singleRStaticCountData","text":"object object singleRStaticCountData class. test type test significance parameters \"t\" t-test \"z\" normal approximation students t distribution, default \"z\" used 30 degrees freedom \"t\" used cases. resType type residuals summarize value allowed residuals.singleRStaticCountData except \"\" allowed. default pearson residuals used. correlation logical value indicating whether correlation matrix computed covariance matrix default FALSE. confint logical value indicating whether confidence intervals regression parameters constructed. default FALSE. cov covariance matrix corresponding regression parameters. possible give cov argument function object. specified constructed using vcov.singleRStaticCountData method. (.e using Cramer-Rao lower bound) popSizeEst popSizeEstResults class object. specified population size estimation results drawn object. post-hoc procedures, sandwich covariance matrix estimation bias reduction, taken possible include population size estimation results calling redoPopEstimation. ... additional optional arguments passed following functions: vcov.singleRStaticCountData – cov argument provided. cov – cov parameter specified call function. confint.singleRStaticCountData – confint parameter set TRUE function call. particular possible set confidence level ....","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRStaticCountData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summary statistics for model of singleRStaticCountData class — summary.singleRStaticCountData","text":"object summarysingleRStaticCountData class containing: call – call created object. coefficients – dataframe estimated regression coefficients summary statistics standard error Wald test statistic p value Wald test. residuals – vector residuals type specified call. aic – Akaike's information criterion. bic – Bayesian (Schwarz's) information criterion. iter – Number iterations taken fitting regression. logL – Logarithm likelihood function evaluated coefficients. deviance – Residual deviance. populationSize – Object population size estimation results. dfResidual – Residual degrees freedom. sizeObserved – Size observed population. correlation – Correlation matrix correlation parameter set TRUE test – Type statistical test performed. model – Family class object specified call object. skew – bootstrap sample saved contains estimate skewness.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRStaticCountData.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Summary statistics for model of singleRStaticCountData class — summary.singleRStaticCountData","text":"Works analogically summary.glm includes population size estimation results. additional statistics, confidence intervals coefficients coefficient correlation, specified printed.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRmargin.html","id":null,"dir":"Reference","previous_headings":"","what":"Statistical tests of goodness of fit — summary.singleRmargin","title":"Statistical tests of goodness of fit — summary.singleRmargin","text":"Performs two statistical test observed fitted marginal frequencies. G test test statistic computed : G = 2_kO_k(O_kE_k) ^2 test statistic computed : ^2 = _k(O_k-E_k)^2E_k O_k,E_k denoted observed fitted frequencies respectively. statistics converge ^2 distribution asymptotically degrees freedom. convergence G, ^2 statistics ^2 distribution may violated expected counts cells low, say < 5, customary either censor omit cells.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRmargin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Statistical tests of goodness of fit — summary.singleRmargin","text":"","code":"# S3 method for class 'singleRmargin' summary(object, df, dropl5 = c(\"drop\", \"group\", \"no\"), ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRmargin.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Statistical tests of goodness of fit — summary.singleRmargin","text":"object object singleRmargin class. df degrees freedom provided function try manually always possible. dropl5 character indicating treatment cells frequencies < 5 either grouping , dropping leaving . Defaults drop. ... currently nothing.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRmargin.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Statistical tests of goodness of fit — summary.singleRmargin","text":"chi squared test G test comparison fitted observed marginal frequencies.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/summary.singleRmargin.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Statistical tests of goodness of fit — summary.singleRmargin","text":"","code":"# Create a simple model Model <- estimatePopsize( formula = capture ~ ., data = netherlandsimmigrant, model = ztpoisson, method = \"IRLS\" ) plot(Model, \"rootogram\") # We see a considerable lack of fit summary(marginalFreq(Model), df = 1, dropl5 = \"group\") #> Test for Goodness of fit of a regression model: #> #> Test statistics df P(>X^2) #> Chi-squared test 50.06 1 1.5e-12 #> G-test 34.31 1 4.7e-09 #> #> -------------------------------------------------------------- #> Cells with fitted frequencies of < 5 have been grouped #> Names of cells used in calculating test(s) statistic: 1 2 3"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcov.singleRStaticCountData.html","id":null,"dir":"Reference","previous_headings":"","what":"Obtain covariance matrix estimation — vcov.singleRStaticCountData","title":"Obtain covariance matrix estimation — vcov.singleRStaticCountData","text":"vcov method singleRStaticCountData class.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcov.singleRStaticCountData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Obtain covariance matrix estimation — vcov.singleRStaticCountData","text":"","code":"# S3 method for class 'singleRStaticCountData' vcov(object, type = c(\"Fisher\", \"observedInform\"), ...)"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcov.singleRStaticCountData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Obtain covariance matrix estimation — vcov.singleRStaticCountData","text":"object object singleRStaticCountData class. type type estimate covariance matrix now either expected (Fisher) information matrix observed information matrix. ... additional arguments method functions","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcov.singleRStaticCountData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Obtain covariance matrix estimation — vcov.singleRStaticCountData","text":"covariance matrix fitted coefficients, rows columns correspond parameters returned coef method.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcov.singleRStaticCountData.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Obtain covariance matrix estimation — vcov.singleRStaticCountData","text":"Returns estimated covariance matrix model coefficients calculated analytic hessian Fisher information matrix usually utilizing asymptotic effectiveness maximum likelihood estimates. Covariance type taken control parameter provided call created object arguments type specified.","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcovHC.singleRStaticCountData.html","id":null,"dir":"Reference","previous_headings":"","what":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","title":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","text":"S3 method vcovHC handle singleRStaticCountData class objects. Works exactly like vcovHC.default difference method handles vector generalised linear models. Updating covariance matrix variance/standard error estimation population size estimator can done via redoPopEstimation()","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcovHC.singleRStaticCountData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","text":"","code":"# S3 method for class 'singleRStaticCountData' estfun(x, ...) # S3 method for class 'singleRStaticCountData' bread(x, ...) # S3 method for class 'singleRStaticCountData' vcovHC( x, type = c(\"HC3\", \"const\", \"HC\", \"HC0\", \"HC1\", \"HC2\", \"HC4\", \"HC4m\", \"HC5\"), omega = NULL, sandwich = TRUE, ... )"},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcovHC.singleRStaticCountData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","text":"x fitted singleRStaticCountData class object. ... vcovHC additional optional arguments passed following functions: estfun – empirical estimating functions. hatvalues – diagonal elements projection matrix. sandwich – sandwich argument function call set TRUE. vcov – calling bread internally. type character string specifying estimation type, sandwich::vcovHC.default. HC3 default value. omega vector function depending arguments residuals (.e. derivative log-likelihood respect linear predictor), diaghat (diagonal corresponding hat matrix) df (residual degrees freedom), sandwich::vcovHC.default. sandwich logical. sandwich estimator computed? set FALSE meat matrix returned. sandwich::vcovHC()","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcovHC.singleRStaticCountData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","text":"Variance-covariance matrix estimation corrected heteroscedasticity regression errors","code":""},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcovHC.singleRStaticCountData.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","text":"Piotr Chlebicki, Maciej Beręsewicz","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/reference/vcovHC.singleRStaticCountData.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Heteroscedasticity-consistent covariance matrix estimation for singleRStaticCountData class — estfun.singleRStaticCountData","text":"","code":"set.seed(1) N <- 10000 gender <- rbinom(N, 1, 0.2) eta <- -1 + 0.5*gender counts <- rpois(N, lambda = exp(eta)) df <- data.frame(gender, eta, counts) df2 <- subset(df, counts > 0) mod1 <- estimatePopsize( formula = counts ~ 1 + gender, data = df2, model = \"ztpoisson\", method = \"optim\", popVar = \"analytic\" ) require(sandwich) HC <- sandwich::vcovHC(mod1, type = \"HC4\") Fisher <- vcov(mod1, \"Fisher\") # variance covariance matrix obtained from #Fisher (expected) information matrix HC #> (Intercept) gender #> (Intercept) 0.00201216 -0.002012160 #> gender -0.00201216 0.004790297 Fisher #> (Intercept) gender #> (Intercept) 0.002022145 -0.002022145 #> gender -0.002022145 0.004881858 # usual results summary(mod1) #> #> Call: #> estimatePopsize.default(formula = counts ~ 1 + gender, data = df2, #> model = \"ztpoisson\", method = \"optim\", popVar = \"analytic\") #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.5503 -0.4267 -0.4267 0.0000 -0.4267 6.2261 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.01346 0.04497 -22.537 < 2e-16 *** #> gender 0.50288 0.06987 7.197 6.14e-13 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 3990.538 #> BIC: 4002.804 #> Residual deviance: 2386.29 #> #> Log-likelihood: -1993.269 on 3403 Degrees of freedom #> Number of calls to log-likelihood function: 35 #> ----------------------- #> Population size estimation results: #> Point estimate 10146.02 #> Observed proportion: 33.6% (N obs = 3405) #> Std. Error 341.7287 #> 95% CI for the population size: #> lowerBound upperBound #> normal 9476.239 10815.79 #> logNormal 9508.827 10849.72 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 31.48175 35.93198 #> logNormal 31.38330 35.80883 # updated results summary(mod1, cov = HC, popSizeEst = redoPopEstimation(mod1, cov = HC)) #> #> Call: #> estimatePopsize.default(formula = counts ~ 1 + gender, data = df2, #> model = \"ztpoisson\", method = \"optim\", popVar = \"analytic\") #> #> Pearson Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.5503 -0.4267 -0.4267 0.0000 -0.4267 6.2261 #> #> Coefficients: #> ----------------------- #> For linear predictors associated with: lambda #> Estimate Std. Error z value P(>|z|) #> (Intercept) -1.01346 0.04486 -22.593 < 2e-16 *** #> gender 0.50288 0.06921 7.266 3.71e-13 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> AIC: 3990.538 #> BIC: 4002.804 #> Residual deviance: 2386.29 #> #> Log-likelihood: -1993.269 on 3403 Degrees of freedom #> Number of calls to log-likelihood function: 35 #> ----------------------- #> Population size estimation results: #> Point estimate 10146.02 #> Observed proportion: 33.6% (N obs = 3405) #> Std. Error 340.7902 #> 95% CI for the population size: #> lowerBound upperBound #> normal 9478.078 10813.95 #> logNormal 9510.489 10847.69 #> 95% CI for the share of observed population: #> lowerBound upperBound #> normal 31.48710 35.92500 #> logNormal 31.38916 35.80257 # estimating equations mod1_sims <- sandwich::estfun(mod1) head(mod1_sims) #> (Intercept) gender #> 1 -0.1924342 0.0000000 #> 2 0.6700925 0.6700925 #> 3 -0.1924342 0.0000000 #> 4 -0.1924342 0.0000000 #> 5 -0.1924342 0.0000000 #> 6 -0.1924342 0.0000000 # bread method all(vcov(mod1, \"Fisher\") * nrow(df2) == sandwich::bread(mod1, type = \"Fisher\")) #> [1] TRUE"},{"path":[]},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-023","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.3","title":"singleRcapture 0.2.3","text":"BugFix anova working methods Tests working methods added Small changes documentation","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-022","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.2","title":"singleRcapture 0.2.2","text":"CRAN release: 2025-02-04 Fixing documentation typos errors plot now default value qq vignette added based paper submitted JSS","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-0212","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.1.2","title":"singleRcapture 0.2.1.2","text":"CRAN release: 2024-07-18 Bugfix interaction terms formula considered Small changes summary marginal count distributions Small fixes standard errors predicted means Code coverage raised nearly 90% logLik.singleRStaticCountData method now type argument , set \"function\" makes function return minus log-likelihood function (default) deriv argument set 1 2 respectively either gradient hessian log-likelihood function.","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-0211","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.1.1","title":"singleRcapture 0.2.1.1","text":"CRAN release: 2023-10-23 Bugfix tests failing noLongDouble","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-021","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.1","title":"singleRcapture 0.2.1","text":"CRAN release: 2023-10-14 Fixed bugs IRLS fitting providing weights argument calling estimatePopsize weightsAsCounts option controlModel now works properly, dfbeta dfpopsize decrease weight selected row model matrix instead deleting set TRUE simulate method now works family object (like ztpoisson()) objects returned estimatePopsize Introduced singleRStaticCountData sub class singleRclass made estimatePopsize method new package singleRcaptureExtra (development) can make necessary calculations pop size estimation providing object fitted countreg::zerotrunc VGAM::vglm/VGAM::vgam bugfixes multicore bootstrap Code re-factored make development/maintenance package much easier Update uploaded CRAN semiparametric bootstrap now much faster sampling algorithm (job) Unit tests: * Reduced computational burden unit tests * Multicore tests performed TEST_SINGLERCAPTURE_MULTICORE_DEVELOPER set \"true\" via Sys.setenv _R_CHECK_LIMIT_CORES_ false","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-0201","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.0.1","title":"singleRcapture 0.2.0.1","text":"Added offset argument estimatePopsize Added options parallel computing bootstrap dfbeta Added deviance negative binomial based models. (NOTE: slow now believe may change verify one theoretical results lead significant speed increase computations) Overhaul starting points (new methods added linear predictors start IRLS) Code weights IRLS fitting speed Minor bugfixes","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-020","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.2.0","title":"singleRcapture 0.2.0","text":"CRAN release: 2023-06-11","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"the-package-is-now-at-cran-0-2-0","dir":"Changelog","previous_headings":"","what":"The package is now at CRAN","title":"singleRcapture 0.2.0","text":"Added final Hurdleztnegbin model Vastly improved redoPopSize now handles bootstrap fitted model non standard covariance matrixes newdata argument user supplied coef etc. Added predict.singleR method offers standard error link, response well mean predictions unexpected warnings occur now main function using package correctly control arguments now verified passed Fitting now reliable Added information stats::optim error codes Added warnings functions computing deviance fixed bugs occurring using mathematical functions part formulas .e. setting formula something like: y ~ log(x) + (x ^ t) + (t ^ 2)","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-014","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.4","title":"singleRcapture 0.1.4","text":"Added ztoinegbin, oiztnegbin ztHurdlenegbin models Added optional arguments family-functions specify link function distribution parameters Updated standardized documentation Added warnings Added methods singleR class commonly used glm functions, particular texreg::screenreg work well now Changed default arguments Added option save logs IRLS fitting Fixed issues intercept models Fixed slight miscalculations information matrixes one inflated models making fitting much reliable better Rcmd tests","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-0132--ntts","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.3.2 – NTTS","title":"singleRcapture 0.1.3.2 – NTTS","text":"Added function implements population size estimates stratas warnings fitting options control functions Corrected/implemented deviance residuals models Now whole package uses cammelCase Performance upgrades Corrected miss calculated moments Change exported data factors actually factors just characters Removed unused dependency Added automated R-cmd check","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-0131","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.3.1","title":"singleRcapture 0.1.3.1","text":"Basically documentation redone now features important theory SSCR methods information (v)glms Added checks positivity working weights matrixes stabilise \"IRLS\" algorithm S3 method vcovHC implemented vcovCL work singleR class objects work \"HC0\" \"HC1\" type argument values Basic version function redoPopEstimation updating population size estimation post-hoc procedures implemented popSizeEst function extracting population size estimation results implemented Minor improvements memory usage made computation speed little Changed names mle robust fitting methods optim IRLS respectively bugfixes warnings messages estimate_popsize.fit","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-013","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.3","title":"singleRcapture 0.1.3","text":"Multiple new models IRLS generalised distributions multiple parameters bugfixes QOL improvements extended bootstrap methods new models","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-012","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.2","title":"singleRcapture 0.1.2","text":"control parameters model control parameters regression bootstrap sampling leave one diagnostics popsize regression parameters (dfbetas corrected) fixes Goodness fit tests zero one truncated models computational improvements IRLS small bugfixes","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-011","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.1","title":"singleRcapture 0.1.1","text":"tiny tests fixes marginal frequencies Deviance implemented dfbetas levarage matrix Parametric bootstraps work correctly part just polishing left ","code":""},{"path":"https://ncn-foreigners.github.io/singleRcapture/news/index.html","id":"singlercapture-010","dir":"Changelog","previous_headings":"","what":"singleRcapture 0.1.0","title":"singleRcapture 0.1.0","text":"first version package released","code":""}]