[英]Error in chol.default(Cxx) : the leading minor of order is not positive definite
[英]How to Fix Error in chol.defalt(cov): leading minor of order 2 is not positive definite?
我試圖在散點圖上設置一個門,但我遇到了錯誤:“chol.default(cov) 中的錯誤:2 階的前導次要不是正定的”我不知道它是什么意思是我很難找到理解它的資源。
這是我的代碼!
meantBB<- c("BL1.H"=9, "BL3.H"=9)
cov <- matrix(c(7.5,7.9,9,10.5), ncol = 2, dimnames=list(c("BL1.H", "BL3.H"), c("BL1.H", "BL3.H")))
GateBB<- ellipsoidGate(.gate = cov,
mean = meantBB,
distance = 1,
filterId = "test gate")
ps_rose.0t <- ggcyto::ggcyto(InFCS_ta[rose.0], aes(x = `BL3.H`, y = `BL1.H`)) +
geom_hex(bins = 300) +
theme_bw()+
theme(axis.text = element_text(size = 12),
axis.title = element_text(size = 12),
strip.background = element_rect(colour="white", fill="white"),
panel.border = element_rect(colour = "white"))+
geom_gate(GateBB, col = "#CB0001", fill = "ffa401", alpha = 0.8, size = 1)
plot(ps_rose.0t, echo = FALSE)
謝謝!
為什么協方差矩陣是非對稱的? (閱讀?chol
。“計算實對稱正定方陣的 Choleski 分解。”)你確定你的cov
定義沒有錯字嗎? 當我將第三個條目從 9 更改為 7.9 時,錯誤消失了。
cov <- matrix(c(7.5,7.9,7.9,10.5), ncol = 2, dimnames=list(c("BL1.H", "BL3.H"), c("BL1.H", "BL3.H")))
chol(cov)
#----------------
BL1.H BL3.H
BL1.H 2.738613 2.884672
BL3.H 0.000000 1.476031
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.