A Reference Class for Local Polynomial Regression with covafill.

`ptr`

External pointer to the covafill C++ object

`getBandwith()`

Get the bandwith.

`getDegree()`

Get the polynomial degree.

`getDim()`

Get the dimension of the coordinates.

`initialize(coord, obs, h = suggestBandwith(coord, p), p = 3L, ...)`

Method to initialize the covafill. coord is a matrix of coordinates, obs is a vector of corresponding observations, h is a vector of bandwiths, and p is the polynomial degree.

`predict(coord, se.fit = FALSE)`

Predict function value and derivatives with local polynomial regression at coord. If se.fit=TRUE a list is returned with estimates and their standard deviations.

`residuals(excludeRadius)`

Get 'leave-neighborhood-out' residuals, i.e. local polynomial regression predictions excluding points within excludeRadius subtracted from the observation.

`setBandwith(h)`

Set the bandwith to h.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ```
getRefClass('covafill')
fn <- function(x) x ^ 4 - x ^ 2
x <- runif(2000,-3,3)
y <- fn(x) + rnorm(2000,0,0.1)
cf <- covafill(coord = x,obs = y,p = 5L)
cf$getDim()
cf$getDegree()
cf$getBandwith()
x0 <- seq(-1,1,0.1)
y0 <- cf$predict(x0)
par(mfrow=c(3,1))
plot(x0,y0[,1], main = "Function")
lines(x0,fn(x0))
plot(x0, y0[,2], main = "First derivative")
lines(x0, 4 * x0 ^ 3 - 2 * x0)
plot(x0, y0[,3], main = "Second derivative")
lines(x0, 3 * 4 * x0 ^ 2 - 2)
cf$setBandwith(1.0)
cf$getBandwith()
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.