npfit-plot: Plotting functions for npfit objects

Description Usage Arguments Examples

Description

Plotting methods for fitted nonparametric regression objects. The plot command creates a new plot, with the observed data as points and the fitted nonparametric estimator as a line. The lines command adds the nonparametric estimate to an existing plot, as a line.

Usage

1
2
3
4
5
## S3 method for class 'npfit'
plot(x, ...)

## S3 method for class 'npfit'
lines(x, ...)

Arguments

x

an npfit object, the result of running nw or local_average

...

additional arguments to be passed to the plotting function, e.g. xlim, col, lty etc.

Examples

1
2
3
4
5
6
 m <- function(x) (x^2+1)*sin(2*pi*x*((1-x) + 4*x))
 x <- sort(runif(100))
 y <- m(x) + rnorm(length(x), sd=0.1)
 simdata <- data.frame(x=x,y=y)
 plot(local_average(simdata,h=0.02))
 lines(local_average(simdata,h=0.04), col=4)

timwaite/nprtw documentation built on Jan. 25, 2021, 1:50 a.m.