plot.unireg: Plot method for 'unireg' objects.

Description Usage Arguments Details Author(s) See Also Examples

View source: R/plot.unireg.R

Description

Plotting a unimodal regression object.

Usage

1
2
## S3 method for class 'unireg'
plot(x, onlySpline=FALSE, type="l", xlab="x", ylab=NULL, col="black", ...)

Arguments

x

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

onlySpline

Logical indicating whether only the fitted spline or also the original data points should be plotted. Defaults to FALSE (plotting both).

type

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

xlab

Per default the x-axis is labelled with "x".

ylab

If the user does not specify a label for the y-axis, that is when ylab=NULL(default), prespecified labels like "Fitted unimodal spline function" (depending on the constraint) are used.

col

Colour of the spline function to be plotted (default: black).

...

other parameters to be passed through to the generic plot function.

Details

This is a plot 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,points.unireg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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)

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

# plot of fitted spline with and without data
plot(fit, col="orange")
plot(fit, onlySpline=TRUE)

Example output

Fitted unimodal spline of degree 3 with difference penalty of order 2 

Coefficients          -0.21 0.03 0.23 0.23 0.18 0.13 0.09 0.07 0.05 
Mode of coefficients  3 4 
Tuning parameter      20.09 
Variance estimate     0 

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