Define the B-splines Used for the Time-varying Coefficients of the Model.
Source:R/splines.R
splines.Rd
This function can be used as part of dynamiteformula()
to define the
splines used for the time-varying coefficients \(\delta\).
Arguments
- df
[
integer(1)
]
Degrees of freedom, i.e., the total number of spline coefficients. Seesplines::bs()
. Note that the knots are always defined as an equidistant sequence on the interval starting from the first non-fixed time point to the last time point in the data. Seedynamiteformula()
for more information on fixed time points. Should be an (unrestricted) positive integer.- degree
[
integer(1)
]
Seesplines::bs()
. Should be an (unrestricted) positive integer.- lb_tau
[
numeric()
]
Hard constraint(s) on the lower bound of the standard deviation parameters \(\tau\) of the random walk priors. Can be useful in avoiding divergences in some cases. See also thenoncentered
argument. Can be a single positive value, or vector defining the lower bound separately for each channel, even for channels without varying effects. The ordering is based on the order of channel definitions in thedynamiteformula
object.- noncentered
[
logical()
]
IfTRUE
, use a noncentered parameterization for the spline coefficients. Default isFALSE
. Try changing this if you encounter divergences or other problems in sampling for example when simulating from prior predictive distribution. Can be a single logical value, or vector of logical values, defining the parameterization separately for each channel, even for channels without varying effects.- override
[
logical(1)
]
IfFALSE
(the default), an existing definition for the splines will not be overridden by another call tosplines()
. IfTRUE
, any existing definitions will be replaced.
See also
Model formula construction
dynamite()
,
dynamiteformula()
,
lags()
,
lfactor()
,
random_spec()
Examples
data.table::setDTthreads(1) # For CRAN
# Two channel model with varying effects, with explicit lower bounds for the
# random walk prior standard deviations, with noncentered parameterization
# for the first channel and centered for the second channel.
obs(y ~ 1, family = "gaussian") + obs(x ~ 1, family = "gaussian") +
lags(type = "varying") +
splines(
df = 20, degree = 3, lb_tau = c(0, 0.1),
noncentered = c(TRUE, FALSE)
)
#> Family Formula
#> y gaussian y ~ 1
#> x gaussian x ~ 1
#>
#> Lagged responses added as varying predictors with: k = 1