Skip to contents

Create a dataset with indices from a functional dataset in one or multiple dimensions

Usage

generate_indices(
  curves,
  k,
  grid,
  bs = "cr",
  indices = c("EI", "HI", "MEI", "MHI"),
  ...
)

Arguments

curves

matrix with dimension \(n \times p\) in the case of a one-dimensional functional dataset, or array of dimension \(n \times p \times q\) in the case of a multivariate functional dataset. \(n\) represents the number of curves, \(p\) the number of values along the curve, and in the second case, \(q\) is the number of dimensions.

k

Number of basis functions for the B-splines. If equals to 0, the number of basis functions will be automatically selected.

grid

Atomic vector of type numeric with two elements: the lower limit and the upper limit of the evaluation grid. If not provided, it will be selected automatically.

bs

A two letter character string indicating the (penalized) smoothing basis to use. See smooth.terms.

indices

Set of indices to be applied to the dataset. They should be any between EI, HI, MEI and MHI.

...

Additional arguments (unused)

Value

A dataframe containing the indices provided in indices for original data, first and second derivatives

Examples

x1 <- array(c(1, 2, 3, 3, 2, 1, 5, 2, 3, 9, 8, 7, -1, -5, -6, 2, 3, 0, -1, 0, 2, -1, -2, 0),
  dim = c(3, 4, 2)
)
generate_indices(x1, k = 4)
#> Warning: Fit captures <50% of input data variability for at least one function -- consider increasing no. of basis functions 'k' or decreasing penalization.
#>       dtaEI    ddtaEI   d2dtaEI     dtaHI    ddtaHI   d2dtaHI    dtaMEI
#> 1 0.6666667 0.6666667 0.6666667 0.3333333 0.3333333 0.3333333 0.6666667
#> 2 0.6666667 0.6666667 0.6666667 0.3333333 0.3333333 0.3333333 0.5000000
#> 3 0.6666667 0.6666667 0.6666667 0.3333333 0.3333333 0.3333333 0.5833333
#>     ddtaMEI  d2dtaMEI    dtaMHI   ddtaMHI d2dtaMHI
#> 1 0.6666667 0.6666667 0.4166667 0.3333333      0.5
#> 2 0.5000000 0.5000000 0.4166667 0.5000000      0.5
#> 3 0.5000000 0.3333333 0.4166667 0.5000000      0.5

x2 <- matrix(c(1, 2, 3, 3, 2, 1, 5, 2, 3, 9, 8, 7), nrow = 3, ncol = 4)
generate_indices(x2, k = 4)
#>       dtaEI    ddtaEI   d2dtaEI     dtaHI    ddtaHI   d2dtaHI dtaMEI   ddtaMEI
#> 1 0.6666667 0.6666667 0.3333333 0.3333333 0.3333333 0.3333333   0.50 0.3333333
#> 2 0.6666667 0.6666667 0.6666667 0.3333333 0.3333333 0.6666667   0.25 0.3333333
#> 3 0.6666667 0.6666667 0.6666667 0.3333333 0.3333333 0.3333333   0.25 0.3333333
#>    d2dtaMEI    dtaMHI   ddtaMHI  d2dtaMHI
#> 1 0.1666667 0.8333333 0.6666667 0.5000000
#> 2 0.5000000 0.5833333 0.6666667 0.8333333
#> 3 0.3333333 0.5833333 0.6666667 0.6666667