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.
Arguments
- formula
A model formula of the form
y ~ x1 + x2 + ...passed tonp::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
# \donttest{
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)
}
#> $method
#> [1] "np::npreg (default method via npregbw)"
#>
#> $raw
#> $raw$bws
#>
#> Regression Data (50 observations, 1 variable(s)):
#>
#> x
#> Bandwidth(s): 0.03113067
#>
#> Regression Type: Local-Constant
#> Bandwidth Selection Method: Least Squares Cross-Validation
#> Bandwidth Type: Fixed
#> Objective Function Value: 0.01307107 (achieved on multistart 1)
#> Number of Function Evaluations: 57
#> Evaluation cache (Powell): 19 hits / 44 lookups (43.2%)
#>
#> Continuous Kernel Type: Second-Order Gaussian
#> No. Continuous Explanatory Vars.: 1
#>
#>
#> $raw$fit
#>
#> Regression Data: 50 training points, in 1 variable(s)
#> x
#> Bandwidth(s): 0.03113067
#>
#> Kernel Regression Estimator: Local-Constant
#> Bandwidth Type: Fixed
#>
#> Continuous Kernel Type: Second-Order Gaussian
#> No. Continuous Explanatory Vars.: 1
#>
#>
#>
# }
