# splineBasis1D: Calculate a spline basis decomposition for functional data on... In MFPCA: Multivariate Functional Principal Component Analysis for Data Observed on Different Dimensional Domains

## Description

These functions calculate a penalized or unpenalized spline basis decomposition for functional data on one-dimensional domains based on the gam function in the mgcv package.

## Usage

 ```1 2 3 4``` ```splineBasis1D(funDataObject, bs = "ps", m = NA, k = -1) splineBasis1Dpen(funDataObject, bs = "ps", m = NA, k = -1, parallel = FALSE) ```

## Arguments

 `funDataObject` An object of class `funData` containing the observed functional data samples and for which the basis decomposition is calculated. `bs` A character string, specifying the type of basis functions to be used. Defaults to `"ps"` (B-spline functions). Please refer to `smooth.terms` for a list of possible basis functions. `m` A numeric, the order of the spline basis. Defaults to `NA`, i.e. the order is chosen automatically. See `s` for details. `k` A numeric, the number of basis functions used. Defaults to `-1`, i.e. the number of basis functions is chosen automatically. See `s` for details. `parallel` Logical (only for `splineBasis1Dpen`. If `TRUE`, the coefficients for the basis functions are calculated in parallel. The implementation is based on the `foreach` function and requires a parallel backend that must be registered before. See `foreach` for details.

## Value

 `scores` A matrix of scores (coefficients) with dimension `N x K`, reflecting the weights for each of the `K` basis functions and for each of the `N` observations. `B` A matrix containing the scalar product of all pairs of basis functions. `ortho` Logical, set to `FALSE`, as basis functions are not orthonormal. `functions` `NULL`, as basis functions are known `settings` A list with entries `bs`, `m` and `k`, giving the actual parameters used for generating the spline basis functions.

`univDecomp`, `gam`, `foreach`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18``` ```# generate some data dat <- simFunData(argvals = seq(0,1,0.01), M = 5, eFunType = "Poly", eValType = "linear", N = 100)\$simData # calculate spline basis decomposition dataDec <- MFPCA:::splineBasis1D(dat) # use mgcv's default parameters str(dataDec) # add some noise to the data noisyDat <- addError(dat, sd = 0.5) # calculate spline basis decomposition with penalization to reduce noise noisyDataDec <- MFPCA:::splineBasis1Dpen(dat) # use mgcv's default parameters str(noisyDataDec) # check if noise has been filtered out by penalization all.equal(noisyDataDec\$scores, dataDec\$scores, check.attributes = FALSE) # -> have almost the same coefficients ```

### Example output

```Loading required package: funData

Attaching package: 'funData'

The following object is masked from 'package:stats':

integrate

List of 5
\$ scores   : num [1:100, 1:10] -1.4283 -0.2946 0.0229 1.5949 0.2489 ...
..- attr(*, "dimnames")=List of 2
.. ..\$ : NULL
.. ..\$ : chr [1:10] "dM(Intercept)" "dM" "dM" "dM" ...
\$ B        : num [1:10, 1:10] 1 -0.002757 0.000219 0.001111 0.001111 ...
\$ ortho    : logi FALSE
\$ functions: NULL
\$ settings :List of 3
..\$ bs: chr "ps"
..\$ k : num 10
..\$ m : num [1:2] 2 2
List of 5
\$ scores   : num [1:100, 1:10] -1.4283 -0.2946 0.0229 1.5949 0.2489 ...
..- attr(*, "dimnames")=List of 2
.. ..\$ : chr [1:100] "result.1" "result.2" "result.3" "result.4" ...
.. ..\$ : chr [1:10] "(Intercept)" "s(x).1" "s(x).2" "s(x).3" ...
\$ B        : num [1:10, 1:10] 1 -0.002757 0.000219 0.001111 0.001111 ...
\$ ortho    : logi FALSE
\$ functions: NULL
\$ settings :List of 3
..\$ bs: chr "ps"
..\$ k : num 10
..\$ m : num [1:2] 2 2
[1] "Mean relative difference: 3.933435e-06"
```

MFPCA documentation built on May 2, 2019, 2:49 p.m.