regDiagSingleR {singleRcapture}R Documentation

Regression diagnostics in singleRcapture

Description

List of some regression diagnostics implemented for singleRStaticCountData class. Functions that either require no changes from glm class or are not relevant to context of singleRcapture are omitted.

Usage

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"), ...)

Arguments

model, object

an object of singleRStaticCountData class.

...

arguments passed to other methods. Notably dfpopsize.singleRStaticCountData calls dfbeta.singleRStaticCountData if no dfbeta argument was provided and controlMethod is called in dfbeta method.

dfbeta

if dfbeta was already obtained it is possible to pass them into function so that they need not be computed for the second time.

maxitNew

the maximal number of iterations for regressions with starting points \(\hat{\boldsymbol{\beta}}\) on data specified at call for model after the removal of k'th row. By default 1.

trace

a logical value specifying whether to tracking results when cores > 1 it will result in a progress bar being created.

cores

a number of processor cores to be used, any number greater than 1 activates code designed with doParallel, foreach and parallel packages. Note that for now using parallel computing makes tracing impossible so trace parameter is ignored in this case.

type

a type of residual to return.

do.coef

logical indicating if dfbeta computation for influence should be done. FALSE by default.

Details

dfpopsize and dfbeta are closely related. dfbeta fits a regression after removing a specific row from the data and returns the difference between regression coefficients estimated on full data set and data set obtained after deletion of that row, and repeats procedure once for every unit present in the data.dfpopsize does the same for population size estimation utilizing coefficients computed by dfbeta.

cooks.distance is implemented (for now) only for models with a single linear predictor and works exactly like the method for glm class.

sigma computes the standard errors of predicted means. Returns a matrix with two columns first for truncated mean and the other for the non-truncated mean.

residuals.singleRStaticCountData (can be abbreviated to resid) works like residuals.glm with the exception that:

hatvalues.singleRStaticCountData is method for singleRStaticCountData class for extracting diagonal elements of projection matrix.

Since singleRcapture supports not only regular glm's but also vglm's the hatvalues returns a matrix with number of columns corresponding to number of linear predictors in a model, where kth column corresponds to elements of the diagonal of projection matrix associated with kth linear predictor. For glm's \[\boldsymbol{W}^{\frac{1}{2}}\boldsymbol{X} \left(\boldsymbol{X}^{T}\boldsymbol{W}\boldsymbol{X}\right)^{-1} \boldsymbol{X}^{T}\boldsymbol{W}^{\frac{1}{2}}\] where: \(\boldsymbol{W}=\mathbb{E}\left(\text{Diag} \left(\frac{\partial^{2}\ell}{\partial\boldsymbol{\eta}^{T} \partial\boldsymbol{\eta}}\right)\right)\) and \(\boldsymbol{X}\) is a model (lm) matrix. For vglm's present in the package it is instead : \[\boldsymbol{X}_{vlm} \left(\boldsymbol{X}_{vlm}^{T}\boldsymbol{W}\boldsymbol{X}_{vlm}\right)^{-1} \boldsymbol{X}_{vlm}^{T}\boldsymbol{W}\] where: \[ \boldsymbol{W} = \mathbb{E}\left(\begin{bmatrix} \text{Diag}\left(\frac{\partial^{2}\ell}{\partial\eta_{1}^{T}\partial\eta_{1}}\right) & \text{Diag}\left(\frac{\partial^{2}\ell}{\partial\eta_{1}^{T}\partial\eta_{2}}\right) & \dotso & \text{Diag}\left(\frac{\partial^{2}\ell}{\partial\eta_{1}^{T}\partial\eta_{p}}\right)\cr \text{Diag}\left(\frac{\partial^{2}\ell}{\partial\eta_{2}^{T}\partial\eta_{1}}\right) & \text{Diag}\left(\frac{\partial^{2}\ell}{\partial\eta_{2}^{T}\partial\eta_{2}}\right) & \dotso & \text{Diag}\left(\frac{\partial^{2}\ell}{\partial\eta_{2}^{T}\partial\eta_{p}}\right)\cr \vdots & \vdots & \ddots & \vdots\cr \text{Diag}\left(\frac{\partial^{2}\ell}{\partial\eta_{p}^{T}\partial\eta_{1}}\right) & \text{Diag}\left(\frac{\partial^{2}\ell}{\partial\eta_{p}^{T}\partial\eta_{2}}\right) & \dotso & \text{Diag}\left(\frac{\partial^{2}\ell}{\partial\eta_{p}^{T}\partial\eta_{p}}\right) \end{bmatrix}\right)\] is a block matrix constructed by taking the expected value from diagonal matrixes corresponding to second derivatives with respect to each linear predictor (and mixed derivatives) and \(\boldsymbol{X}_{vlm}\) is a model (vlm) matrix constructed using specifications in controlModel and call to estimatePopsize.

influence works like glm counterpart computing the most important influence measures.

Value

Author(s)

Piotr Chlebicki, Maciej Beręsewicz

See Also

estimatePopsize() stats::hatvalues() controlMethod() stats::dfbeta() stats::cooks.distance()

Examples


# 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)
plot(res)
# see vaious types of residuals:
head(resid(Model, "all"))


[Package singleRcapture version 0.2.1.4 Index]