ggbAgeTrimSensitivity: calculate and plot ggb results for each possible age trim

View source: R/plot_functions.R

ggbAgeTrimSensitivityR Documentation

calculate and plot ggb results for each possible age trim

Description

Age trim selection is a big open problem for death distribution methods. Here we can see how the "Mxcoverage" estiamte varies as a function of lower and upper ages of age trims. Alternatively, one could check other optimal criteria, such as r2, RMS, or ORSS statistics over the same space.

Usage

ggbAgeTrimSensitivity(
  X,
  minA = 5,
  maxA = 75,
  minAges = 8,
  deaths.summed = FALSE,
  mig.summed = deaths.summed,
  lm.method = "tukey",
  nx.method = 2,
  opt.method = "r2",
  type = "Mxcoverage",
  plot = TRUE
)

Arguments

X

data.frame with columns, pop1, pop2, deaths, mig (optional), date1, date2, age, and id (if there are more than 1 region/sex/intercensal period).

minA

the lowest age to be included in search

maxA

the highest age to be included in search (the lower bound thereof)

minAges

the minimum number of adjacent ages to be used in estimating

deaths.summed

logical. is the deaths column given as the total per age in the intercensal period (TRUE). By default we assume FALSE, i.e. that the average annual was given.

mig.summed

logical. Is the (optional) net migration column mig given as the total per age in the intercensal period (TRUE). By default we assume FALSE, i.e. that the average annual was given.

lm.method

character, one of:

  • "oldschool" default sd ratio operation of still unknown origin

  • "lm" or "ols" for a simple linear model

  • "tls", "orthogonal", or "deming" for total least squares

  • "tukey", "resistant", or ""median" for Tukey's resistant line method

nx.method

either 2 or 4. 4 is smoother.

opt.method

what kind of residual do we minimize? choices "RMS","logRMS", "ORSS", "logORSS" (experimental)

type

either "Mxcoverage" or "resid"

plot

logical. Shall we also render the plot?

Details

The optimal (using the specified opt.method criterion) age trim is indicated with a circle. Whether or not plot is TRUE this function returns a data object that one may wish to analyze.

Examples

## Not run: 
ZAmx_r2 <-
ggbAgeTrimSensitivity(ZA,
                      maxA=80,
                      deaths.summed = TRUE,
                      type = "resid")
ZAmx_coverage <-
  ggbAgeTrimSensitivity(ZA,
                        maxA=80,
                        deaths.summed = TRUE,
                        type = "Mxcoverage")

## End(Not run)

albinomatheus/toolbox documentation built on June 13, 2024, 5:42 a.m.