help rmse



rmse -- Caluclate raw or adjusted RMSE (Root MSE)


rmse variable variable [varlist] [, options]


rmse provides a fast and easy way to calculate raw or adjusted RMSE, useful for checking prediction accuracy.

rmse = [(sum of (y-yhat)^2)/(N - k - 1)]^.5 where k is the number of parameters, usually regression coefficients.

The results are stored in r-class locals.


+------+ ----+ Main +-------------------------------------------------------------

estimates Use the same sample and degrees of freedom (df) as the current regression results.

df_m(#) # is k in the formula above. Comparable to e(df_m)

raw Do not reduce the df by 1 [as in at the end of (N - k - 1)]


* reproduce a single RMSE from a regression sysuse auto, clear regress mpg price rep78 headroom turn predict yhat di e(rmse)

rmse mpg yhat, est

* reproduce from scratch sysuse auto, clear regress mpg price rep78 headroom predict yhat gen resid=yhat-mpg gen resid2=resid*resid sum resid2 if e(sample)==1 di e(rmse) di (r(mean)*e(N)/(e(N)-e(df_m)-1))^.5

rmse mpg yhat if e(sample)==1, df_m(3)

* multiple RMSE sysuse auto, clear rmse mpg price rep78 headroom ret list


The first variable is compared against the rest.


Roy Wada