compute_elastic_mean {elasdics}  R Documentation 
Computes a Fréchet mean for the curves stored in data_curves
) with respect
to the elastic distance. Constructor function for class elastic_mean
.
compute_elastic_mean(
data_curves,
knots = seq(0, 1, len = 5),
type = c("smooth", "polygon"),
closed = FALSE,
eps = 0.01,
pen_factor = 100,
max_iter = 50
)
data_curves 
list of 
knots 
set of knots for the mean spline curve 
type 
if "smooth" linear srvsplines are used which results in a differentiable mean curve if "polygon" the mean will be piecewise linear. 
closed 

eps 
the algorithm stops if L2 norm of coefficients changes less 
pen_factor 
penalty factor forcing the mean to be closed 
max_iter 
maximal number of iterations 
an object of class elastic_mean
, which is a list
with entries
type 
"smooth" if mean was modeled using linear srvsplines or "polygon" if constant srvsplines are used 
coefs 
spline coeffiecients 
knots 
spline knots 
data_curves 
list of 
closed 

curve < function(t){
rbind(t*cos(13*t), t*sin(13*t))
}
set.seed(18)
data_curves < lapply(1:4, function(i){
m < sample(10:15, 1)
delta < abs(rnorm(m, mean = 1, sd = 0.05))
t < cumsum(delta)/sum(delta)
data.frame(t(curve(t)) + 0.07*t*matrix(cumsum(rnorm(2*length(delta))),
ncol = 2))
})
#compute elastic means
knots < seq(0,1, length = 11)
smooth_elastic_mean < compute_elastic_mean(data_curves, knots = knots)
plot(smooth_elastic_mean)
knots < seq(0,1, length = 15)
polygon_elastic_mean < compute_elastic_mean(data_curves, knots = knots, type = "poly")
lines(get_evals(polygon_elastic_mean), col = "blue", lwd = 2)
#compute closed smooth mean, takes a little longer
knots < seq(0,1, length = 11)
closed_elastic_mean < compute_elastic_mean(data_curves, knots = knots, closed = TRUE)
plot(closed_elastic_mean)