confidenceBands: Confidence Bands for Wasserstein Regression

View source: R/confidenceBands.R

confidenceBandsR Documentation

Confidence Bands for Wasserstein Regression

Description

Confidence Bands for Wasserstein Regression

Usage

confidenceBands(
  wass_regress_res,
  Xpred_df,
  level = 0.95,
  delta = 0.01,
  type = "density",
  figure = TRUE,
  fig_num = NULL
)

Arguments

wass_regress_res

an object returned by the wass_regress function

Xpred_df

k-by-p matrix (or dataframe, or named vector) used for prediction. Note that Xpred_df should have the same column names with Xfit_df used in wass_regress_res

level

confidence level

delta

boundary control value in density band computation. Must be a value in the interval (0, 1/2) (default: 0.01)

type

'density', 'quantile' or 'both'

  • 'density': density function bands will be returned (and plotted if figure = TRUE)

  • 'quantile': quantile function and CDF bands will be returned (and plotted if figure = TRUE)

  • 'both': three kinds of bands, density function, quantile function and CDF bands will be returned (and plotted if figure = TRUE)

figure

logical; if TRUE, return a sampled plot (default: TRUE)

fig_num

the fig_num-th row of Xpred_df will be used for visualization of confidence bands. If NULL, then fig_num is randomly chosen (default: NULL)

Details

This function computes intrinsic confidence bands for Xpred_df if type = 'quantile' and density bands if type = 'density', and visualizes the confidence and/or density bands when figure = TRUE.

Value

a list containing the following lists:

den_list:
  • fpred: k-by-m matrix, predicted density function at Xpred_df.

  • f_ux: k-by-m matrix, upper bound of confidence bands of density functions.

  • f_lx: k-by-m matrix, lower bound of confidence bands of density functions.

  • Qpred: k-by-m matrix, f_lx[i, ], f_ux[i, ] and fpred[i, ] evaluated on Qpred[i, ] vector.

quan_list:
  • Qpred: k-by-m matrix of predicted quantile functions.

  • Q_ux: k-by-m matrix of upper bound of quantile functions.

  • Q_lx: k-by-m matrix of lower bound of quantile functions.

  • t_vec: a length m vector - common grid for all quantile functions.

cdf_list:
  • fpred: k-by-m matrix, predicted density function.

  • Fpred: k-by-m matrix, predicted cumulative distribution functions.

  • F_ux: k-by-m matrix, upper bound of cumulative distribution functions.

  • F_lx: k-by-m matrix, lower bound of cumulative distribution functions.

  • Fsup: k-by-m matrix, fpred[i, ], F_lx[i, ], F_ux[i, ] and Fpred[i, ] evaluated on Fsup[i, ] vector.

Examples

alpha = 2
beta = 1
n = 50
x1 = runif(n)
t_vec = unique(c(seq(0, 0.05, 0.001), seq(0.05, 0.95, 0.05), seq(0.95, 1, 0.001)))
set.seed(1)
quan_obs = simulate_quantile_curves(x1, alpha, beta, t_vec)
Xfit_df = data.frame(x1 = x1)
res = wass_regress(rightside_formula = ~., Xfit_df = Xfit_df,
                   Ytype = 'quantile', Ymat = quan_obs, Sup = t_vec)
confidence_Band = confidenceBands(res, Xpred_df = data.frame(x1 = c(-0.5,0.5)),
type = 'both', fig_num = 2)

data(strokeCTdensity)
predictor = strokeCTdensity$predictors
dSup = strokeCTdensity$densitySupport
densityCurves = strokeCTdensity$densityCurve
xpred = predictor[2:3, ]

res = wass_regress(rightside_formula = ~., Xfit_df = predictor,
Ytype = 'density', Ymat = densityCurves, Sup = dSup)
confidence_Band = confidenceBands(res, Xpred_df = xpred, type = 'density', fig_num = 1)


WRI documentation built on July 9, 2022, 1:06 a.m.