\name{qqkrls}
\alias{qqkrls}
\title{Quantile-on-Quantile Kernel Regularized Least Squares}
\usage{
qqkrls(y, x,
       y_quantiles = seq(0.05, 0.95, by = 0.05),
       x_quantiles = seq(0.05, 0.95, by = 0.05),
       subset_col = 1, deriv_index = 1,
       sigma = NULL, lambda = NULL,
       min_obs = 15, n_boot = 200,
       verbose = TRUE, seed = 42)
}
\arguments{
\item{y}{Numeric response.}
\item{x}{Numeric vector or matrix.}
\item{y_quantiles}{Quantiles of y (tau) in (0, 1).}
\item{x_quantiles}{Quantiles of x (theta) in (0, 1).}
\item{subset_col}{Column of x used to subset by quantile.}
\item{deriv_index}{Column of x summarised across pointwise marginal effects.}
\item{sigma}{KRLS Gaussian bandwidth or NULL.}
\item{lambda}{KRLS regularisation parameter or NULL.}
\item{min_obs}{Minimum observations in a subset.}
\item{n_boot}{Bootstrap replicates.}
\item{verbose}{Print progress.}
\item{seed}{RNG seed.}
}
\value{An object of class \code{"qqkrls"}.}
\description{Implements QQKRLS (Adebayo et al., 2024). For each
x-quantile theta, fit KRLS of y on x on the sub-sample where
x <= Q_x(theta), then take the tau-quantile of the pointwise marginal
effects as the coefficient beta(theta, tau).}
\references{
Adebayo, T.S., Ozkan, O., Eweade, B.S. (2024). Do energy efficiency
R&D investments and ICT promote environmental sustainability in
Sweden? A QQKRLS investigation. \emph{Journal of Cleaner Production},
440, 140832. \doi{10.1016/j.jclepro.2024.140832}

Hainmueller, J., Hazlett, C. (2014). Kernel Regularized Least Squares.
\emph{Political Analysis}, 22(2), 143-168. \doi{10.1093/pan/mpt019}

Sim, N., Zhou, H. (2015). Oil Prices, US Stock Return, and the
Dependence Between Their Quantiles. \emph{Journal of Banking and
Finance}, 55, 1-12. \doi{10.1016/j.jbankfin.2015.01.013}
}
\examples{
## Small toy example -- auto-tested by R CMD check, runs in well under 5 s.
set.seed(1); n <- 30
x <- rnorm(n); y <- 0.5 * x + rnorm(n, sd = 0.3)
fit <- qqkrls(y, x,
              y_quantiles = c(0.25, 0.5),
              x_quantiles = c(0.5, 0.75),
              n_boot = 5, verbose = FALSE)
print(fit)
head(fit$results)

\donttest{
## Realistic example with the default 19 x 19 quantile grid and 200
## bootstrap replicates (slow; for interactive use).
set.seed(1); n <- 150
xb <- rnorm(n); yb <- 0.5 * sin(xb) + rnorm(n, sd = 0.3)
fit_full <- qqkrls(yb, xb, n_boot = 100, verbose = FALSE)
print(fit_full)
}
}
