% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/MeanimileLinearRegression.R
\name{MeanimileLinearRegression}
\alias{MeanimileLinearRegression}
\title{Estimate linear conditional meanimile}
\usage{
MeanimileLinearRegression(
  X,
  Y,
  d_tau,
  tau,
  h_x,
  h_y,
  loss_type = c("square", "general"),
  lossDerivative = NULL,
  delta = NULL
)
}
\arguments{
\item{X}{A numeric matrix of covariates (n x d).}

\item{Y}{A numeric vector of the response variable.}

\item{d_tau}{A function representing the density function of the
distributional weight function D_tau.}

\item{tau}{A numeric risk level/index. Argument of d_tau function.}

\item{h_x}{A numeric vector of bandwidths for the covariates X.}

\item{h_y}{A numeric scalar bandwidth for the response variable Y.}

\item{loss_type}{A character string specifying the loss formulation. Must be either \code{"square"} (default) or \code{"general"}.}

\item{lossDerivative}{A function defining the derivative of the loss function. Required only if \code{loss_type = "general"}.}

\item{delta}{Optional numeric parameter for the loss function. Used only if \code{loss_type = "general"}.}
}
\value{
A numeric vector of estimated regression coefficients (including the intercept).
}
\description{
Estimates the parameters of a linear conditional meanimile model using a two-fold
sample splitting procedure to mitigate bias from the conditional CDF estimation.
This function acts as a unified wrapper, allowing the user to seamlessly switch
between the square loss formulation and the general loss formulation.
}
\examples{
set.seed(123)
n <- 400
X <- matrix(rnorm(n * 2), ncol = 2)
Y <- 0.9 * X[, 1] + 0.5 * X[, 2] + rnorm(n)
d_tau_minvar <- function(u, tau) {
  (tau + 1) * u^tau
}
lossDerivativeExpectiles <- function(x, c, delta) {
  -2 * ifelse(x > c, delta, 1 - delta) * (x - c)
}

# 1. Square Loss
MeanimileLinearRegression(X, Y,
  d_tau = d_tau_minvar, tau = 2,
  h_x = c(0.4, 0.4), h_y = 0.4, loss_type = "square"
)

# 2. General Loss
MeanimileLinearRegression(X, Y,
  d_tau = d_tau_minvar, tau = 2,
  h_x = c(0.4, 0.4), h_y = 0.4, loss_type = "general",
  lossDerivative = lossDerivativeExpectiles, delta = 0.9
)
}
