loocv {switchSelection} | R Documentation |
Leave-one-out cross-validation
Description
This function calculates root mean squared error (RMSE) for leave-one-out cross-validation of linear regression estimated via least squares method.
Usage
loocv(fit)
Arguments
fit |
object of class |
Details
Fast analytical formula is used.
Value
This function returns a numeric value representing root mean squared error (RMSE) of leave-one-out cross-validation (LOOCV).
Examples
set.seed(123)
# Generate data according to linear regression
n <- 100
eps <- rnorm(n)
x <- runif(n)
y <- x + eps
# Estimate the model
model <- lm(y ~ x)
# Perform cross-validation
loocv(model)
[Package switchSelection version 1.1.2 Index]