Title: | Mixed Effects Modeling with Warping for Functional Data Using B-Spline |
---|---|
Description: | Mixed effects modeling with warping for functional data using B- spline. Warping coefficients are considered as random effects, and warping functions are general functions, parameters representing the projection onto B- spline basis of a part of the warping functions. Warped data are modelled by a linear mixed effect functional model, the noise is Gaussian and independent from the warping functions. |
Authors: | Emilie Devijver, Gerda Claeskens, Irene Gijbels |
Maintainer: | Emilie Devijver <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.0 |
Built: | 2024-12-17 06:55:05 UTC |
Source: | CRAN |
This function returns the empirical L_2 between two functions, the first one being warped.
criterion(t, f, g, theta, splineBasisW)
criterion(t, f, g, theta, splineBasisW)
t |
A vector of numbers, corresponding to time points. |
f |
A vector of numbers, corresponding to the evaluated function. |
g |
A vector of numbers, corresponding to the evaluated function. |
theta |
A vector of warping parameters. |
splineBasisW |
A matrix, corresponding to the spline basis for the warping functions, evaluted in time points. |
A list, with crit the distance.
This function estimate the warping parameters, knowing the observations and the individual aligned curves.
estimationTheta(t, y, splineBasisW, indSignal, thetaObs)
estimationTheta(t, y, splineBasisW, indSignal, thetaObs)
t |
A vector of numbers, corresponding to time points. |
y |
A matrix of numbers, corresponding to observations (size: T * n). |
splineBasisW |
A matrix, corresponding to the spline basis for the warping functions, evaluted in time points. |
indSignal |
A matrix, corresponding to the individual aligned curves. |
thetaObs |
A matrix, corresponding to initial values for the warping parameters. |
A list, with theta, a matrix of estimated warping parameters, and wT, the corresponding warping functions.
This function initializes the mean curve, the individual effect U_i, related to aligned curves.
initialisationPara(t, y, splineBasisMu, splineBasisU, warpTime)
initialisationPara(t, y, splineBasisMu, splineBasisU, warpTime)
t |
A vector of numbers, corresponding to time points. |
y |
A matrix of numbers, corresponding to observations (size: T * n). |
splineBasisMu |
A matrix, corresponding to the spline basis for the global mean function, evaluted in time points. |
splineBasisU |
A matrix, corresponding to the spline basis for the individual curves, evaluted in time points. |
warpTime |
A matrix, corresponding to warping time points. |
A list, with x, aligned curves, alphaMu the coefficients of the mean curve, sigmaEpsilon the variance of the noise, sigmaU the variance of the random effects, and indSignal each individual curves.
This function initializes the warping parameters
initialisationTheta(t, y, splineBasisW)
initialisationTheta(t, y, splineBasisW)
t |
A vector of numbers, corresponding to time points. |
y |
A matrix of numbers, corresponding to observations (size: T * n). |
splineBasisW |
A matrix, corresponding to the spline basis for the warping functions, evaluted in time points. |
A list, with theta, a matrix of estimated warping parameters, and wT, the corresponding warping functions.
This function updates the estimations of the mean curve, the individual effect U_i, related to aligned curves.
majPara(t, y, splineBasisMu, splineBasisU, warpTime)
majPara(t, y, splineBasisMu, splineBasisU, warpTime)
t |
A vector of numbers, corresponding to time points. |
y |
A matrix of numbers, corresponding to observations (size: T * n). |
splineBasisMu |
A matrix, corresponding to the spline basis for the global mean function, evaluted in time points. |
splineBasisU |
A matrix, corresponding to the spline basis for the individual curves, evaluted in time points. |
warpTime |
A matrix, corresponding to warping time points. |
A list, with x, aligned curves, alphaMu the coefficients of the mean curve, sigmaEpsilon the variance of the noise, sigmaU the variance of the random effects, and indSignal the individual curves.
This function predict the warping parameters, using the estimations of those parameters, and fitting a linear mixed effect model on them.
predictionTheta(thetaObs, sigmaEpsilon)
predictionTheta(thetaObs, sigmaEpsilon)
thetaObs |
A matrix (size: n * T) corresponding of the estimations of the warping parameters. |
sigmaEpsilon |
A number, defining the variance of the noise in the linear mixed- effect model fitted on the warping parameters. |
A list, with theta, a matrix of predicted warping parameters, sigmaE the covariance of the random effects, and theta0 the mean.
This function returns estimates of parameters in the non linear functional mixed-effect model defined to warp data and estimate the underlying model with mixed effect.
warpMix(t, y, baseMu, baseU, baseW, sigmaEpsilonTilde = 10^-3, threshold = 10^-3, nIte = 100)
warpMix(t, y, baseMu, baseU, baseW, sigmaEpsilonTilde = 10^-3, threshold = 10^-3, nIte = 100)
t |
A vector of numbers, corresponding to time points. |
y |
A matrix of numbers, corresponding to observations (size: T * n). |
baseMu |
A B-spline used to decompose the global mean. |
baseU |
A B-spline used to decompose the individual effects. |
baseW |
A B-spline used to decompose the warping functions. |
sigmaEpsilonTilde |
A number, defining the variance of the noise in the linear mixed- effect model fitted on the warping parameters. |
threshold |
A number, defining the threshold of convergence. |
nIte |
Maximum number of iterations |
Notice that the warping parameters are considered as random effects.
A list, with fonct, functional quantities (indCurvAlign the individual aligned curves, warping the warping functions and theta, the warping parameters), para the estimates of parameters (alphaMu, sigmaU,theta0, sigmaTheta, sigmaEpsHat), dist the criterion computed to reach the convergence, and others other values (successAlphaMu, initTheta, initPara, CPUtime).
T = seq(0.5,0.841,length.out = 9) n = 10 t = c(qnorm(T),1) mu = cos(2*pi*t+pi/2) library(fda) baseMu = create.bspline.basis(c(0,max(t)), norder = 2, breaks = seq(0,1,0.5)) splineBasisMu = eval.basis(t,baseMu) alphaMu = Data2fd(mu,argvals = t, baseMu)$coef muApprox = (splineBasisMu) %*% alphaMu baseU = create.bspline.basis(c(0,max(t)),norder = 2, breaks = seq(0,1,0.5)) mU = baseU$nbasis sigmaU = diag(0.1,mU) library(MASS) alphaU = t(mvrnorm(n,rep(0,mU),sigmaU)) splineBasisU = eval.basis(t,baseU) U = splineBasisU %*% alphaU epsilon = t(mvrnorm(n,rep(0,length(t)),0.01 * diag(1,length(t)))) X = as.vector(muApprox) + U + epsilon baseW = create.bspline.basis(c(0,max(t)), norder = 2, breaks = c(0,0.6,1)) mW = baseW$nbasis splineBasisW = eval.basis(t,baseW) theta = t(mvrnorm(n,rep(0,mW),diag(0.1,mW + 1e-3 * diag(1,mW)))) wtheta = matrix(rep(0,n*length(t)),ncol = n) for (i in c(1:n)){ wtheta[,i] = warpTimeFunction(splineBasisW,theta[,i],t)$warpTime } Y = matrix(0, nrow = length(t), ncol = n) for (i in c(1:n)){ y = approxfun(wtheta[,i],X[,i]) Y[,i] = y(t) } warpMix(t,Y,baseMu, baseU, baseW, nIte = 2)
T = seq(0.5,0.841,length.out = 9) n = 10 t = c(qnorm(T),1) mu = cos(2*pi*t+pi/2) library(fda) baseMu = create.bspline.basis(c(0,max(t)), norder = 2, breaks = seq(0,1,0.5)) splineBasisMu = eval.basis(t,baseMu) alphaMu = Data2fd(mu,argvals = t, baseMu)$coef muApprox = (splineBasisMu) %*% alphaMu baseU = create.bspline.basis(c(0,max(t)),norder = 2, breaks = seq(0,1,0.5)) mU = baseU$nbasis sigmaU = diag(0.1,mU) library(MASS) alphaU = t(mvrnorm(n,rep(0,mU),sigmaU)) splineBasisU = eval.basis(t,baseU) U = splineBasisU %*% alphaU epsilon = t(mvrnorm(n,rep(0,length(t)),0.01 * diag(1,length(t)))) X = as.vector(muApprox) + U + epsilon baseW = create.bspline.basis(c(0,max(t)), norder = 2, breaks = c(0,0.6,1)) mW = baseW$nbasis splineBasisW = eval.basis(t,baseW) theta = t(mvrnorm(n,rep(0,mW),diag(0.1,mW + 1e-3 * diag(1,mW)))) wtheta = matrix(rep(0,n*length(t)),ncol = n) for (i in c(1:n)){ wtheta[,i] = warpTimeFunction(splineBasisW,theta[,i],t)$warpTime } Y = matrix(0, nrow = length(t), ncol = n) for (i in c(1:n)){ y = approxfun(wtheta[,i],X[,i]) Y[,i] = y(t) } warpMix(t,Y,baseMu, baseU, baseW, nIte = 2)
This function returns warped time points for a known warping parameter theta.
warpTimeFunction(splineBasisW, theta, t)
warpTimeFunction(splineBasisW, theta, t)
splineBasisW |
A matrix, corresponding to the spline basis for the warping functions, evaluted in time points. |
theta |
A matrix, corresponding to initial values for the warping parameters. |
t |
A vector of numbers, corresponding to time points. |
A vector, corresponding to the warped time points.