On Thu, 6 Aug 2009, Riccardo (Jack) Lucchetti wrote:
On Wed, 5 Aug 2009, Allin Cottrell wrote:
>> If the original model was estimated via OLS, the restricted one
>> could be estimated via NLS.
An alternative which does away with NLS and the associated potential
convergence problems is a Wald-type test, that is, a simple application
of the delta method (see section 5.9 of the manual). Example:
<script>
function nlWald(matrix coeff, matrix vcv, string funcstring)
lc = coeff
string s = funcstring~"(&lc)"
matrix bread = @s
df = cols(bread)
matrix J = fdjac(lc, @s)
matrix ham = invpd(qform(J, vcv))
scalar WT = qform(bread, ham)
printf "Nonlinear Wald Test: %12.6f (%d df, p-value = %g)\n", \
WT, df, pvalue(x, df, WT)
return scalar WT
end function
# ----------------------------------------------
# constraint function
function somestupidfunction(matrix *coeff)
scalar b1 = coeff[1]
scalar b2 = coeff[2]
matrix ret = (sqrt(b1)-b2*50) ~ (b1*b2 - 7)
return matrix ret
end function
# ----------------------------------------------
# main script
open data3-1.gdt
ols price const sqft
nlWald($coeff, $vcv, "somestupidfunction")
</script>
Basically, all you have to do is write a constraint function returning a
_row_ vector, which must be 0 under H0 and nonzero under H1. Then, you
feed it into the nlWald function and you're all set...
This is certainly an elegant approach. In fact, I wonder if it
might be worth offering a semi-automated version as an option to
the existing "restrict" command. That is,
restrict <function-name> --<option-name>
where <function-name> would refer to something like your
somestupidfunction and <option-name> would be something like
"nl-Wald". The place of your "nlWald" function would be taken by
a built-in function that automatically accesses $coeff and $vcv
from the last-estimated model (and deposits $test and $pvalue).
Is this too much like spoon-feeding?
On the other hand, my reading in Greene and Davidson and MacKinnon
(and not, I hasten to say, my own unaided thinking!) leads me to
the idea that such Wald tests are not altogether reliable, since
the result can depend quite sensitively on just how the
restriction is represented.
That thought was behind my suggestion of estimating the restricted
model and comparing either the sum of squared residuals or the
log-likelihood with that of the unrestricted model. True enough,
it's not always straightforward to estimate the restricted model
(though I think it is in the sort of case that Arthur brought up).
I'm not sure what's best here. Any other thoughts?
Allin.