How to obtain RMSE out of lm result?

后端 未结 4 1255
孤街浪徒
孤街浪徒 2021-02-01 22:06

I know there is a small difference between $sigma and the concept of root mean squared error. So, i am wondering what is the easiest way to obtain

4条回答
  •  无人及你
    2021-02-01 22:36

    I think the other answers might be incorrect. The MSE of regression is the SSE divided by (n - k - 1), where n is the number of data points and k is the number of model parameters.

    Simply taking the mean of the residuals squared (as other answers have suggested) is the equivalent of dividing by n instead of (n - k - 1).

    I would calculate RMSE by sqrt(sum(res$residuals^2) / res$df).

    The quantity in the denominator res$df gives you the degrees of freedom, which is the same as (n - k - 1). Take a look at this for reference: https://www3.nd.edu/~rwilliam/stats2/l02.pdf

提交回复
热议问题