The documentation at https://pkg.robjhyndman.com/forecast/reference/CV.html says that the function "Computes the leave-one-out cross-validation statistic (also known as PRESS -- prediction residual sum of squares)...", but the code calculates the mean rather than the sum.
The CV() function defines the cv value as:
cv <- mean((residuals(obj) / (1 - hatvalues(obj))) ^ 2, na.rm = TRUE)
Where (residuals(obj) / (1 - hatvalues(obj))) ^ 2 is a vector of the squared LOOCV residuals.
Should the documentation say "mean of PRESS" or should the code be sum(..., na.rm=TRUE) instead of mean(..., na.rm=TRUE)?
The documentation at https://pkg.robjhyndman.com/forecast/reference/CV.html says that the function "Computes the leave-one-out cross-validation statistic (also known as PRESS -- prediction residual sum of squares)...", but the code calculates the mean rather than the sum.
The
CV()
function defines the cv value as:cv <- mean((residuals(obj) / (1 - hatvalues(obj))) ^ 2, na.rm = TRUE)
Where
(residuals(obj) / (1 - hatvalues(obj))) ^ 2
is a vector of the squared LOOCV residuals.Should the documentation say "mean of PRESS" or should the code be
sum(..., na.rm=TRUE)
instead ofmean(..., na.rm=TRUE)
?