Provides a summary of a fitted Beta Kernel Process (BKP) or
Dirichlet Kernel Process (DKP) model. Currently, this function acts as a
wrapper for print.BKP
or print.DKP
, delivering
a concise overview of key model characteristics and fitting results.
Usage
# S3 method for class 'BKP'
summary(object, ...)
# S3 method for class 'DKP'
summary(object, ...)
Value
Invisibly returns the input object (of class "BKP"
or
"DKP"
). Called for side effects: prints a concise summary of the
fitted model.
Examples
# ============================================================== #
# ========================= BKP Examples ======================= #
# ============================================================== #
#-------------------------- 1D Example ---------------------------
set.seed(123)
# Define true success probability function
true_pi_fun <- function(x) {
(1 + exp(-x^2) * cos(10 * (1 - exp(-x)) / (1 + exp(-x)))) / 2
}
n <- 30
Xbounds <- matrix(c(-2,2), nrow=1)
X <- tgp::lhs(n = n, rect = Xbounds)
true_pi <- true_pi_fun(X)
m <- sample(100, n, replace = TRUE)
y <- rbinom(n, size = m, prob = true_pi)
# Fit BKP model
model1 <- fit.BKP(X, y, m, Xbounds=Xbounds)
summary(model1)
#> --------------------------------------------------
#> Beta Kernel Process (BKP) Model
#> --------------------------------------------------
#> Number of observations (n): 30
#> Input dimensionality (d): 1
#> Kernel type: gaussian
#> Loss function used: brier
#> Optimized kernel parameters: 0.0386
#> Minimum achieved loss: 0.00012
#>
#> Prior specification:
#> Noninformative prior: Beta(1,1).
#> --------------------------------------------------
#-------------------------- 2D Example ---------------------------
set.seed(123)
# Define 2D latent function and probability transformation
true_pi_fun <- function(X) {
if(is.null(nrow(X))) X <- matrix(X, nrow=1)
m <- 8.6928
s <- 2.4269
x1 <- 4*X[,1]- 2
x2 <- 4*X[,2]- 2
a <- 1 + (x1 + x2 + 1)^2 *
(19- 14*x1 + 3*x1^2- 14*x2 + 6*x1*x2 + 3*x2^2)
b <- 30 + (2*x1- 3*x2)^2 *
(18- 32*x1 + 12*x1^2 + 48*x2- 36*x1*x2 + 27*x2^2)
f <- log(a*b)
f <- (f- m)/s
return(pnorm(f)) # Transform to probability
}
n <- 100
Xbounds <- matrix(c(0, 0, 1, 1), nrow = 2)
X <- tgp::lhs(n = n, rect = Xbounds)
true_pi <- true_pi_fun(X)
m <- sample(100, n, replace = TRUE)
y <- rbinom(n, size = m, prob = true_pi)
# Fit BKP model
model2 <- fit.BKP(X, y, m, Xbounds=Xbounds)
summary(model2)
#> --------------------------------------------------
#> Beta Kernel Process (BKP) Model
#> --------------------------------------------------
#> Number of observations (n): 100
#> Input dimensionality (d): 2
#> Kernel type: gaussian
#> Loss function used: brier
#> Optimized kernel parameters: 0.1112, 0.0680
#> Minimum achieved loss: 0.00020
#>
#> Prior specification:
#> Noninformative prior: Beta(1,1).
#> --------------------------------------------------
# ============================================================== #
# ========================= DKP Examples ======================= #
# ============================================================== #
#-------------------------- 1D Example ---------------------------
set.seed(123)
# Define true class probability function (3-class)
true_pi_fun <- function(X) {
p <- (1 + exp(-X^2) * cos(10 * (1 - exp(-X)) / (1 + exp(-X)))) / 2
return(matrix(c(p/2, p/2, 1 - p), nrow = length(p)))
}
n <- 30
Xbounds <- matrix(c(-2, 2), nrow = 1)
X <- tgp::lhs(n = n, rect = Xbounds)
true_pi <- true_pi_fun(X)
m <- sample(100, n, replace = TRUE)
# Generate multinomial responses
Y <- t(sapply(1:n, function(i) rmultinom(1, size = m[i], prob = true_pi[i, ])))
# Fit DKP model
model1 <- fit.DKP(X, Y, Xbounds = Xbounds)
summary(model1)
#> --------------------------------------------------
#> Dirichlet Kernel Process (DKP) Model
#> --------------------------------------------------
#> Number of observations (n): 30
#> Input dimensionality (d): 1
#> Output dimensionality (q): 3
#> Kernel type: gaussian
#> Loss function used: brier
#> Optimized kernel parameters: 0.0407
#> Minimum achieved loss: 0.00058
#>
#> Prior specification:
#> Noninformative prior: Dirichlet(1,...,1).
#> --------------------------------------------------
#-------------------------- 2D Example ---------------------------
set.seed(123)
# Define latent function and transform to 3-class probabilities
true_pi_fun <- function(X) {
if (is.null(nrow(X))) X <- matrix(X, nrow = 1)
m <- 8.6928; s <- 2.4269
x1 <- 4 * X[,1] - 2
x2 <- 4 * X[,2] - 2
a <- 1 + (x1 + x2 + 1)^2 *
(19 - 14*x1 + 3*x1^2 - 14*x2 + 6*x1*x2 + 3*x2^2)
b <- 30 + (2*x1 - 3*x2)^2 *
(18 - 32*x1 + 12*x1^2 + 48*x2 - 36*x1*x2 + 27*x2^2)
f <- (log(a * b) - m) / s
p <- pnorm(f)
return(matrix(c(p/2, p/2, 1 - p), nrow = length(p)))
}
n <- 100
Xbounds <- matrix(c(0, 0, 1, 1), nrow = 2)
X <- tgp::lhs(n = n, rect = Xbounds)
true_pi <- true_pi_fun(X)
m <- sample(100, n, replace = TRUE)
# Generate multinomial responses
Y <- t(sapply(1:n, function(i) rmultinom(1, size = m[i], prob = true_pi[i, ])))
# Fit DKP model
model2 <- fit.DKP(X, Y, Xbounds = Xbounds)
summary(model2)
#> --------------------------------------------------
#> Dirichlet Kernel Process (DKP) Model
#> --------------------------------------------------
#> Number of observations (n): 100
#> Input dimensionality (d): 2
#> Output dimensionality (q): 3
#> Kernel type: gaussian
#> Loss function used: brier
#> Optimized kernel parameters: 0.1245, 0.0706
#> Minimum achieved loss: 0.00061
#>
#> Prior specification:
#> Noninformative prior: Dirichlet(1,...,1).
#> --------------------------------------------------