DenseProductFPCA {fdarep}R Documentation

Product Functional Principal Component Analysis for dense repeated functional data.

Description

Note: The code works for dense functional data observed on a regular grid, missing values are allowed, written by Kehui Chen 10/09/2015, based on the original code by Pedro Delicado.

Usage

DenseProductFPCA(
  X.age.year,
  n,
  num.years,
  num.ages,
  fpca.op1 = list(),
  fpca.op2 = list(),
  pc.j = NULL,
  pc.k = NULL
)

Arguments

X.age.year

An n by (num.years x num.ages) input data matrix, such that the ith row of the matrix gives the observed values for the ith individual. The values in each row are sorted first by years (dimension 1) and then by ages (dimension 2) within each year.

n

The sample size.

num.years

Dimension 1

num.ages

Dimension 2

fpca.op1

A list of options control parameters specified by list(name=value) for FPCA in direction of (age) dimension 2; check fdapace::FPCA for available control options and default settings.

fpca.op2

A list of options control parameters specified by list(name=value) for FPCA in direction of (year) dimension 1; check fdapace::FPCA for available control options and default settings.

pc.j

A scalar denoting the maximum number of components to consider for FPCA in direction of (age) dimension 2; default: chosen by FVE if NULL.

pc.k

A scalar denoting the maximum number of components to consider for FPCA in direction of (year) dimension 1; default: chosen by FVE if NULL.

Details

The code works for dense functional data (with missing values), with density in both the direction of (age) dimension 2 and (year) dimension 1.

Value

A list containing the following fields:

Xest

An n by (num.years x num.ages) estimated matrix, based on the fitted Product FPCA model. The ith row of the matrix gives the observed values for the ith individual. The values in each row are sorted first by years (dimension 1) and then by ages (dimension 2) within each year.

mu

An num.ages by num.years matrix containing the bivariate mean function estimate.

pc.j

A scalar denoting the selected number of components for FPCA in direction of (age) dimension 2.

pc.k

A scalar denoting the selected number of components for FPCA in direction of (year) dimension 1.

scores

An n by (pc.k x pc.j) matrix of the estimated scores, such that the ith row of the matrix comprises estimated scores chi_{1,1}, chi_{1,2},...chi_{1,pc.k}, chi_{2,1}, chi_{2,2}, ..., chi_{2,pc.k}, ..., chi_{pc.j,1}, chi_{pc.j,2}, ..., chi_{pc.j,pc.k} for the ith individual.

res.psi

A list containing the FPCA output for FPCA in direction of (age) dimension 2.

res.phi

A list containing the FPCA output for FPCA in direction of (year) dimension 1.

eig

An (num.years x num.ages) by (pc.k x pc.j) matrix of the estimated product eigen functions. The rows are sorted first by years (dimension 1) and then by ages (dimension 2) within each year. The columns are sorted as in the scores.

psi

An num.ages by pc.j matrix containing the estimated eigenfunctions from FPCA in direction of (age) dimension 2.

phi

An num.years by pc.k matrix containing the estimated eigenfunctions from FPCA in direction of (year) dimension 1.

FVE

A vector of length (pc.k x pc.j), indicating the fraction of total variance explained by each product function, with corresponding 'FVEthreshold'.

VarOrdered

Variance explained by each term. The terms are ordered by var(chi_{jk}). One can select the best model by truncating at a desired level of FVE, and use names(VarOrdered) to see the corresponding model terms.

References

Examples


n <- 100 ### sample size
N <- 100
num.ages <- 20 ### dimension 2
num.years <- 15 ### dimension 1
dense_grid <- seq(0,1,length=N)
Lt <- list()
Ly <- list()
 Lt <- lapply(1:n, function(i) dense_grid)
 Ly <- lapply(Lt, function(grid) {
 y_temp <- matrix(0, num.ages, num.years)
  lapply(1:num.ages, function(s) {
    lapply(1:num.years, function(t) {
      y_temp[s, t] <<- y_temp[s, t] + cos(grid[t]) + rnorm(1, 0, 0.5)
    })
  })
  y_temp
 })
X.age.year <- matrix(0,n,num.years*num.ages)
lapply(1:n, function(i) {
  X.age.year[i,] <<- as.vector(Ly[[i]])
})
res<-DenseProductFPCA(X.age.year, n, 15, 20, fpca.op1=NULL, fpca.op2=NULL, pc.j = NULL, pc.k = NULL)
# Basic output
res$Xest
res$mu
res$pc.j
res$pc.k
res$scores
res$res.psi
res$psi
res$FVE
res$VarOrdered



[Package fdarep version 0.1.1 Index]