View source: R/component_samplers.R
sampleBTF_sparse | R Documentation |
Compute one draw of the T x 1
state variable mu
in a DLM using back-band substitution methods.
This model is equivalent to the Bayesian trend filtering (BTF) model, assuming appropriate
(shrinkage/sparsity) priors for the evolution errors, with an additional shrinkage-to-zero prior.
sampleBTF_sparse(
y,
obs_sigma_t2,
evol_sigma_t2,
zero_sigma_t2,
D = 1,
chol0 = NULL
)
y |
the |
obs_sigma_t2 |
the |
evol_sigma_t2 |
the |
zero_sigma_t2 |
the |
D |
the degree of differencing (one or two) |
chol0 |
(optional) the |
T x 1
vector of simulated states
Missing entries (NAs) are not permitted in y
. Imputation schemes are available.
# Simulate some data:
T = 1000
y = seq(0, 10, length.out = T) + rnorm(T)
plot(y) # plot the data
obs_sigma_t2 = rep(1, T) # These could be static or dynamic
evol_sigma_t2 = rep(0.001, T)
zero_sigma_t2 = rep(1, T)
# Simulate one draw of the states:
mu = sampleBTF_sparse(y = y, obs_sigma_t2, evol_sigma_t2, zero_sigma_t2, D = 1)
lines(mu, lwd=8, col='blue') # add the states to the plot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.