Learn R Programming

lgspline (version 0.2.0)

leave_one_out: Compute Leave-One-Out Cross-Validated predictions for Gaussian Response/Identity Link under Constraint.

Description

Computes the leave-one-out cross-validated predictions from a model fit, assuming Gaussian-distributed response with identity link.

Usage

leave_one_out(model_fit)

Value

A vector of leave-one-out cross-validated predictions

Arguments

model_fit

A fitted Lagrangian smoothing spline model

Examples

Run this code

## Basic usage with Gaussian response, computing PRESS
set.seed(1234)
t <- rnorm(50)
y <- sin(t) + rnorm(50, 0, .25)
fit <- lgspline(t, y)
loo <- leave_one_out(fit)
press <- mean((y-loo)^2)

plot(loo, y,
   main = "Leave-One-Out Cross-Validation Prediction vs. Observed Response",
   xlab = 'Prediction', ylab = 'Response')
abline(0, 1)

Run the code above in your browser using DataLab