Skip to contents

Thin extender over np::npregbw + np::npreg for kernel-smoothed nonparametric regression with data-driven bandwidth selection (Hayfield & Racine, 2008). Runs the bandwidth-selection routine first and then fits the regression using the chosen bandwidths.

Usage

morie_np_kernel_reg(formula, data, ...)

Arguments

formula

A model formula of the form y ~ x1 + x2 + ... passed to np::npregbw.

data

A data frame containing the variables in formula.

...

Further arguments forwarded to np::npregbw (e.g. bwmethod, bwtype, ckertype, regtype, tol, ftol).

Value

A list with $method = "np::npreg (bws via npregbw)" and $raw, where $raw is itself a list with $bws (the rbandwidth object from np::npregbw) and $fit (the npregression object from np::npreg).

Examples

if (FALSE) { # \dontrun{
  if (requireNamespace("np", quietly = TRUE)) {
    set.seed(1)
    n  <- 50
    df <- data.frame(x = stats::runif(n, -1, 1))
    df$y <- sin(pi * df$x) + stats::rnorm(n, sd = 0.1)
    morie_np_kernel_reg(y ~ x, data = df)
  }
} # }