View source: R/predict.vem_fit.R
| predict.vem_fit | R Documentation |
Returns posterior mean curve estimates from a vem_fit object.
Active basis functions are selected by applying a 0.5 probability threshold
on the posterior inclusion probabilities. If newdata is supplied,
a new basis matrix is
constructed at those time points; otherwise the original fitted time points
are used. Predictions are automatically back-transformed if the model was
fitted with center = TRUE or scale = TRUE.
## S3 method for class 'vem_fit'
predict(object, newdata = NULL, ...)
object |
A |
newdata |
Optional numeric vector of new time points at which to
evaluate the fitted curves. Must lie within the original domain
|
... |
Currently unused. |
A list of length m. Each element is a numeric vector of
predicted values on the original (back-transformed) scale.
da Cruz, A. C., de Souza, C. P. E., & Sousa, P. H. T. O. (2024). Fast Bayesian basis selection for functional data representation with correlated errors. arXiv:2405.20758. https://arxiv.org/abs/2405.20758
vem_fit, plot.vem_fit,
coef.vem_fit
data(toy_curves)
fit <- vem_fit(y = toy_curves$y, Xt = toy_curves$Xt, K = 8)
# Predictions at original time points
preds <- predict(fit)
length(preds) # 3 — one vector per curve
# Predictions at a denser grid
Xt_new <- seq(0, 1, length.out = 200)
preds_dense <- predict(fit, newdata = Xt_new)
# Plot observed vs predicted for curve 1
plot(toy_curves$Xt, toy_curves$y[[1]],
pch = 16, cex = 0.6, col = "grey50",
xlab = "t", ylab = "y")
lines(Xt_new, preds_dense[[1]], col = "firebrick", lwd = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.