Create a dataset with indices from a functional dataset in one or multiple dimensions
Source:R/indices.R
generate_indices.Rd
Create a dataset with indices from a functional dataset in one or multiple dimensions
Usage
generate_indices(
curves,
k,
bs = "cr",
indices = c("EI", "HI", "MEI", "MHI"),
n_cores = 1,
...
)
Arguments
- curves
matrix
with dimension \(n \times p\) in the case of a one-dimensional functional dataset, orarray
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.
- 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.
- n_cores
Number of cores to do parallel computation. 1 by default, which mean no parallel execution. Must be an integer number greater than 1.
- ...
Additional arguments for tfb. See
tfb
.
Value
A dataframe containing the indices provided in indices
for
original data, first and second derivatives
Examples
# 3-dimensional array
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
# matrix
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
# using additional parameter for tf::tfb
curves <- sim_model_ex1(n = 10)
generate_indices(
curves = curves,
k = 20,
bs = "bs",
m = c(3,2), # additional parameter for tfb
penalized = FALSE # additional parameter for tfb
)
#> dtaEI ddtaEI d2dtaEI dtaHI ddtaHI d2dtaHI dtaMEI ddtaMEI d2dtaMEI
#> 1 0.85 0.95 0.95 0.05 0.05 0.05 0.1533333 0.4916667 0.5400000
#> 2 0.90 0.95 0.95 0.05 0.05 0.05 0.6033333 0.4033333 0.4533333
#> 3 0.90 0.95 0.95 0.10 0.05 0.05 0.4233333 0.5100000 0.5000000
#> 4 0.80 0.95 0.95 0.05 0.05 0.05 0.1916667 0.4783333 0.4366667
#> 5 0.50 0.95 0.95 0.05 0.05 0.05 0.1083333 0.4966667 0.5066667
#> 6 0.85 0.95 0.95 0.05 0.05 0.05 0.3933333 0.4250000 0.4400000
#> 7 0.85 0.95 0.95 0.05 0.05 0.05 0.3966667 0.4783333 0.4633333
#> 8 0.90 0.95 0.95 0.05 0.05 0.05 0.4183333 0.5316667 0.4400000
#> 9 0.90 0.95 0.95 0.05 0.05 0.05 0.3633333 0.4550000 0.4666667
#> 10 0.80 0.95 0.95 0.05 0.05 0.05 0.2566667 0.4500000 0.5200000
#> 11 0.95 0.95 0.95 0.15 0.05 0.05 0.4366667 0.4983333 0.5366667
#> 12 0.95 0.95 0.95 0.30 0.05 0.05 0.8450000 0.4133333 0.4500000
#> 13 0.95 0.95 0.95 0.20 0.05 0.05 0.7116667 0.5133333 0.4966667
#> 14 0.95 0.95 0.95 0.10 0.05 0.05 0.4850000 0.4850000 0.4333333
#> 15 0.90 0.95 0.95 0.10 0.05 0.05 0.3966667 0.5000000 0.5033333
#> 16 0.95 0.95 0.95 0.30 0.05 0.05 0.7166667 0.4316667 0.4366667
#> 17 0.95 0.95 0.95 0.10 0.05 0.05 0.6233333 0.4850000 0.4600000
#> 18 0.95 0.95 0.95 0.15 0.05 0.05 0.7050000 0.5383333 0.4366667
#> 19 0.95 0.95 0.95 0.20 0.05 0.05 0.6900000 0.4616667 0.4633333
#> 20 0.95 0.95 0.95 0.15 0.05 0.05 0.5816667 0.4533333 0.5166667
#> dtaMHI ddtaMHI d2dtaMHI
#> 1 0.2033333 0.5416667 0.5900000
#> 2 0.6533333 0.4533333 0.5033333
#> 3 0.4733333 0.5600000 0.5500000
#> 4 0.2416667 0.5283333 0.4866667
#> 5 0.1583333 0.5466667 0.5566667
#> 6 0.4433333 0.4750000 0.4900000
#> 7 0.4466667 0.5283333 0.5133333
#> 8 0.4683333 0.5816667 0.4900000
#> 9 0.4133333 0.5050000 0.5166667
#> 10 0.3066667 0.5000000 0.5700000
#> 11 0.4866667 0.5483333 0.5866667
#> 12 0.8950000 0.4633333 0.5000000
#> 13 0.7616667 0.5633333 0.5466667
#> 14 0.5350000 0.5350000 0.4833333
#> 15 0.4466667 0.5500000 0.5533333
#> 16 0.7666667 0.4816667 0.4866667
#> 17 0.6733333 0.5350000 0.5100000
#> 18 0.7550000 0.5883333 0.4866667
#> 19 0.7400000 0.5116667 0.5133333
#> 20 0.6316667 0.5033333 0.5666667