如何调整重叠{siar}中的椭圆重叠计算以匹配ggbiplot中的正态概率椭圆? [英] How to adjust ellipses overlap calculation in overlap{siar} to match normal probability ellipsoids in ggbiplot?
问题描述
回到此线程,我正在计算两个椭圆之间的交点,例如versicolor和virginca之间的交点体积: 使用以下mwe:
Going back to this thread, I was calculating the intersection between two ellipses e.g. the volume of the intersection between versicolor and virginca: using the following mwe:
data(iris)
log.ir <- log(iris[, 1:4])
ir.species <- iris[, 5]
ir.pca <- prcomp(log.ir, center = TRUE, scale. = TRUE)
library(ggbiplot)
g <- ggbiplot(ir.pca, obs.scale = 1, var.scale = 1,
groups = ir.species, ellipse = TRUE,
circle = TRUE)
g <- g + scale_color_discrete(name = '')
g <- g + theme(legend.direction = 'horizontal',
legend.position = 'top')
print(g)
然后我使用重叠{siar}计算椭圆,如下所示:
I then calculate the ellipsoids using overlap{siar} as follows:
library(siar)
setosa <- ir.pca$x[ir.species=="setosa",]
versicolor <- ir.pca$x[ir.species=="versicolor",]
virginica <- ir.pca$x[ir.species=="virginica",]
tmp <- overlap(versicolor[,1], versicolor[,2], virginica[,1], virginica[,2], steps = 5)
virginica.percentage <- round(x=(tmp$overlap/tmp$area2*100), digits = 2)
versicolor.percentage <- round(x=(tmp$overlap/tmp$area1*100), digits = 2)
> virginica.percentage [1] 1.54
> versicolor.percentage[1] 1.56
显然比上面的图 2 中的说明要少.
which apparently is much less than illustrated in the Figure 2 above.
正如第50行上的 ggbiplot代码所示, ggbiplot默认情况下使用概率在"ellipse.prob = 0.68"的情况下计算正态概率椭球.
As the ggbiplot code on line 50 indicates, ggbiplot calculates the normal probability ellipsoids with a probability of "ellipse.prob = 0.68" by default, what is used in the plot above.
由于文档重叠{siar}计算椭圆称为小样本量校正标准椭圆".
Due to the documentation overlap {siar} calculates the ellipses as "small sample size corrected standard ellipses".
因此,我问自己如何修改重叠部分[siar},以计算与ggbiplot中所绘制/计算的相似的正态概率椭球.
Hence I was asking myself how overlap{siar} could be modified to calculate an normal probability ellipsoid similar to the one plotted/calculated in ggbiplot.
推荐答案
SIBER的最新版本可从 https:获得://github.com/AndrewLJackson/SIBER 包含两个新函数,用于计算用户定义大小(即不同分位数)的椭圆的重叠.
the latest version of SIBER available from https://github.com/AndrewLJackson/SIBER includes two new functions to calculate overlap of ellipses of a user defined size (i.e. different quantiles).
maxLikOverlap()
和
bayesianOverlap()
我建议您使用
# install.packages("devtools") # install if necessary
devtools::install_github("andrewljackson/SIBER@master",
build_vingettes = TRUE)
library(SIBER)
并遵循小插图椭圆重叠".如果未为您安装小插图,则可以直接从github存储库 https:下载://github.com/AndrewLJackson/SIBER/tree/master/vignettes
And follow the vignette "Ellipse-Overlap". If the vignettes do not install for you, you can download them directly from the github repository https://github.com/AndrewLJackson/SIBER/tree/master/vignettes
这篇关于如何调整重叠{siar}中的椭圆重叠计算以匹配ggbiplot中的正态概率椭圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!