我在这里看官方教程。我完全复制了他们的代码,但 RStudio 给了我关于行, , B = GOOD
(错误消息:)unexpected ',' in ","
和dfit
(错误消息:)的错误消息object dfit not found
。这是我复制的确切代码:
# install.packages("bnlearn")
library(bnlearn)
cptA = matrix(c(0.4, 0.6), ncol = 2, dimnames = list(NULL, c("LOW", "HIGH")))
#cptA
cptB = matrix(c(0.8, 0.2), ncol = 2, dimnames = list(NULL, c("GOOD", "BAD")))
#cptB
cptC = c(0.5, 0.5, 0.4, 0.6, 0.3, 0.7, 0.2, 0.8)
dim(cptC) = c(2, 2, 2)
dimnames(cptC) = list("C" = c("TRUE", "FALSE"), "A" = c("LOW", "HIGH"), "B" = c("GOOD", "BAD"))
#cptC
, , B = GOOD
net = model2network("[A][B][C|A:B]")
dfit = custom.fit(net, dist = list(A = cptA, B = cptB, C = cptC))
dfit
有谁知道这里发生了什么?我做错了什么?