predict.unireg: Predict method for 'unireg' objects.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/predict.unireg.R

Description

Predicted values based on a unimodal regression object.

Usage

1
2
## S3 method for class 'unireg'
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).

Details

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

Value

Returns a numeric vector of predicted function values.

Author(s)

Claudia Koellmann

See Also

unireg,plot.unireg,points.unireg

Examples

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

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 
[1] 0.22276705 0.18015210 0.12398603 0.08550933

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