% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/adaptive_chaos.R
\name{adaptive_khaos_ridge}
\alias{adaptive_khaos_ridge}
\title{Bayesian Adaptive Polynomial Chaos Expansion (Ridge Prior)}
\usage{
adaptive_khaos_ridge(
  X,
  y,
  degree = 15,
  order = 5,
  nmcmc = 10000,
  nburn = 9000,
  thin = 1,
  max_basis = 1000,
  tau2 = 10^5,
  s2_lower = 0,
  g1 = 0,
  g2 = 0,
  h1 = 4,
  h2 = 40/length(y),
  move_probs = rep(1/3, 3),
  coin_pars = list(function(j) 1/j, 1, 2, 3),
  degree_penalty = 0,
  legacy = TRUE,
  verbose = TRUE
)
}
\arguments{
\item{X}{A data frame or matrix of predictors scaled to be between 0 and 1}

\item{y}{a response vector}

\item{degree}{Maximum polynomial degree for each basis function.}

\item{order}{Maximum order of interaction for each basis function.}

\item{nmcmc}{Number of MCMC iterations.}

\item{nburn}{Number of initial MCMC iterations to discard.}

\item{thin}{Keep every \code{thin} samples.}

\item{max_basis}{Maximum number of basis functions.}

\item{tau2}{Prior variance for coefficients}

\item{s2_lower}{Lower bound on process variance (numerically useful for deterministic functions).}

\item{g1, g2}{Shape/rate parameters for the IG prior on process variance (default is Jefffrey's prior)}

\item{h1, h2}{Shape/rate parameters for the Gamma prior on expected number of basis functions.}

\item{move_probs}{A 3-vector with probabilities for (i) birth, (ii) death, and (iii) mutation.}

\item{coin_pars}{A list of control parameters for coinflip proposal}

\item{degree_penalty}{Increasing this value encourages lower order polynomial terms (0 is no penalization).}

\item{legacy}{Logical. If TRUE, mimics original implementation behavior (from the emulator comparison paper),
which may retain invalid basis function structures across iterations. Defaults to FALSE.}

\item{verbose}{Logical. Should progress information be printed?}
}
\value{
An object of class \code{"adaptive_khaos"}.
The object is a list containing:
\describe{
\item{B}{Matrix of basis functions evaluated at the training inputs.}
\item{vars, degs}{Arrays encoding the variables and polynomial degrees for each basis function across MCMC iterations.}
\item{nint, dtot}{Interaction order and total degree for each basis function.}
\item{nbasis}{Number of basis functions per MCMC iteration.}
\item{beta}{Posterior samples of regression coefficients.}
\item{s2}{Posterior samples of the noise variance.}
\item{lam}{Posterior samples of the Poisson rate parameter controlling model size.}
\item{sum_sq}{Residual sum of squares at each iteration.}
\item{eta}{Variable inclusion counts used in the proposal distribution.}
\item{count_accept, count_propose}{Acceptance and proposal counts for RJMCMC moves.}
\item{prior_type}{Character string indicating the ridge prior.}
\item{X, y}{Training data.}
}
}
\description{
Adaptive Bayesian polynomial chaos expansion using a fixed Gaussian (ridge)
prior on coefficients. This implementation corresponds to a simplified
version of the adaptive Bayesian PCE methodology described in Rumsey et al. (2026)
}
\details{
Implements the RJMCMC algorithm described by Francom & Sanso (2020) for BMARS, modifying it for polynomial chaos basis functions.
As an alternative the NKD procedure of Nott et al. (2005), we use a coinflipping procedure to identify useful variables. See writeup (coming soon) for details.
The coin_pars argument is an ordered list with elements:
\enumerate{
\item{a function giving proposal probability for q_0, the expected order of interaction,}
\item{epsilon, the base weight for each variable (epsilon=Inf corresponds to uniform sampling),}
\item{alpha, the exponent-learning rate,}
\item{num_passes a numerical parameter only.}
}

Other proposal notes:
Expected order q0 is chosen from 1:order with weights \code{coin_pars[[1]](1:order)}
Degree is chosen from q0:degree with weights \code{(1:(degree-q0+1))^(-degree_penalty)} and a random partition is created (see helper function).

Two types of change steps are possible (and equally likely)
A re-ordering of the degrees
A single variable is swapped out with another one
}
\examples{
\donttest{
X <- lhs::maximinLHS(100, 2)
f <- function(x) 10.391*((x[1]-0.4)*(x[2]-0.6) + 0.36)
y <- apply(X, 1, f) + stats::rnorm(100, 0, 0.1)
fit <- adaptive_khaos(X, y)
}
}
\references{
Francom, Devin, and Bruno Sanso. "BASS: An R package for fitting and performing sensitivity analysis of Bayesian adaptive spline surfaces." Journal of Statistical Software 94.LA-UR-20-23587 (2020).

Nott, David J., Anthony YC Kuk, and Hiep Duc. "Efficient sampling schemes for Bayesian MARS models with many predictors." Statistics and Computing 15 (2005): 93-101.

Rumsey, K.N., Francom, D., Gibson, G., Derek Tucker, J. and Huerta, G., 2026. Bayesian Adaptive Polynomial Chaos Expansions. Stat, 15(1), p.e70151.
}
