导出功能性PCA中的主要组件

时间:2019-04-22 23:23:18

标签: r pca

我正在尝试找到从特征值中找到特征函数的方法。据我所阅读的内容,我必须将特征值乘以某种才能获得功能性PCA的主要成分。但是,执行该操作的算法是什么?我可以找到特征值,但是我不知道如何从该特征值中找到PCA。

`

#To derive the data
Data <- readMat("C:\\Users\\syeda\\Desktop\\Reserach PhD\\Data\\gait.mat")
#To separate Knee variable
kne<-Data$knee
t20 <- seq(0.025,0.975,len=20)
#To plot the raw data after standardization
matplot(t20,kne,type="l",xlab="time",ylab="Knee")
#Derive the finer time grid using 200 equispaced points
t <- seq(0.025,0.975,len=200)
#To derive knots
knt <- seq(0.025,0.975,len=7)
#To exclude the boundary points
knt <- knt[2:length(knt)-1]
#Derive the basis function
Phi <- bs(x=t,knots=knt,degree=3,intercept = FALSE,
          Boundary.knots = range(t))
plot(t,Phi[,1], type="l")
#To plot all the phi with finer time grid at once
#Spline smoothers of the sample curves on a finer time grid
pl<-ggplot(data=data.frame(Phi)) + geom_line(aes(x=t,y=Phi[,1]
)) + geom_line(aes(x=t,y=Phi[,2]))+geom_line(aes(x=t,y=Phi[,3]
))+geom_line(aes(x=t,y=Phi[,4]))+geom_line(aes(x=t,y=Phi[,5]
))+geom_line(aes(x=t,y=Phi[,6]))+geom_line(aes(x=t,y=Phi[,7]
))+geom_line(aes(x=t,y=Phi[,8]))+geom_line(aes(x=t,y=Phi[,9]))


#Time points to estimate values to draw the sample curve
#To Derive Bspline/basis function
Phi1 <- bs(t20,knots=knt,degree=3,intercept = FALSE,
           Boundary.knots = range(t))
beta1 <-(ginv( t(Phi1)%*%Phi1))%*%(t(Phi1)%*%kne) #parameter
x_hat <- Phi%*%beta1 #Estimated value
#To plot the estimated value
matplot(t,x_hat,type="l",xlab="time",ylab="X_hat")

#Question1
#Part a
#PCA

#To derive the covariance matrix
xx<-cov(t(x_hat)) # Since the position of knee is random variable, so I use transpose
#but not using transpose also giving the zero determinant
det(xx)
eig<-eigen(xx)
plot(1:200,eigen(xx)$values)




`

(我正在使用R studio)

0 个答案:

没有答案