summary.singleRmargin: Statistical tests of goodness of fit

View source: R/marginal.R

summary.singleRmarginR Documentation

Statistical tests of goodness of fit

Description

Performs two statistical test on observed and fitted marginal frequencies. For G test the test statistic is computed as: \loadmathjax \mjsdeqnG = 2\sum_kO_k\ln\left(\fracO_kE_k\right) and for \mjseqn\chi^2 the test statistic is computed as: \mjsdeqn\chi^2 = \sum_k\frac\left(O_k-E_k\right)^2E_k where \mjseqnO_k,E_k denoted observed and fitted frequencies respectively. Both of these statistics converge to \mjseqn\chi^2 distribution asymptotically with the same degrees of freedom.

The convergence of \mjseqnG, \chi^2 statistics to \mjseqn\chi^2 distribution may be violated if expected counts in cells are too low, say < 5, so it is customary to either censor or omit these cells.

Usage

## S3 method for class 'singleRmargin'
summary(object, df, dropl5 = c("drop", "group", "no"), ...)

Arguments

object

object of singleRmargin class.

df

degrees of freedom if not provided the function will try and manually but it is not always possible.

dropl5

a character indicating treatment of cells with frequencies < 5 either grouping them, dropping or leaving them as is. Defaults to drop.

...

currently does nothing.

Value

A chi squared test and G test for comparison between fitted and observed marginal frequencies.

Examples

# 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")

singleRcapture documentation built on April 4, 2025, 1:43 a.m.