## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4.5, fig.align = "center" ) ## ----message=FALSE, warning=FALSE--------------------------------------------- library(AddiVortes) ## ----------------------------------------------------------------------------- set.seed(2026) n <- 120 x <- data.frame( x1 = runif(n, -1, 1), x2 = runif(n, -1, 1) ) y <- factor(ifelse(x$x1 + x$x2 > 0, "active", "inactive"), levels = c("inactive", "active")) fit_bin <- AddiVortes( y, x, m = 200, totalMCMCIter = 2000, mcmcBurnIn = 500, showProgress = FALSE ) fit_bin$task fit_bin$classLevels fit_bin$inSampleAccuracy ## ----------------------------------------------------------------------------- p_hat <- predict(fit_bin, x, type = "response", showProgress = FALSE) y_hat <- predict(fit_bin, x, type = "class", showProgress = FALSE) p_int <- predict(fit_bin, x, type = "quantile", quantiles = c(0.05, 0.95), showProgress = FALSE ) mean(y_hat == y) range(p_hat) head(cbind(prob = round(p_hat, 3), lower = round(p_int[, 1], 3), upper = round(p_int[, 2], 3), class = as.character(y_hat))) ## ----------------------------------------------------------------------------- plot(p_hat, as.integer(y) - 1, xlab = "Predicted P(active)", ylab = "Observed class", pch = 19, col = "steelblue") abline(v = 0.5, lty = 2, col = "grey40") ## ----------------------------------------------------------------------------- set.seed(2026) n3 <- 90 x3 <- data.frame( x1 = rnorm(n3), x2 = rnorm(n3) ) y3 <- cut(x3$x1, breaks = c(-Inf, -0.5, 0.5, Inf), labels = c("low", "mid", "high")) fit_multi <- AddiVortes( y3, x3, m = 200, totalMCMCIter = 2000, mcmcBurnIn = 500, showProgress = FALSE ) fit_multi$task fit_multi$nLatents fit_multi$inSampleAccuracy ## ----------------------------------------------------------------------------- p3 <- predict(fit_multi, x3, type = "response", showProgress = FALSE) cls3 <- predict(fit_multi, x3, type = "class", showProgress = FALSE) head(round(p3, 3)) mean(abs(rowSums(p3) - 1) < 1e-8) table(predicted = cls3, observed = y3) .