Comments (3)
R代码如下
N = 200
X1 = rnorm(N)
X2 = X1 + 0.001*rnorm(N)
X3 = 10*rnorm(N)
X = cbind(X1, X2, X3)
X.pca = princomp(X)
summary(X.pca)
结果为
从上述结果可以看出,前两个主成分便解释了所有的方差。
我们有两种方式得到主成分,一种是直接对协方差矩阵进行分解:
Sigma = cov(X)
eigen(Sigma)
结果为
可以看出第一主成分为X3
,第二主成分为-0.707(X1+X2)
另一种是
loadings(X.pca)
结果为
同样得出第一主成分为X3
the proportion of explained variance can be calculated as
> lambdas = c(100, 1 + (0.001^2 + sqrt(0.001^2 + 4)) / 2, 1 + (0.001^2 - sqrt(0.001^2 + 4)) / 2)
> lambdas
[1] 1.000000e+02 2.000001e+00 3.750000e-07
> cumsum(lambdas) / sum(lambdas)
[1] 0.9803921 1.0000000 1.0000000
same with the above simulation!!
from esl-cn.
而对于因子分析,我们有
library(psych)
X.fa = fa(X)
loadings(X.fa)
from esl-cn.
Related discussion of PCA on the covariance or correlation can be found in https://stats.stackexchange.com/questions/53/pca-on-correlation-or-covariance
from esl-cn.
Related Issues (20)
- Phoneme Data
- Ex. 6.8 HOT 1
- Ex. derive natural spline bases from B-spline bases HOT 2
- Ex. 9.5 HOT 7
- unclickable nav in the header
- Ex. 9.6 HOT 6
- broken gravatar for mainland China HOT 1
- disappeared avatar on the n-th (n>=2) level in phones from mainland China
- workflow for Rmd notes
- ok
- Fig. 18.1 HOT 5
- Ex 8.1 HOT 1
- Ex. 2.2
- Chapter 1.1 - Website URL of ESL is unavailable HOT 1
- Fig. 8.6 and Tab. 8.2: Example for EM HOT 2
- 请问一下,链接是不是失效了呀?那个网址esl.hohoweiya.xyz进不去了 HOT 2
- Ex. 3.7 HOT 1
- Fig. 14.29 HOT 1
- Fig. 14.30 HOT 1
- Can you tell me how the recursive computational spline basis functions of Computations for Splines (B-splines) can be used on natural cubic spline? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esl-cn.