spline_weights: Estimate spline weights

Description Usage Arguments See Also Examples

Description

Estimate spline weights for given warps and covariances. The method seamlessly handles positivity constraints (specified in the basis function).

Usage

1
spline_weights(y, t, Sinv = NULL, basis_fct, weights = NULL)

Arguments

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 NULL, iid. Gaussian noise is assumed

basis_fct

function for generating a basis.

weights

weights for the individual observations. Mainly used for pavpop clustering.

See Also

make_basis_fct

Examples

 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)

larslau/pavpop documentation built on June 14, 2019, 2:18 p.m.