calibrateBinary {calibrateBinary}  R Documentation 
The function performs the L2 calibration method for binary outputs.
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)
Xp 
a design matrix with dimension 
yp 
a response vector with length 
Xs1 
a design matrix with dimension 
Xs2 
a design matrix with dimension 
ys 
a response vector with length 
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 
kernel 
input for fitting kernel logistic regression. See 
nu 
input for fitting kernel logistic regression. See 
power 
input for fitting kernel logistic regression. See 
rho 

sigma 
a vector specifying values of the tuning parameter 
lower 
a vector of size 
upper 
a vector of size 
verbose 
logical. If 
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{\theta}=\arg\min_{\theta}\\hat{\eta}(\cdot)\hat{p}(\cdot,\theta)\_{L_2(\Omega)},
where \hat{\eta}(x)
is the fitted probability function for physical data, and \hat{p}(x,\theta)
is the fitted probability function for computer data. In this L2 calibration framework, \hat{\eta}(x)
is fitted by the kernel logistic regression using the input Xp
and the output yp
. The tuning parameter \lambda
for the kernel logistic regression can be chosen by kfold crossvalidation, 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,\theta)
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_{\sigma}(\mathbf{x}_i,\mathbf{x}_j)=\exp\{\sum^{d}_{l=1}\sigma(x_{il}x_{jl})^2 \},
is used here. The vector sigma
is the choices of the tuning parameter \sigma
, and it will be chosen by kfold crossvalidation. 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 \theta
. If they are not given, the default is the range of each column of rbind(Xp,Xs1)
, and Xs2
.
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.
ChihLi Sung <iamdfchile@gmail.com>
KLR
for performing a kernel logistic regression with given lambda
and rho
. cv.KLR
for performing crossvalidation to estimate the tuning parameters.
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(theta0.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)