JeffreyRacine / R-Package-np

R package np (Nonparametric Kernel Smoothing Methods for Mixed Data Types)
https://socialsciences.mcmaster.ca/people/racinej
47 stars 18 forks source link

Rule of thumb for npregbw #16

Open rb792-EcoEvo opened 6 years ago

rb792-EcoEvo commented 6 years ago

Would it be possible to implement the plug-in method (rule of thumb), that is used in bandwidth estimation for densities, in the function "npregbw" as well?

JeffreyRacine commented 6 years ago

Greetings,

The normal-reference rule is included (bwmethod="normal-reference") but base R has a number of plug-in methods for univariate density estimation that can be called, e.g., bws=bw.nrd0(x) etc. See ?bw.nrd for details (and the np FAQ)...

Jeff

rb792-EcoEvo commented 6 years ago

Dear Jeff, I'm aware of the implementations for density estimation, but was wondering about regression estimation, for which I'm working with "npregbw" (which only accepts bwmethod = "cv.ls" and "cv.aic"). Or is there an obvious way to use the plug-in methods that are implemented for density estimation to estimate bandwidths for regressions? Many thanks, Robert

JeffreyRacine commented 6 years ago

Hi,

For regression there is the function dpill() in the KernSmooth package ("Use direct plug-in methodology to select the bandwidth of a local linear Gaussian kernel regression estimate, as described by Ruppert, Sheather and Wand (1995).")

Perhaps this will work? It is univariate only though...

Jeff

rb792-EcoEvo commented 6 years ago

Thanks, and sorry, I should have specified this at the start, I'm dealing with a multivariate problem, ~5 predictors of length ~20,000 each, which makes cross-validation a bit tricky...

JeffreyRacine commented 6 years ago

In that case, try a bounded support kernel function, turn on the tree option (see FAQ) and you can also run the snippet of code in the FAQ that indicates likely run-time...

Jeff