简体   繁体   English

如何在PCA后计算T2 Hotelling?

[英]How can I compute T2 Hotelling after PCA?

I need to compute Hotelling T2 and SPE (Q), after the PCA analysis. 在PCA分析之后,我需要计算Hotelling T2和SPE(Q)。 I did it using the pca function from library mdatools, but I see the PC computed are different from the one computed by prcomp or princomp functions. 我是使用库mdatools中的pca函数完成的,但是我看到计算的PC与prcomp或princomp函数计算的不同。 Why? 为什么?

library(mdatools)
NF4.3.pca4 <- pca(NF4.3, ncomp = 15, center = T, scale = T)
res <- NF4.3.pca4$calres

NF4.3.pca <- prcomp(NF4.3, center = T, scale. = T) #different eigenvalues

Is there another way to calculate T2 and SPE from principal components? 还有另一种从主成分计算T2和SPE的方法吗?

Data: 数据:

ASSORB_CAT1;ASSORB_CAT3;ASSORB_VOLANO;AZOTO_IN
0.03662109;23.55957;-12.30469;39.3
0;25.36621;-11.09619;39.2
-0.02441406;21.92383;-11.26709;39.2
-0.02441406;23.10791;-11.07178;39.1
-0.04882813;22.81494;-10.57129;39.59975
0;24.24316;-11.23047;39.89737
0;22.63184;-11.43799;39.8
-0.04882813;24.34082;-13.61084;39.5
0;21.83838;-11.1084;39.4
0;24.3042;-12.08496;39.3
0;24.67041;-12.40234;39.3

I will explain on an other dataset, as I do not have access to what you are analysing. 我将解释另一个数据集,因为我无法访问您正在分析的内容。 The two methods that you applied on my dataset are identical. 您在我的数据集上应用的两种方法是相同的。 What can be confusing though is that if you look at stats_pca$sdev it is a root square of the vector of eigenvalues, whereas mdatools_pca$eigenvals reports eigenvalues themselves. 可能令人困惑的是,如果你看一下stats_pca$sdev它是特征值向量的根平方 ,而mdatools_pca$eigenvals自己报告特征值。

library(mdatools)
data("mtcars")
stats_pca <- prcomp(mtcars, center=TRUE, scale.=TRUE)
mdatools_pca <- mdatools::pca(mtcars, center=TRUE, scale=TRUE)

all.equal(sqrt(mdatools_pca$eigenvals)[1:length(stats_pca$sdev)], stats_pca$sdev)
# TRUE

If you want to go on with Hotelling's T2 I would recommend this read: PCA and Hotelling's T^2 for confidence intervall in R . 如果你想继续使用Hotelling的T2,我会推荐这个: PCA和Hotelling的T ^ 2,用于R中的置信度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM