surv.convert: Convert simulated mortality data to survivorship format.

Description Usage Arguments Value Examples

View source: R/surv.convert.R

Description

Takes simulated frequencies for a series of ordinal classes and calculates survivorship across that series. Intended for mortality data. Survivorship currently defined as proportion surviving to *end* of given class; in future plan to add an argument allowing this to be set to *start* of class, as is standard practice in human demographics.

Usage

1
2
surv.convert(mortality, field.list = NULL, quant.list = c(0.025, 0.25, 0.5,
  0.75, 0.975))

Arguments

mortality

Output from a date.simulate, dummy.simulate, or freq.simulate call: either a data table with columns 'bin', 'bin.no' and 'rep.no' (plus at least one column of frequencies) or a list whose first item is such a data table.

field.list

Character vector of columns in 'mortality' which contain the mortality data to convert. Defaults to NULL, in which case all frequency columns are used.

quant.list

Numeric vector of quantiles to be calculated in a summary table. Defaults to c(0.025,0.25,0.5,0.75,0.975).

Value

A list with two named elements: "full" is a long-format data table with at least four named columns: 'rep.no', integer specifying simulation run; 'bin', character specifying chronological bin in terms of date range; 'bin.no' integer specifying number of bin, counting from earliest; then for each input frequency column a column called 'survive.[input column name], giving survivorship (out of 1) to the end of the given bin in the given simulation run. "summary" is a second long format data table with four named columns: 'bin', as above; 'V1', the relevant value for the given bin at a given quantile; 'quantile', the quantile at which V1 is calculated; 'id', character specifying which column from "full" V1 is based upon.

Examples

1
2
3
4
5
# Simulating a sample of 50 mandibles from an ideal dairy herd model, then calculating survivorship
dairy.model <- c(0.53, 0.05, 0.03, 0.04, 0.07, 0.05, 0.04, 0.09, 0.10)
payne.breaks <- c(0, 2, 6, 12, 24, 36, 48, 2, 96, 20)
sim.ages <- dummy.simulate(50, probs=dairy.model, breaks=payne.breaks, reps=1000)
sim.survive <- surv.convert(sim.ages)

davidcorton/archSeries documentation built on May 4, 2021, 10:09 p.m.