Skip to contents

A random walk whose annual changes are correlated between neighbouring ages. Changes are independent between years, with no tendency to return to a mean. tinyAM uses this process for F_settings$process = "cor_rw".

Usage

dprocess_cor_rw(x, sd = 1, rho = 0)

rprocess_cor_rw(x, sd = 1, rho = 0)

Arguments

x

Numeric matrix with years in rows and ordered ages in columns. For simulation, only the first row supplies starting values.

sd

Positive marginal SD of annual increments: a scalar shared by all ages, or a vector with one value per column of x.

rho

Correlation between adjacent columns, strictly between -1 and 1. Negative values allow alternating changes between neighbouring ages.

Value

dprocess_cor_rw() returns the summed log density of annual increment vectors (zero for one row). rprocess_cor_rw() returns a matrix with the dimensions and names of x, leaving its first row unchanged.

Details

For a year by age matrix x, each vector of annual increments \(x_{t,a}-x_{t-1,a}\) has a multivariate Normal distribution with mean zero and covariance \(\Sigma_{ab}=\sigma_a\sigma_b\rho^{|a-b|}\). Distance is measured by column position, not by numerical age labels. Each sd is a marginal increment SD; correlation does not inflate it. At rho = 0, increments are independent between ages, as in dprocess_rw().

The first row has no density contribution. rprocess_cor_rw() retains it and simulates later rows conditionally. In tinyAM, x contains deviations from the log-F mean, rather than the absolute latent log-F states. dprocess_cor_rw() supports RTMB automatic differentiation.

Examples

x <- matrix(0, 6, 3, dimnames = list(2000:2005, 2:4))
set.seed(1)
draw <- rprocess_cor_rw(x, sd = c(0.2, 0.3, 0.4), rho = 0.6)
dprocess_cor_rw(draw, sd = c(0.2, 0.3, 0.4), rho = 0.6)
#> [1] -0.2303206