How to calculate sum of squared errors (SSE or SSR) with Stata 12 software? I have a techincal issue with Stata: I need to calculate the SSE of a regression model, but the automatic output just gives me RMSE; I need SSE of this constrained model because I have to test if this model is better than the completely-free model.
SPSS gives me the SSE value in the regression output, but I don't know how to calculate a constrained linear regression with this model.
 A: If you are insane enough to literally try to compute the difference of the two sums of squares and relate it to an F distribution, you can certainly do that:
sysuse auto, clear
* (i) run full regression
regress price mpg foreign
* (ii) look into Stata guts
ereturn list
* (iii) take the pieces that you need
scalar ss_model_full = e(mss)
scalar ss_residual_full = e(rss)
scalar dfres_full = e(df_r)
* (iv) run constrained regression
regress price foreign
scalar ss_model_constr = e(mss)
scalar ss_residual_constr = e(rss)
scalar dfres_constr = e(df_r)
* (v) construct the test statistic
scalar F = ( ss_model_full - ss_model_constr) / (ss_residual_full/dfres_full)
display scalar(F)
* (vi) relate it to its reference distribution
scalar p_F = Ftail( dfres_constr - dfres_full, dfres_full, F)
display scalar(p_F)    

All the crap starting from (ii) is completely unnecessary and is fully taken care of with
test mpg
* look into the guts
return list

I would even go as far as to say that the reason they've written statistical software is that you won't have to do all the coding, introducing errors (statistical errors, code typos, references to wrong data, etc.) along the way.
