View source: R/bage_prior-constructors.R
AR | R Documentation |
Use an autoregressive process to model a main effect, or use multiple autoregressive processes to model an interaction. Typically used with time effects or with interactions that involve time.
AR(
n_coef = 2,
s = 1,
shape1 = 5,
shape2 = 5,
along = NULL,
con = c("none", "by")
)
n_coef |
Number of lagged terms in the
model, ie the order of the model. Default is |
s |
Scale for the prior for the innovations.
Default is |
shape1 , shape2 |
Parameters for beta-distribution prior
for coefficients. Defaults are |
along |
Name of the variable to be used as the 'along' variable. Only used with interactions. |
con |
Constraints on parameters.
Current choices are |
If AR()
is used with an interaction, then
separate AR processes are constructed along
the 'along' variable, within each combination of the
'by' variables.
By default, the autoregressive processes
have order 2. Alternative choices can be
specified through the n_coef
argument.
Argument s
controls the size of innovations.
Smaller values for s
tend to give smoother estimates.
An object of class "bage_prior_ar"
.
When AR()
is used with a main effect,
\beta_j = \phi_1 \beta_{j-1} + \cdots + \phi_{\mathtt{n\_coef}} \beta_{j-\mathtt{n\_coef}} + \epsilon_j
\epsilon_j \sim \text{N}(0, \omega^2),
and when it is used with an interaction,
\beta_{u,v} = \phi_1 \beta_{u,v-1} + \cdots + \phi_{\mathtt{n\_coef}} \beta_{u,v-\mathtt{n\_coef}} + \epsilon_{u,v}
\epsilon_{u,v} \sim \text{N}(0, \omega^2),
where
\pmb{\beta}
is the 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.
Internally, AR()
derives a value for \omega
that
gives every element of \beta
a marginal
variance of \tau^2
. Parameter \tau
has a half-normal prior
\tau \sim \text{N}^+(0, \mathtt{s}^2).
The correlation coefficients \phi_1, \cdots, \phi_{\mathtt{n\_coef}}
each have prior
\phi_k \sim \text{Beta}(\mathtt{shape1}, \mathtt{shape2}).
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 forecasting, or when trying to obtain interpretable values for main effects and interactions, it can be helpful to increase identifiability through the use of constraints.
Current options for constraints 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.
AR()
is based on the TMB function
ARk
AR1()
Special case of AR()
. Can be more
numerically stable than higher-order models.
Lin_AR()
, Lin_AR1()
Straight line with AR errors
priors Overview of priors implemented in bage
set_prior()
Specify prior for intercept,
main effect, or interaction
AR(n_coef = 3)
AR(n_coef = 3, s = 2.4)
AR(along = "cohort")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.