Lin_AR1 {bage} | R Documentation |
Linear Prior with Autoregressive Errors of Order 1
Description
Use a line or lines with AR1 errors to model a main effect or interaction. Typically used with time.
Usage
Lin_AR1(
s = 1,
shape1 = 5,
shape2 = 5,
min = 0.8,
max = 0.98,
mean_slope = 0,
sd_slope = 1,
along = NULL,
con = c("none", "by")
)
Arguments
s |
Scale for the innovations in the
AR process. Default is |
shape1 , shape2 |
Parameters for beta-distribution prior
for coefficients. Defaults are |
min , max |
Minimum and maximum values
for autocorrelation coefficient.
Defaults are |
mean_slope |
Mean in prior for slope of line. Default is 0. |
sd_slope |
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. |
con |
Constraints on parameters.
Current choices are |
Details
If Lin_AR1()
is used with an interaction,
separate lines are constructed along
the 'along' variable, within each combination
of the 'by' variables.
Arguments min
and max
can be used to specify
the permissible range for autocorrelation.
Argument s
controls the size of the innovations.
Smaller values tend to give smoother estimates.
Argument sd_slope
controls the slopes of
the lines. Larger values can give more steeply
sloped lines.
Value
An object of class "bage_prior_linar"
.
Mathematical details
When Lin_AR1()
is being 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 \epsilon_{j-1} + \varepsilon_j
\varepsilon \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 \epsilon_{u,v-1} + \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; and -
u
denotes position within the 'by' variable(s) of the interaction.
The slopes have priors
\eta \sim \text{N}(\mathtt{mean\_slope}, \mathtt{sd\_slope}^2)
and
\eta_u \sim \text{N}(\mathtt{mean\_slope}, \mathtt{sd\_slope}^2).
Internally, Lin_AR1()
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, \mathtt{s}^2),
where a value for s
is provided by the user.
Coefficient \phi
is constrained
to lie between min
and max
.
Its prior distribution is
\phi = (\mathtt{max} - \mathtt{min}) \phi' - \mathtt{min}
where
\phi' \sim \text{Beta}(\mathtt{shape1}, \mathtt{shape2}).
Constraints
With some combinations of terms and priors, the values of
the intercept, main effects, and interactions are
are only weakly identified.
For instance, it may be possible to increase the value of the
intercept and reduce the value of the remaining terms in
the model with no effect on predicted rates and only a tiny
effect on prior probabilities. This weak identifiability is
typically harmless. However, in some applications, such as
when trying to obtain interpretable values
for main effects and interactions, it can be helpful to increase
identifiability through the use of constraints, specified through the
con
argument.
Current options for con
are:
-
"none"
No constraints. The default. -
"by"
Only used in interaction terms that include 'along' and 'by' dimensions. Within each value of the 'along' dimension, terms across each 'by' dimension are constrained to sum to 0.
References
The defaults for
min
andmax
are based on the defaults forforecast::ets()
.
See Also
-
Lin_AR()
Generalization ofLin_AR1()
-
Lin()
Line with independent normal errors -
AR1()
AR1 process with no line -
priors Overview of priors implemented in bage
-
set_prior()
Specify prior for intercept, main effect, or interaction -
Mathematical Details vignette
Examples
Lin_AR1()
Lin_AR1(min = 0, s = 0.5, sd_slope = 2)