
Functional data analysis
morie_functional_regression.RdRegression with a functional predictor: basis expansion of the curves, the resulting scalar design, the fitted coefficient function, and BIC and leave-one-out criteria for choosing the basis size.
Usage
morie_fda_design(t, X_curves, L1 = 3, L2 = 5, kind = "fourier")
morie_fda_fit(t, X_curves, y, L1 = 3, L2 = 5, kind = "fourier")
morie_fda_beta_function(t, beta_coefs, L1, kind = "fourier")
morie_fda_bic(loglik, n_params, n_obs)
morie_fda_loocv(t, x_t, L2, kind = "fourier")Arguments
- t
numeric grid of observation points
- X_curves
matrix or list of observed curves, one per subject
- y
numeric response, one value per curve
- L1
number of coefficient-function basis terms
- L2
number of curve basis terms
- kind
basis kind, "fourier" or "poly"
- beta_coefs
basis coefficients from [morie_fda_fit()]
- loglik
maximised log-likelihood
- n_params
number of estimated parameters
- n_obs
number of observations
- x_t
observed curve values
Value
A list holding the fitted quantities for the method called: point estimates, fitted values and any diagnostics it produces. See the individual method descriptions above for the components each returns.
Details
These functions mirror, in R, the implementations in the Python package
morie; the two are checked against each other by the parity
tests in tests/testthat/.
Examples
set.seed(10)
tt <- seq(0, 1, length.out = 30)
Xc <- rbind(sin(2 * pi * tt), cos(2 * pi * tt), sin(4 * pi * tt))
morie_fda_design(tt, Xc, L1 = 2, L2 = 3)
#> $X_star
#> [,1] [,2] [,3]
#> [1,] 1 5.430670e-17 5.00000e-01
#> [2,] 1 -5.679774e-17 1.12262e-17
#> [3,] 1 -2.267104e-17 -3.44552e-17
#>
#> $X
#> [,1] [,2]
#> [1,] 5.430670e-17 5.00000e-01
#> [2,] -5.679774e-17 1.12262e-17
#> [3,] -2.267104e-17 -3.44552e-17
#>
#> $C
#> [,1] [,2] [,3]
#> [1,] 5.240935e-17 1.000000e+00 -2.283911e-17
#> [2,] 3.700743e-18 -9.314716e-18 1.000000e+00
#> [3,] -2.267104e-17 -6.891039e-17 6.950858e-17
#>
#> $Q
#> [,1] [,2] [,3]
#> [1,] 1.000000e+00 1.897354e-18 -6.049848e-17
#> [2,] 1.897354e-18 5.000000e-01 1.588356e-17
#>
#> $Psi
#> [,1] [,2] [,3]
#> [1,] 1 0.000000e+00 1.00000000
#> [2,] 1 2.149704e-01 0.97662056
#> [3,] 1 4.198891e-01 0.90757542
#> [4,] 1 6.051742e-01 0.79609307
#> [5,] 1 7.621621e-01 0.64738628
#> [6,] 1 8.835120e-01 0.46840844
#> [7,] 1 9.635500e-01 0.26752834
#> [8,] 1 9.985334e-01 0.05413891
#> [9,] 1 9.868265e-01 -0.16178200
#> [10,] 1 9.289767e-01 -0.37013816
#> [11,] 1 8.276890e-01 -0.56118707
#> [12,] 1 6.876995e-01 -0.72599549
#> [13,] 1 5.155539e-01 -0.85685718
#> [14,] 1 3.193015e-01 -0.94765317
#> [15,] 1 1.081190e-01 -0.99413796
#> [16,] 1 -1.081190e-01 -0.99413796
#> [17,] 1 -3.193015e-01 -0.94765317
#> [18,] 1 -5.155539e-01 -0.85685718
#> [19,] 1 -6.876995e-01 -0.72599549
#> [20,] 1 -8.276890e-01 -0.56118707
#> [21,] 1 -9.289767e-01 -0.37013816
#> [22,] 1 -9.868265e-01 -0.16178200
#> [23,] 1 -9.985334e-01 0.05413891
#> [24,] 1 -9.635500e-01 0.26752834
#> [25,] 1 -8.835120e-01 0.46840844
#> [26,] 1 -7.621621e-01 0.64738628
#> [27,] 1 -6.051742e-01 0.79609307
#> [28,] 1 -4.198891e-01 0.90757542
#> [29,] 1 -2.149704e-01 0.97662056
#> [30,] 1 -2.449294e-16 1.00000000
#>