Learn R Programming

uniReg (version 1.1)

predict.unireg: Predict method for unireg objects.

Description

Predicted values based on a unimodal regression object.

Usage

"predict"(object, newdata, ...)

Arguments

object
Object of class 'unireg', a result of unireg.
newdata
A numeric vector of values at which to evaluate the fitted spline function.
...
Further arguments (currently not used).

Value

Details

predict.unireg produces predicted values by evaluating the fitted regression spline function at the values in newdata.

See Also

unireg,plot.unireg,points.unireg

Examples

Run this code
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

# prediction at interim values
predict(fit, c(1.5,2.5,3.5,4.5))

Run the code above in your browser using DataLab