calibrateBinary: Calibration for Binary Outputs

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/calibrateBinary.R

Description

The function performs the L2 calibration method for binary outputs.

Usage

1
2
3
4
calibrateBinary(Xp, yp, Xs1, Xs2, ys, K = 5, lambda = seq(0.001, 0.1,
  0.005), kernel = c("matern", "exponential")[1], nu = 1.5, power = 1.95,
  rho = seq(0.05, 0.5, 0.05), sigma = seq(100, 20, -1), lower, upper,
  verbose = TRUE)

Arguments

Xp

a design matrix with dimension np by d.

yp

a response vector with length np. The values in the vector are 0 or 1.

Xs1

a design matrix with dimension ns by d. These columns should one-by-one correspond to the columns of Xp.

Xs2

a design matrix with dimension ns by q.

ys

a response vector with length ns. The values in the vector are 0 or 1.

K

a positive integer specifying the number of folds for fitting kernel logistic regression and generalized Gaussian process. The default is 5.

lambda

a vector specifying lambda values at which CV curve will be computed for fitting kernel logistic regression. See cv.KLR.

kernel

input for fitting kernel logistic regression. See KLR.

nu

input for fitting kernel logistic regression. See KLR.

power

input for fitting kernel logistic regression. See KLR.

rho

rho value at which CV curve will be computed for fitting kernel logistic regression. See KLR.

sigma

a vector specifying values of the tuning parameter σ at which CV curve will be computed for fitting generalized Gaussian process. See Details.

lower

a vector of size p+q specifying lower bounds of the input space for rbind(Xp,Xs1) and Xs2.

upper

a vector of size p+q specifying upper bounds of the input space for rbind(Xp,Xs1) and Xs2.

verbose

logical. If TRUE, additional diagnostics are printed. The default is TRUE.

Details

The function performs the L2 calibration method for computer experiments with binary outputs. The input and ouput of physical data are assigned to Xp and yp, and the input and output of computer data are assigned to cbind(Xs1,Xs2) and ys. Note here we separate the input of computer data by Xs1 and Xs2, where Xs1 is the shared input with Xp and Xs2 is the calibration input. The idea of L2 calibration is to find the calibration parameter that minimizes the discrepancy measured by the L2 distance between the underlying probability functions in the physical and computer data. That is,

\hat{θ}=\arg\min_{θ}\|\hat{η}(\cdot)-\hat{p}(\cdot,θ)\|_{L_2(Ω)},

where \hat{η}(x) is the fitted probability function for physical data, and \hat{p}(x,θ) is the fitted probability function for computer data. In this L2 calibration framework, \hat{η}(x) is fitted by the kernel logistic regression using the input Xp and the output yp. The tuning parameter λ for the kernel logistic regression can be chosen by k-fold cross-validation, where k is assigned by K. The choices of the tuning parameter are given by the vector lambda. The kernel function for the kernel logistic regression can be given by kernel, where Matern kernel or power exponential kernel can be chosen. The arguments power, nu, rho are the tuning parameters in the kernel functions. See KLR. For computer data, the probability function \hat{p}(x,θ) is fitted by the Bayesian Gaussian process in Williams and Barber (1998) using the input cbind(Xs1,Xs2) and the output ys, where the Gaussian correlation function,

R_{σ}(\mathbf{x}_i,\mathbf{x}_j)=\exp\{-∑^{d}_{l=1}σ(x_{il}-x_{jl})^2 \},

is used here. The vector sigma is the choices of the tuning parameter σ, and it will be chosen by k-fold cross-validation. More details can be seen in Sung et al. (unpublished). The arguments lower and upper are lower and upper bounds of the input space, which will be used in scaling the inputs and optimization for θ. If they are not given, the default is the range of each column of rbind(Xp,Xs1), and Xs2.

Value

a matrix with number of columns q+1. The first q columns are the local (the first row is the global) minimal solutions which are the potential estimates of calibration parameters, and the (q+1)-th column is the corresponding L2 distance.

Author(s)

Chih-Li Sung <iamdfchile@gmail.com>

See Also

KLR for performing a kernel logistic regression with given lambda and rho. cv.KLR for performing cross-validation to estimate the tuning parameters.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
library(calibrateBinary)

set.seed(1)
#####   data from physical experiment   #####
np <- 10
xp <- seq(0,1,length.out = np)
eta_fun <- function(x) exp(exp(-0.5*x)*cos(3.5*pi*x)-1) # true probability function
eta_x <- eta_fun(xp)
yp <- rep(0,np)
for(i in 1:np) yp[i] <- rbinom(1,1, eta_x[i])

#####   data from computer experiment   #####
ns <- 20
xs <- matrix(runif(ns*2), ncol=2)  # the first column corresponds to the column of xp
p_xtheta <- function(x,theta) {
     # true probability function
     exp(exp(-0.5*x)*cos(3.5*pi*x)-1) - abs(theta-0.3) *exp(-0.5*x)*cos(3.5*pi*x)
}
ys <- rep(0,ns)
for(i in 1:ns) ys[i] <- rbinom(1,1, p_xtheta(xs[i,1],xs[i,2]))

#####    check the true parameter    #####
curve(eta_fun, lwd=2, lty=2, from=0, to=1)
curve(p_xtheta(x,0.3), add=TRUE, col=4)   # true value = 0.3: L2 dist = 0
curve(p_xtheta(x,0.9), add=TRUE, col=3)   # other value

##### calibration: true parameter is 0.3 #####

calibrate.result <- calibrateBinary(xp, yp, xs[,1], xs[,2], ys)
print(calibrate.result)

calibrateBinary documentation built on May 2, 2019, 4:20 a.m.