On Sat, 24 Dec 2011, clarodina(a)lycos.com wrote:
Make some adjust to the script but don't know does is there
error
d1 d2 and d3 are different data series
Want regress d1 against d2 and d3 without const
The output would be a regress d1hat
Do a adf on d1 - d1hat
Use the bfgsmax to determine the coefficients of d2 and d3
maximising t from the adf of d1 - d11hat
function scalar adf_t (matrix *b, series y, series d2, series d3)
series d0 = y - (b[1]*d2 + b[2]*d3)
adf 0 d0 --c --quiet
scalar tau = $test
return tau
end function
Using the above script gives a error
The convergence criterion was not met
Error executing script: halting
This is my last contribution on this point. It's not surprising that
BFGS failed to converge since there's no guarantee that there's any
finite maximum for this problem. Nor is there any guarantee (or even
likelihood) that the "d1hat" arrived at in this way can be
considered as a "fitted value" or prediction for d1. It may bear no
resemblance to d1.
I guess that in fact you want to minimize, not maximize, the ADF
t-ratio (that is, maximize the strength of the rejection of the
unit-root null hypothesis for the series in question, which requires
a negative t-value). But that doesn't alter my comment above. Here's
a sample script, but as I said this is my last shot on this topic:
<hansl>
function scalar adf_max (matrix *b, series d1, series d2, series d3)
series u = d1 - (b[1]*d2 + b[2]*d3)
adf 0 u --nc --quiet
# maximize negative tau
scalar tau = -$test
return tau
end function
nulldata 100
series d1 = normal()
series d2 = normal()
series d3 = normal()
matrix b = {1,1}
# set a sloppy tolerance
set bfgs_toler 1e-6
tau_max = BFGSmax(b, adf_max(&b, d1, d2, d3))
print b
series d1hat = b[1]*d2 + b[2]*d3
series u = d1 - d1hat
adf 0 u --nc
# are d1 and d1hat related?
corr d1 d1hat
</hansl>
Allin Cottrell