| Library: | fda |
| See also: | fdaspca CPCFGalg data2fd |
| Quantlet: | fdacpcaK | |
| Description: | perform the common estimation for functional PCA, using simultaneous diagonalization |
| Usage: | {fpcaresult,values,varprop,scores} = fdacpcaK(CovC,N,basisfd,lambda,lfd,npc,orthonorm) | |
| Input: | ||
| CovC | p x p x k array of covariances of coefficients | |
| N | k x 1 vector of weight, usually number of observations in each group | |
| basisfd | list, functional basis (fdbasis object) | |
| lambda | scalar, smoothing parameter | |
| lfd | list, LDO object, linear differential opereator | |
| npc | scalar, number of eigenfunctions, default = 4 | |
| norm | string, normalization type, if norm=="orthonorm" coef are orthonormalized (with respect to the basis penalty matrix), if norm=="norm" the coefficients are renormalized to norm=1, default is no normalization | |
| Output: | ||
| fpcaresult | list, functional data (fd) object | |
| values | npc x 2 matrix, eigenvalues | |
| varprop | npc x 2 matrix, variance proportions | |
library("plot")
library("fda")
axeson()
t = read("dailtemp.dat")
y =t[,1:17]
y2=t[,18:35]
tvec=#(1:365)/365
fdb = createfdbasis("fourier", #(0,1),9,1)
fdtempf31=data2fd(y,tvec,fdb)
fd2tempf31=data2fd(y2,tvec,fdb)
covfdtempf31=cov(fdtempf31.coef')
covfd2tempf31=cov(fd2tempf31.coef')
covC31temp=stack(covfdtempf31,covfd2tempf31)
N=17|17 ; weights
cpc=fdacpcaK(covC31temp,N,fdb,0.000001,2,4)
Tempdi=createdisplay(1,1)
grtempfc=grfd(cpc.fcpcaKresult,grid(0,1/100,100),0,#(0,1,2,3))
show(Tempdi,1,1,grtempfc)
Plots the common estimation of first and second part of the temperature data set and prints the eigenvalues for both groups