This function provides tunes the expected number of crossings. See vignette for detail.

tuneEcross(ecross_candidates = seq(0.25, 5, by = 0.25), y, tgt,
          x, nburn = 1000, nsim = 1000, ntree = 200, lambda = NULL,
          sigq = 0.9, sighat = NULL, nu = 3, base_tree = 0.95,
          power_tree = 2, probit = FALSE, yobs = NULL,
          monotone = "no", binsize = NULL)

Arguments

ecross_candidates

A vector of candidate values for expected number of crossings. Required, defaults to seq(.25,5,by=.25).

y

Length n vector with continuous response values. In probit case, should contain initializations for latent variables.

tgt

Length n targeted covariate over which to smooth.

x

A (n x p) data frame or matrix containing the covariates which are not to be smoothed over.

nburn

Number of burn-in MCMC iterations.

nsim

Number of MCMC iterations to save after burn-in.

ntree

Number of trees. Defaults to 200.

lambda

Scale parameter in the chisq prior sigma^2. Defaults to NULL, ie being estimated from sigq and sighat. Not appicable for binary case.

sigq

Calibration quantile in the chisq prior on sigma^2. Defaults to .9. Not applicable for binary case.

sighat

Calibration estimate for chisq prior on sigma^2. Defaults to being estimated from data using linear model. Not applicable for binary case.

nu

Degrees of freedom in the chisq prior on sigma^2. Defaults to 3. Not applicable for binary case.

base_tree

Base for tree prior. Defaults to 0.95.

power_tree

Power for tree prior. Defaults to 2.0.

probit

F indicates continuous response; T indicates probit response. Default is F. If T, then yobs must be populated.

yobs

Length n vector of binary responses; only populated for probit=T case.

monotone

For Projective Smooth BART. Specifies type of monotonicity constraint on f(x,t) estimates. If "no", no monotonicity constraint. If "incr" or "decr", f(x,t) is monotone increasing or decreasing. Default is "no".

binsize

Specifies a value $c$ where (y_i mod c == 0) indicates that y_i may have been rounded to this bin size. Defaults to NULL.

Value

A list object, containing the following items:

ecross_opt

A double; the optimal expected crossings value from the user input grid.

waic_plot

A ggplot object containing diagnostics for tuning expected crossings.

waic_grid

A data frame containing the expected crossing candidates and corresponding WAIC values.

Examples

if (FALSE) { ## Evaluate optimal number of crossings. ecrossTune = tuneEcross(ecross_candidates = seq(.25,5,by=.25), y, tgt, x, nburn, nsim, ntree=200, lambda=NULL, sigq=.9, sighat=NULL, nu=3, base_tree=.95, power_tree=2, probit=FALSE, yobs=NULL, monotone="no", binsize=NULL) ## View expected number of crossings. ecrossTune[["ecross_opt"]] }