tfpca: Temporal Functional Principal Component

Description Usage Arguments Value References See Also Examples

Description

This function is used on step II of the STDF algorithm. It does not need to be used directly, since it's mostly an wrapper to fda package function calls. It behaves similarly to the pca.fd function, but rescales the eigenfunctions/eigenvalues in a way that's needed by the stdf function. Notice tfpca do not handle NA's in the data values. It might be useful do to some kind of nearest neightbor imputation if possible. The fda function data2fd does a least-squares fit of the basis function, which can be helpful in preprocessing the data. The tuning parameter zeta must be passed manually.

Usage

1
tfpca(MatY, L, t.fit, zeta = 0, tbas = 20)

Arguments

MatY

The data organized in a matrix, with each time series in a column. Missing values are currently not handled properly.

L

The number of functional principal components to be returned.

t.fit

Values of the time-domain at which a value is fitted.

zeta

Smoothness parameter, must be provided. Defaults to 0 (no smoothing).

tbas

Number of spline basis functions used in the smooth.

Value

List of three items

values

numeric vector of L Eigenvalue estimates

vectors

matrix of L columns with Eigenfunction estimates observed at t.fit

harmfd

Internal use. Prediction of the Eigenfunction at new values of t, say under vector t.pred, can be obtained with the next three parameters. The syntax is fda::eval.fd(t.pred, harmfd)*t(matrix(sqrt(nObs/etan), L, length(t.pred)))

nObs

Internal use.

etan

Internal use.

References

Ramsay, J. O. (2006) Functional Data Analysis. New York: Springer.

See Also

pca.fd, stdf

Examples

1
2
3
4
5
6
7
8
9
# This example uses fda's CanadianWeather dataset:
library(fda)
test <- tfpca(CanadianWeather$dailyAv[,,"Temperature.C"], 2, 1:365, 0, 20)
test2 <- tfpca(CanadianWeather$dailyAv[,,"Temperature.C"], 2, 1:365, 1e5, 20)
layout(matrix(1:4, byrow = TRUE, ncol = 2))
plot(test$vectors[,1], type="l", main="First Principal Component")
plot(test$vectors[,2], type="l", main="Second Principal Component")
plot(test2$vectors[,1], type="l", main="Smooth First Principal Component")
plot(test2$vectors[,2], type="l", main="Smooth Second Principal Component")

guiludwig/stdf documentation built on May 17, 2019, 9:27 a.m.