Skip to contents

Use a second-order random walk to model variation over age, with an indicator variable for the first age group. Designed for use in models of mortality rates.

Usage

RW2_Infant(s = 1, sd_slope = 1, zero_sum = FALSE)

Arguments

s

Scale for the prior for the innovations. Default is 1.

sd_slope

Standard deviation for initial slope of random walk. Default is 1.

zero_sum

If TRUE, values must sum to 0 within each combination of the 'by' variables. Default is FALSE.

Value

Object of class "bage_prior_rw2infant".

Details

A second-order random walk prior RW2() does a good job of smoothing mortality rates over age, except at age 0, where there is typically a sudden jump in rates, reflecting the special risks of infancy. The RW2_Infant() is a RW2() prior with a special treatment of the first age group.

If RW2_Infant() is used in an interaction, the 'along' dimension is always age, implying that there is a separate random walk along age within each combination of the 'by' variables.

Argument s controls the size of innovations in the random walk. Smaller values for s tend to give smoother series.

Argument sd controls the sl size of innovations in the random walk. Smaller values for s tend to give smoother series.

Mathematical details

When RW2_Infant() is used with a main effect,

$$\beta_1 \sim \text{N}(0, 1)$$ $$\beta_2 \sim \text{N}(0, \omega^2)$$ $$\beta_3 \sim \text{N}(2 \beta_2, \tau^2)$$ $$\beta_j \sim \text{N}(2 \beta_{j-1} - \beta_{j-2}, \tau^2)$$

and when it is used with an interaction,

$$\beta_{u,1} \sim \text{N}(0, 1)$$ $$\beta_{u,2} \sim \text{N}(0, \omega^2)$$ $$\beta_{u,3} \sim \text{N}(2 \beta_{u,2}, \tau^2)$$ $$\beta_{u,j} \sim \text{N}(2 \beta_{u,v-1} - \beta_{u,v-2}, \tau^2)$$

where

  • \(\pmb{\beta}\) is a main effect or interaction;

  • \(j\) denotes position within the main effect;

  • \(v\) denotes position within the 'along' variable of the interaction; and

  • \(u\) denotes position within the 'by' variable(s) of the interaction.

Parameter \(\omega\) has a half-normal prior $$\omega \sim \text{N}^+(0, \text{sd}^2),$$ where sd can be specified by the user.

Parameter \(\tau\) has a half-normal prior $$\tau \sim \text{N}^+(0, \text{s}^2),$$ where s can be specified by the user.

See also

  • RW2() Second-order random walk, without infant indicator

  • Sp() Smoothing via splines

  • SVD() Smoothing over age via singular value decomposition

  • priors Overview of priors implemented in bage

  • set_prior() Specify prior for intercept, main effect, or interaction

Examples

RW2_Infant()
#>   RW2_Infant() 
#>          s: 1
#>   sd_slope: 1
#>   zero_sum: FALSE
RW2_Infant(s = 0.1)
#>   RW2_Infant(s=0.1) 
#>          s: 0.1
#>   sd_slope: 1
#>   zero_sum: FALSE