points.unireg: Points method for 'unireg' objects.

Description Usage Arguments Details Author(s) See Also Examples

View source: R/points.unireg.R

Description

Plotting a unimodal regression object into an existing plot.

Usage

1
2
## S3 method for class 'unireg'
points(x, type="l", ...)

Arguments

x

Object of class "unireg", a result of unireg.

type

Per default plotting type "l" is used for the fitted spline.

...

other parameters to be passed through to the generic points functions.

Details

This is a points method for unimodal regression objects. The spline function is plotted using a grid of x-values equally spaced across the interval on which the spline is defined. The distance between the grid values is given by the minimal distance of the observed x-values (used for fitting) divided by 10.

Author(s)

Claudia Koellmann

See Also

unireg,predict.unireg,plot.unireg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
x <- sort(rep(0:5,20))         
n <- length(x)               
set.seed(41333)
func <- function(mu){rnorm(1,mu,0.05)}
y <- sapply(dchisq(x,3),func)

# plot of data
plot(jitter(x), y, xlab="x (jittered)")

# fit with default settings
fit <- unireg(x, y, g=5)
# short overview of the fitted spline
fit

# plot of true and fitted functions
plot(jitter(x), y, xlab="x (jittered)")
curve(dchisq(x,3), 0, 5, type="l", col="grey", lwd=2, add=TRUE)
points(fit, lwd=2, col="orange")
legend("bottomright", legend = c("true mean function", 
        "difference penalized unimodal fit"),
    col=c("grey","orange"),lwd=c(2,2))

uniReg documentation built on May 29, 2017, 8:30 p.m.