Description Usage Arguments See Also Examples
Estimate spline weights for given warps and covariances. The method seamlessly handles positivity constraints (specified in the basis function).
1 | spline_weights(y, t, Sinv = NULL, basis_fct, weights = NULL)
|
y |
list, matrix or data.frame containing n functional observations. |
t |
(warped) time points corresponding to y in the same format. |
Sinv |
list of precision matrices for amplitude variation. If |
basis_fct |
function for generating a basis. |
weights |
weights for the individual observations. Mainly used for pavpop clustering. |
make_basis_fct
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # Evaluation points
t <- seq(0, 1, length = 100)
# Simulate data
y <- t^2 * sin(8 * t) + t
plot(t, y, type = 'l', lwd = 2, lty = 2)
# Add noise to data
y <- y + rnorm(length(y), sd = 0.1)
points(t, y, pch = 19, cex = 0.5)
# Basis function knots
kts <- seq(0, 1, length = 12)[2:11]
# Construct B-spline basis function
basis_fct <- make_basis_fct(kts = kts, control = list(boundary = c(0, 1)))
# Fit B-spline to data assuming iid. noise
weights <- spline_weights(y, t, basis_fct = basis_fct)
lines(t, basis_fct(t) %*% weights, col = 'red', lwd = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.