_images/logo.png

Elastic Functional Principal Component Analysis

After we have aligned our data we can compute functional principal component analysis (fPCA) on the aligned data, warping functions, and jointly

[1]:
import fdasrsf as fs
import numpy as np

We will load in our example data again and compute the alignment

[2]:
data = np.load('../../bin/simu_data.npz')
time = data['arr_1']
f = data['arr_0']
obj = fs.fdawarp(f,time)
obj.srsf_align(parallel=True)
Initializing...
Compute Karcher Mean of 21 function in SRSF space...
updating step: r=1
updating step: r=2

Vertical fPCA

We will first compute fPCA on the aligned functions, by constructing the object and computing the PCA for the number of components, default=3)

[3]:
vpca = fs.fdavpca(obj)
vpca.calc_fpca(no=3)

We then can plot the principal directions

[4]:
vpca.plot()
_images/fpca_example_7_0.png
_images/fpca_example_7_1.png

Horizontal fPCA

We can then compute PCA on the set of warping functions

[5]:
hpca = fs.fdahpca(obj)
hpca.calc_fpca(no=3)

We then can plot the principal directions

[6]:
hpca.plot()
_images/fpca_example_11_0.png
_images/fpca_example_11_1.png

Joint fPCA

We can also compute the fPCA on jointly on the phase/amplitude space if we feel there is correlation between the variabilities

[7]:
jpca = fs.fdajpca(obj)
jpca.calc_fpca(no=3)

We then can plot the principal directions

[8]:
jpca.plot()
_images/fpca_example_15_0.png
_images/fpca_example_15_1.png