predict.ordspline {bigsplines}R Documentation

Predicts for "ordspline" Objects

Description

Get fitted values and standard error estimates for ordinal smoothing splines.

Usage

## S3 method for class 'ordspline'
predict(object,newdata=NULL,se.fit=FALSE,...)

Arguments

object

Object of class "ordspline", which is output from ordspline.

newdata

Vector containing new data points for prediction. See Details and Example. Default of newdata=NULL uses original data in object input.

se.fit

Logical indicating whether the standard errors of the fitted values should be estimated. Default is se.fit=FALSE.

...

Ignored.

Details

Uses the coefficient and smoothing parameter estimates from a fit ordinal smoothing spline (estimated by ordspline) to predict for new data.

Value

If se.fit=FALSE, returns vector of fitted values.

Otherwise returns list with elements:

fit

Vector of fitted values

se.fit

Vector of standard errors of fitted values

Author(s)

Nathaniel E. Helwig <helwig@umn.edu>

References

Gu, C. (2013). Smoothing spline ANOVA models, 2nd edition. New York: Springer.

Helwig, N. E. (2013). Fast and stable smoothing spline analysis of variance models for large samples with applications to electroencephalography data analysis. Unpublished doctoral dissertation. University of Illinois at Urbana-Champaign.

Helwig, N. E. (2017). Regression with ordered predictors via ordinal smoothing splines. Frontiers in Applied Mathematics and Statistics, 3(15), 1-13.

Helwig, N. E. and Ma, P. (2015). Fast and stable multiple smoothing parameter selection in smoothing spline analysis of variance models with large samples. Journal of Computational and Graphical Statistics, 24, 715-732.

Examples


##########   EXAMPLE   ##########

# define univariate function and data
set.seed(773)
myfun <- function(x){ 2 + x/2 + sin(x) }
x <- sample(1:20, size=500, replace=TRUE)
y <- myfun(x) + rnorm(500)

# fit ordinal spline model
ordmod <- ordspline(x, y)
monmod <- ordspline(x, y, monotone=TRUE)
crossprod( predict(ordmod) - myfun(x) ) / 500
crossprod( predict(monmod) - myfun(x) ) / 500

# plot truth and predictions
ordfit <- predict(ordmod, 1:20, se.fit=TRUE)
monfit <- predict(monmod, 1:20, se.fit=TRUE)
plotci(1:20, ordfit$fit, ordfit$se.fit, ylab="f(x)")
plotci(1:20, monfit$fit, monfit$se.fit, col="red", col.ci="pink", add=TRUE)
points(1:20, myfun(1:20))


[Package bigsplines version 1.1-1 Index]