Lin {bage} | R Documentation |
Linear Prior with Independent Normal Errors
Description
Use a line or lines with independent normal errors to model a main effect or interaction. Typically used with time.
Usage
Lin(s = 1, mean_slope = 0, sd_slope = 1, along = NULL, con = c("none", "by"))
Arguments
s |
Scale for the prior for the errors.
Default is |
mean_slope |
Mean in prior for slope of line. Default is 0. |
sd_slope |
Standard deviation in prior for slope of line. 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()
is used with an interaction,
then separate lines are constructed along
the 'along' variable, within each combination
of the 'by' variables.
Argument s
controls the size of the errors.
Smaller values tend to give smoother estimates.
s
can be zero.
Argument sd_slope
controls the size of the slopes of
the lines. Larger values can give more steeply
sloped lines.
Value
An object of class "bage_prior_lin"
.
Mathematical details
When Lin()
is used with a main effect,
\beta_j = \alpha + j \eta + \epsilon_j
\alpha \sim \text{N}(0, 1)
\epsilon_j \sim \text{N}(0, \tau^2),
and when it is used with an interaction,
\beta_{u,v} \sim \alpha_u + v \eta_u + \epsilon_{u,v}
\alpha_u \sim \text{N}(0, 1)
\epsilon_{u,v} \sim \text{N}(0, \tau^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.
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).
Parameter \tau
has a half-normal prior
\tau \sim \text{N}^+(0, \mathtt{s}^2).
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.
See Also
-
Lin_AR()
Linear with AR errors -
Lin_AR1()
Linear with AR1 errors -
RW2()
Second-order random walk -
priors Overview of priors implemented in bage
-
set_prior()
Specify prior for intercept, main effect, or interaction -
Mathematical Details vignette
Examples
Lin()
Lin(s = 0.5, sd_slope = 2)
Lin(s = 0)
Lin(along = "cohort")