On Fri, 15 Apr 2011, Dempsey, Keely wrote:
After estimating GMM, is it possible to estimate R-squared of
the equation?
Yes, but you have to decide how you want to calculate R-squared,
for a model not estimated via least squares. One approach that
people use is to compute the square of the correlation between
actual and predicted y (dependent variable). But GMM is general
enough that gretl doesn't necessarily know what the "dependent
variable" is; you'll have to tell it.
Here's a simple example script:
open data4-1
# run OLS and record R-squared
ols price const sqft
R2_ols = $rsq
# set-up for GMM
matrix X = { const, sqft}
matrix y = { price }
matrix B = { 50, 0.1 }'
matrix I2 = I(2)
matrix e = y - X*B
# emulate OLS via GMM
gmm e = y - X*B
orthog e ; X
params B
weights I2
end gmm
# calculate fitted values from GMM
series yhat = price - e
R2_gmm = corr(price, yhat)^2
printf "R2_ols = %.4f, R2_gmm = %.4f\n", R2_ols, R2_gmm
Allin Cottrell