Skip to contents

Use a line or lines with autoregressive errors to model a main effect or interaction. Typically used with time.

Usage

Lin_AR(n_coef = 2, s = 1, sd = 1, along = NULL)

Arguments

n_coef

Number of lagged terms in the model, ie the order of the model. Default is 2.

s

Scale for the innovations in the AR process. Default is 1.

sd

Standard deviation in the prior for the slope of the line. Larger values imply steeper slopes. Default is 1.

along

Name of the variable to be used as the "along" variable. Only used with interactions.

Value

An object of class "bage_prior_linar".

Details

If Lin_AR() is used with an interaction, separate lines are constructed along the "along" variable, within each combination of the "by" variables.

The order of the autoregressive errors is controlled by the n_coef argument. The default is 2.

Argument s controls the size of the innovations. Smaller values tend to give smoother estimates.

Argument sd controls the size of the slopes of the lines. Larger values can give more steeply sloped lines.

Mathematical details

When Lin_AR() is used with a main effect,

$$\beta_1 = \alpha + \epsilon_1$$ $$\beta_j = \alpha + (j - 1) \eta + \epsilon_j, \quad j > 1$$ $$\alpha \sim \text{N}(0, 1)$$ $$\epsilon_j = \phi_1 \epsilon_{j-1} + \cdots + \phi_n \epsilon_{j-n} + \varepsilon_j$$ $$\varepsilon_j \sim \text{N}(0, \omega^2),$$

and when it is used with an interaction,

$$\beta_{u,1} = \alpha_u + \epsilon_{u,1}$$ $$\beta_{u,v} = \eta (v - 1) + \epsilon_{u,v}, \quad v = 2, \cdots, V$$ $$\alpha_u \sim \text{N}(0, 1)$$ $$\epsilon_{u,v} = \phi_1 \epsilon_{u,v-1} + \cdots + \phi_n \epsilon_{u,v-n} + \varepsilon_{u,v},$$ $$\varepsilon_{u,v} \sim \text{N}(0, \omega^2).$$

where

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

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

  • \(u\) denotes position within the "along" variable of the interaction;

  • \(u\) denotes position within the "by" variable(s) of the interaction; and

  • \(n\) is n_coef.

The slopes have priors $$\eta \sim \text{N}(0, \text{sd}^2)$$ and $$\eta_u \sim \text{N}(0, \text{sd}^2).$$

Internally, Lin_AR() derives a value for \(\omega\) that gives \(\epsilon_j\) or \(\epsilon_{u,v}\) a marginal variance of \(\tau^2\). Parameter \(\tau\) has a half-normal prior $$\tau \sim \text{N}^+(0, \text{s}^2),$$ where a value for s is provided by the user.

The \(\phi_1, \cdots, \phi_k\) are restricted to values between -1 and 1 that jointly lead to a stationary model. The quantity \(r = \sqrt{\phi_1^2 + \cdots + \phi_k^2}\) has boundary-avoiding prior

$$r \sim \text{Beta}(2, 2).$$

See also

  • Lin_AR1() Special case of Lin_AR()

  • Lin() Line with independent normal errors

  • AR() AR process with no line

  • priors Overview of priors implemented in bage

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

Examples

Lin_AR()
#>   Lin_AR() 
#>   n_coef: 2
#>        s: 1
#>       sd: 1
#>      min: -1
#>      max: 1
#>    along: NULL
Lin_AR(n_coef = 3, s = 0.5, sd = 2)
#>   Lin_AR(n_coef=3,s=0.5,sd=2) 
#>   n_coef: 3
#>        s: 0.5
#>       sd: 2
#>      min: -1
#>      max: 1
#>    along: NULL