Last time we fitted a set of data using the cubic function.
Let’s analyse the quality of the fit using the predicted R-squared method. It is also called Leave-Out-One Cross Validation (LOOCV). What it does is that it systematically leaves out one data at a time and estimates how the model performs under those circumstances. For a good fit, the predicted R-squared should be high (as close to 1).
We will estimate the predicted R-squared of the dataset using the library, “olsrr“.
library(olsrr)
model <- lm(Presi_Data$Historians.rank ~ Presi_Data$Approval.High + I(Presi_Data$Approval.High^2) + I(Presi_Data$Approval.High^3))
ols_pred_rsq(model)
The answer is -0.2, which suggests that the cubic function is overfitting the observation.