fit_elastic_regression {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_reg_model
.
fit_elastic_regression(
formula,
data_curves,
x_data,
knots = seq(0, 1, 0.2),
type = "smooth",
closed = FALSE,
max_iter = 10,
eps = 0.001,
pre_align = FALSE
)
formula 
an object of class "formula" of the form data_curves ~ ...". 
data_curves 
list of 
x_data 
a 
knots 
set of knots for the parameter curves of the regression model 
type 
if "smooth" linear srvsplines are used which results in a differentiable mean curve if "polygon" the mean will be piecewise linear. 
closed 

max_iter 
maximal number of iterations 
eps 
the algorithm stops if L2 norm of coefficients changes less 
pre_align 
TRUE if curves should be pre aligned to the mean 
an object of class elastic_reg_model
, which is a list
with entries
type 
"smooth" if linear srvsplines or "polygon" if constant srvsplines were used 
coefs 
spline coeffiecients 
knots 
spline knots 
data_curves 
list of 
closed 

curve < function(x_1, x_2, t){
rbind(2*t*cos(6*t)  x_1*t , x_2*t*sin(6*t))
}
set.seed(18)
x_data < data.frame(x_1 = runif(10,1,1), x_2 = runif(10,1,1))
data_curves < apply(x_data, 1, function(x){
m < sample(10:15, 1)
delta < abs(rnorm(m, mean = 1, sd = 0.05))
t < cumsum(delta)/sum(delta)
data.frame(t(curve((x[1] + 1), (x[2] + 2), t))
+ 0.07*t*matrix(cumsum(rnorm(2*length(delta))), ncol = 2))
})
reg_model < fit_elastic_regression(data_curves ~ x_1 + x_2,
data_curves = data_curves, x_data = x_data)
plot(reg_model)