% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/nwbass.R
\name{nwbass}
\alias{nwbass}
\alias{nwbass2}
\title{Generalized Bayesian MARS with a Normal-Wald likelihood}
\usage{
nwbass(
  X,
  y,
  w_prior = list(type = "GIG", p = -0.1, a = 0, b = 0.1),
  maxInt = 3,
  maxBasis = 1000,
  npart = NULL,
  nmcmc = 10000,
  nburn = 9000,
  thin = 1,
  moveProbs = rep(1/3, 3),
  a_tau = 1/2,
  b_tau = NULL,
  a_lambda = 1,
  b_lambda = 1,
  m_beta = 0,
  s_beta = 0,
  lag_beta = 1001,
  m_gamma = 1,
  s_gamma = 0,
  scale = 1,
  Iw0 = rep(1, maxInt),
  Zw0 = rep(1, ncol(X)),
  verbose = TRUE
)

nwbass2(...)
}
\arguments{
\item{X}{An \eqn{N \times p} numeric matrix of predictor variables. A numeric
vector is treated as a single-column matrix.}

\item{y}{A numeric response vector of length \eqn{N}.}

\item{w_prior}{A named list specifying the prior for the global variance
component. See Details.}

\item{maxInt}{Integer giving the maximum degree of interaction in spline basis
functions. Defaults to \code{3}.}

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

\item{npart}{Minimum number of nonzero points required for a proposed basis
function. Defaults to \code{min(20, 0.1 * N)}.}

\item{nmcmc}{Total number of MCMC iterations.}

\item{nburn}{Number of initial MCMC iterations discarded as burn-in.}

\item{thin}{Thinning interval for retained draws.}

\item{moveProbs}{A length-3 vector giving probabilities for birth, death, and
mutation moves.}

\item{a_tau}{Prior hyperparameter for \code{tau}.}

\item{b_tau}{Prior hyperparameter for \code{tau}. Defaults to \code{N / 2}.}

\item{a_lambda}{Prior hyperparameter for \code{lambda}.}

\item{b_lambda}{Prior hyperparameter for \code{lambda}.}

\item{m_beta}{Prior mean for \code{beta}.}

\item{s_beta}{Prior standard deviation for \code{beta}.}

\item{lag_beta}{Number of initial iterations for which \code{beta} is fixed at
\code{m_beta}. This is often used to stabilize early sampling.}

\item{m_gamma}{Prior mean for \code{gamma}.}

\item{s_gamma}{Prior standard deviation for \code{gamma}.}

\item{scale}{Fixed variance-scale parameter. Defaults to \code{1}.}

\item{Iw0}{Vector of positive nominal weights for interaction order in proposed
basis functions. Must have length \code{maxInt}.}

\item{Zw0}{Vector of positive nominal weights for variable selection in proposed
basis functions. Must have length \code{ncol(X)}.}

\item{verbose}{Logical; should progress be printed?}

\item{...}{(for backwards compatability)}
}
\value{
An object of class \code{c("nwbass", "gbass")} containing posterior draws and
fitted model information.
}
\description{
Fits a generalized BMARS model under a Normal-Wald likelihood. This provides
flexible nonlinear regression with a unimodal, potentially skewed error model.
}
\details{
The latent local-scale prior is fixed internally to the Normal-Wald form
\eqn{v_i \sim \mathrm{GIG}(-1/2, \gamma^2, 1)}. Unlike \code{gbass()},
\code{nwbass()} does not expose a user-specified \code{v_prior}.

The \code{w_prior} list should contain:
\enumerate{
\item \code{type}: either \code{"GIG"} or \code{"GBP"}.
\item \code{p}, \code{a}, \code{b}: hyperparameters for the prior.
\item \code{lower_bound}: optional lower bound for \code{w}. For backward
compatibility, \code{lb} is also accepted.
\item \code{prop_sigma}: proposal standard deviation on the log scale for
Metropolis updates of \code{w}. This is only used when \code{w} is updated
by Metropolis-Hastings, such as the \code{"GBP"} case.
\item \code{adapt}, \code{adapt_delay}, \code{adapt_thin}: optional controls
for adaptive Metropolis updates of \code{w} when applicable.
}

Retained draws are taken at iterations
\code{nburn + 1, nburn + 1 + thin, ...}. Thus \code{nburn} is interpreted as
the number of initial iterations discarded as burn-in.
}
\examples{
\donttest{
n <- 200
X <- lhs::maximinLHS(n, 2)
f <- 20 * apply(X, 1, function(x) sin(pi * x[1]) + x[2]^2)
eps <- rgamma(n, 3, 1.5) - 2
y <- f + eps

mod <- nwbass(X, y,
              m_beta=0, s_beta=10,
              m_gamma = nw_gamma_prior()[1], s_gamma = nw_gamma_prior()[2])
}
}
