Use a line or lines with independent normal errors to model a main effect or interaction. Typically used with time.
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.
Argument sd
controls the size of the slopes of
the lines. Larger values can give more steeply
sloped lines.
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}(0, \text{sd}^2)$$ and $$\eta_u \sim \text{N}(0, \text{sd}^2).$$
Parameter \(\tau\) has a half-normal prior $$\tau \sim \text{N}^+(0, \text{s}^2).$$
See also
Lin_AR()
Linear with AR errorsLin_AR1()
Linear with AR1 errorsRW2()
Second-order random walkpriors Overview of priors implemented in bage
set_prior()
Specify prior for intercept, main effect, or interaction