为排序图添加置信范围曲线
上一篇文章我们利用ggord的源代码改写了一个为LDA排序图添加置信曲线的函数,现在Y叔已经把它改写成了一个geom添加在了他的yyplot包中。y叔扩展了它的功能,现在支持ggord中的其他排序图(我没有进行全面的测试)。
library(ggord)
library(yyplot)
library(MASS)
LDA
ord <- lda(Species ~ ., iris, prior = rep(1, 3)/3)
ggord(ord, iris$Species) + geom_ord_ellipse(lty=2)
PCA
ord <- prcomp(iris[, 1:4])
ggord(ord, iris$Species) + geom_ord_ellipse(lty=2)
MDS
library(vegan)
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.4-4
ord <- metaMDS(iris[, 1:4])
## Run 0 stress 0.03775523
## Run 1 stress 0.05879963
## Run 2 stress 0.05771902
## Run 3 stress 0.03775576
## ... Procrustes: rmse 6.70624e-05 max resid 0.0002355622
## ... Similar to previous best
## Run 4 stress 0.0599531
## Run 5 stress 0.04367524
## Run 6 stress 0.05537389
## Run 7 stress 0.03775524
## ... Procrustes: rmse 9.47124e-06 max resid 4.820747e-05
## ... Similar to previous best
## Run 8 stress 0.03775578
## ... Procrustes: rmse 2.073778e-05 max resid 0.000125111
## ... Similar to previous best
## Run 9 stress 0.04367554
## Run 10 stress 0.03775534
## ... Procrustes: rmse 1.898558e-05 max resid 5.211088e-05
## ... Similar to previous best
## Run 11 stress 0.04367546
## Run 12 stress 0.06174009
## Run 13 stress 0.04367526
## Run 14 stress 0.0377554
## ... Procrustes: rmse 3.074059e-05 max resid 0.0001171343
## ... Similar to previous best
## Run 15 stress 0.05093855
## Run 16 stress 0.05398536
## Run 17 stress 0.03775584
## ... Procrustes: rmse 7.169048e-05 max resid 0.0002630254
## ... Similar to previous best
## Run 18 stress 0.03775551
## ... Procrustes: rmse 4.556503e-05 max resid 0.0001590274
## ... Similar to previous best
## Run 19 stress 0.04804016
## Run 20 stress 0.04355825
## *** Solution reached
ggord(ord, iris$Species) + geom_ord_ellipse(lty=2)