Learn R Programming

rSFA (version 1.5)

sfa2: The SFA2 algorithm, SFA with degree 2 expansion.

Description

Y = sfa2(X) performs expanded Slow Feature Analysis on the input data X and returns the output signals Y ordered by increasing temporal variation, i.e. the first signal Y[,1] is the slowest varying one, Y[,2] the next slowest varying one and so on. The input data have to be organized with each variable in a column and each data (time) point in a row, i.e. X(t,i) is the value of variable i at time t. By default an expansion to the space of 2nd degree polynomials is done, this can be changed by using different functions for xpDimFun and sfaExpandFun.

Usage

sfa2(
  x,
  method = "SVDSFA",
  ppType = "PCA",
  xpDimFun = xpDim,
  sfaExpandFun = sfaExpand
)

Arguments

x

input data

method

eigenvector calculation method: ="SVDSFA" for singular value decomposition (recommended) or ="GENEIG" for generalized eigenvalues (unstable!). GENEIG is not implemented in the current version, since R lacks an easy option to calculate generalized eigenvalues.

ppType

preprocessing type: ="PCA" (principal component analysis) or ="SFA1" (linear sfa)

xpDimFun

function to calculate dimension of expanded data

sfaExpandFun

function to expand data

Value

list sfaList with all SFA information, among them are

y

a matrix containing the output Y (as described above)

-

all input parameters to sfa2Create

-

all elements of sfaList as specified in sfa2Step

See Also

sfa2Step sfa2Create sfaExecute sfa1

Examples

Run this code
# NOT RUN {
## prepare input data for simple demo
t=seq.int(from=0,by=0.011,to=2*pi)
x1=sin(t)+cos(11*t)^2
x2=cos(11*t)
x=data.frame(x1,x2)
## perform sfa2 algorithm with data
res = sfa2(x)
## plot slowest varying function of result
plot(t, res$y[,1],type="l",main="output of the slowest varying function")
## see http://www.scholarpedia.org/article/Slow_feature_analysis#The_algorithm
## for detailed description of this example
# }

Run the code above in your browser using DataLab