splineFunction1D: Calculate linear combinations of spline basis functions on...

Description Usage Arguments Value See Also Examples

View source: R/univariateExpansions.R

Description

Given scores (coefficients), this function calculates a linear combination of spline basis functions on one-dimensional domains based on the gam function in the mgcv package.

Usage

1
splineFunction1D(scores, argvals, bs, m, k)

Arguments

scores

A matrix of dimension N x K, representing the K scores (coefficients) for each of the N observations.

argvals

A list containing a vector of x-values, on which the functions should be defined.

bs

A character string, specifying the type of basis functions to be used. Please refer to smooth.terms for a list of possible basis functions.

m

A numeric, the order of the spline basis. See s for details.

k

A numeric, the number of basis functions used. See s for details.

Value

An object of class funData with N observations on argvals, corresponding to the linear combination of spline basis functions.

See Also

univExpansion, gam, splineBasis1D

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 
set.seed(1234)

# simulate coefficients (scores) for 10 observations and 8 basis functions
N <- 10
K <- 8
scores <- t(replicate(n = N, rnorm(K, sd = (K:1)/K)))
dim(scores)

# expand spline basis on [0,1]
funs <- MFPCA:::splineFunction1D(scores = scores, argvals = list(seq(0,1,0.01)),
                         bs = "ps", m = 2, k = K) # params for mgcv
                         
oldPar <- par(no.readonly = TRUE)
par(mfrow = c(1,1))                        

plot(funs, main = "Spline reconstruction")

par(oldPar)

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