ppMulti: Simultaneous inference for Misaligned Multivarariate...

View source: R/pp-multi_2.R

ppMultiR Documentation

Simultaneous inference for Misaligned Multivarariate functional data

Description

Simultaneous inference for Misaligned Multivarariate functional data

Usage

ppMulti(y, t, basis_fct, warp_fct, amp_cov = NULL, warp_cov = NULL,
  iter = c(5, 5), w0 = NULL, amp_cov_par, use.nlm = c(FALSE, FALSE),
  use.laplace = FALSE, paramMax = rep(TRUE, length(amp_cov_par)),
  parallel = c(), warp_opt = TRUE, like_optim_control = list(),
  pr = FALSE, design = NULL, save_temp = NULL)

Arguments

y

List of observations in matrix form. NAs allowed

t

List of corresponding time points. NAs not allowed

basis_fct

Basis function for spline

warp_fct

Warp function

amp_cov

Amplitude covariance function. Must be on the form function(t, param)

warp_cov

Warp covariance function. Must be on the form function(t, param)

iter

two-dimensional integer of maximal number of outer iterations & maximal number of inner iterations per outer iteration.

w0

Starting values for predicted warps. Should only be used if you have results from a previous run.

amp_cov_par

Starting values for amplitude covariance parameters. There are no defaults.

use.nlm

Use nlm instead of optim for optimization? First index for outer loop, second index for inner loop.

paramMax

Logical vector. Which amplitude parameters to optimise over? Defaults to all parameters. May be overwritten by supplying control parameters.

parallel

Which parts be run in parallel? Character vector. Possibilities are c("warp prediction", "likelihood", "amplitude covariance", "spline weights"). Partial matching allowed. See details.

warp_opt

If FALSE, warp covariance parameters are kept fixed.

like_optim_control

List of control options for optimization in outer loop. See details

pr

Printing option.

design

Design for the experiments. Should be given as a list of one-dimensional vectors or as a design matrix.

save_temp

Save estimates after each outer iteration? NULL or the file path.

use_laplace

Use Laplace approximation? (as opposed to linearization)

Details

ppMulti returns a warning if applied on one-dimensional functional data.

Control parameters:

lower, upper, method, ndeps, maxit will be sent to optim/nlm. The first indices in lower/upper are warp parameter bounds. See optim for more details.

If use.nlm is selected the optimization is performed using the nlm function. Bounds are handled through transformation. Note that the optimization will not be able to actually reach the bounds.

The first entries of lower/upper correspond to warp parameters, while the rest corresponds to amplitude parameters. ppMulti does match upper/lower with corresponding entries in amp_cov, which is important when not all parameters are maximized over. This is for consistency with randomCycle and optimRule.

randomCycle and optimRule are two ways of optimizing on only a subset of the parameters at a time. These overwrites the paramMax argument. TBD: descriptions of these.

Amplitude covariance uses all time points from first observation coordinate, all time points from second observation coordinate etc.

Parallel arguments:

warp prediction runs the inner loop of warp prediction in parallel. likelihood calculates the likelihood in parallel. amplitude covariance updates (inverse) covariances in parallel (outside of outer loop). spline weights runs estimation of spline weights in parallel. Note that simm.fda just calls foreach and does not provide any tools for handling parallelization objects (this is a deliberate design strategy).

Value

A list of estimates

See Also

Important details can be found in simm-fda-short-desc.pdf

Examples

example


# Data originates from http://mocap.cs.cmu.edu/

## Data is provided as
# MCD.data y-values
# MCD.time time points

# Make basis function
bf <- make_basis_fct(seq(0, 1, len=32)[2:31], intercept=T, boundary = c(0, 1))

## Make warp function
tw <- seq(0, 1, length = 5)[2:4] ## anchor points for hyman spline
wf.noshift <- make_warp_fct(type="smooth", tw=tw)

## warp function with shift
wf <- w.shift(wf.noshift, 0.25)

warp_cov <- warp_and_shift_cov(c(0.5, 1))


## For this example we assume no amplitude cross-correlation, otherwise ...
# Matern covariance; smoothness parameter 2, unknown range.

wrapper <- function(t, par) {
  mvMatern(t, par[1], 2, rep(1,3), diag(par[2:4]))
}

lower <- c(1e-4, 1e-4,rep(1e-4, 4))
upper <- rep(1e5, 6)

# Note this will take a long time to run:
mcd.res <-ppMulti(MCD.data, MCD.time, bf, wf, amp_cov = wrapper, warp_cov, amp_cov_par = c(0.2, rep(100, 3)), pr = F, paramMax = rep(T, 4),
                  like_optim_control = list(lower = lower, upper = upper), iter = c(10, 10))



naolsen/simm.fda documentation built on June 28, 2022, 2:41 a.m.