concept square error in category R

appears as: square error, square errors, squared error, squared error
Practical Data Science with R, Second Edition

This is an excerpt from Manning's book Practical Data Science with R, Second Edition.

Listing 7.5. Calculating root mean square error
rmse <- function(y, f) { sqrt(mean( (y-f)^2 )) }

rmse(log10(dtrain$PINCP), dtrain$predLogPINCP)      #1
 ## [1] 0.2685855

rmse(log10(dtest$PINCP), dtest$predLogPINCP)        #2
 ## [1] 0.2675129

The resulting model’s predictions are plotted versus true response in figure 10.15. This fit is much better: the model explains over 80% of the variance (R-squared of 0.83), and the root mean squared error (RMSE) over the training data is less than half the RMSE of the linear model. Note that the points in figure 10.15 are distributed more or less evenly around the line of perfect prediction. The GAM has been fit to be homoscedastic, and any given prediction is as likely to be an overprediction as an underprediction.