Skip to contents

A random walk allows process deviations to persist and change from one year to the next, independently for each age or age block. There is no tendency to return to a mean and no correlation between ages.

Usage

dprocess_rw(x, sd = 1)

rprocess_rw(x, sd = 1)

Arguments

x

A numeric matrix with years in rows and ages or age blocks in columns. For simulation, only the first row supplies starting values.

sd

Positive scalar standard deviation of year-to-year increments.

Value

dprocess_rw() returns the summed log density of increments; rprocess_rw() returns a matrix with the dimensions and names of x.

Details

For a year by age matrix x, increments x[y, a] - x[y - 1, a] are independent Normal variables with mean zero and standard deviation sd. The first row has no increment density. rprocess_rw() keeps that starting row and simulates subsequent rows conditionally. In TAM these helpers act on process deviations from the existing mean surfaces (F/M) or cohort predictions (N).

Examples

x <- matrix(0, 5, 2)
set.seed(1)
x <- rprocess_rw(x, sd = 0.2)
dprocess_rw(x, sd = 0.2)
#> [1] 2.907085