I'm looking at the official tutorial here. I copied their code exactly but RStudio is giving me error messages for the lines , , B = GOOD
(error message: unexpected ',' in ","
) and dfit
(error message: object dfit not found
). Here's the exact code I copied:
# 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
Does anyone know what's going on here? What did I do wrong?