nPxA: Compute the nPx(A), C(A) proportions from a population of...

Description Usage Arguments Details Value Examples

View source: R/main.R

Description

Compute the nPx(A), C(A) proportions from a population of life histories

Usage

1
nPxA(lifehistory)

Arguments

lifehistory,

a matrix with rows (sample individuals) and columns (outcome in year of life); see synthetic.pop return value

Details

computes the relevant nPx(A) and C(A): the probabilities of the various life trajectories, by age. See <doi:10.1098/rsif.2019.0234>, SI section II.A (Cost Benefit Equations: Definitions)

Value

a data.frame (data.table, if available) with columns

A

integer; the reference year of life, from 1 to dim(lifehistory)[2]

p_0

numeric; probability of 0 lifetime infections

p_1p

numeric; probability of 1 or more lifetime infections

p_2p

numeric; probability of 2 or more lifetime infections

p0_1

numeric; probability of 0 infections at age A, and 1 lifetime infection

p0_1p

numeric; probability of 0 infections at age A, and 1 or more lifetime infections

p0_2p

numeric; probability of 0 infections at age A, and 2 or more lifetime infections

p1_A

numeric; probability of 1 infection at age A, and 1 or more lifetime infections

p1_2p

numeric; probability of 1 infection at age A, and 2 or more lifetime infections

p1p_A

numeric; probability of 1 or more infections at age A, and 1 or more lifetime infections

p2p_A

numeric; probability of 2 or more infections at age A, and 2 or more lifetime infections

CA

numeric; probability of converting from seronegative to seropositive between age A and A+1

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
require(denvax);
data(morrison2010) # has counts by age
fit <- with(morrison2010, serofit(sero=Seropositive, N=Number, age.min=Age))
m2010pop <- synthetic.pop(fit, runs = 10, popsize = 10) # small sample size for example run time
m2010lh <- nPxA(m2010pop)
m2010lh
with(m2010lh,
  plot(A, p0_2p*100, type="l",
    xlab="Age", ylab="%", ylim = c(0, 100),
    main="Individuals w/ No Infections,\nbut that will have 2"
  )
)

denvax documentation built on Dec. 2, 2019, 1:09 a.m.