[Gretl-users] Cochrane Orcutt: help!
Allin Cottrell
cottrell at wfu.edu
Tue Jul 17 00:19:21 EDT 2007
On Fri, 13 Jul 2007, Giovanni Inglisa wrote:
> Hi all! I'm not sure this is the most appropriate way to ask for
> support...but...here are my doubts
>
> I'm estimating AR parameters + a constant with a Cochrane-Orcutt
> alghorithm, which is the same used by the AR estimate procedure
> in gretl.
>
> Unfortunately I get really different values with respect to the
> constant...
The following script exposes the algorithm used by gretl. You
should find that the OLS after the loop and the corc command
produce exactly the same estimates.
begin script:
open data9-7
ols QNC 0 PRICE INCOME -q
genr u = $uhat
genr u_1 = u(-1)
scalar rho = sum(u*u_1) / sum(u_1*u_1)
scalar rhobak = rho
scalar rhodiff = 1
loop while rhodiff > .0001
genr yr = QNC - rho*QNC(-1)
series cr = 1 - rho
genr x1r = PRICE - rho*PRICE(-1)
genr x2r = INCOME - rho*INCOME(-1)
ols yr cr x1r x2r -q
genr u = QNC - $coeff(cr) - $coeff(x1r)*PRICE - \
$coeff(x2r)*INCOME
genr u_1 = u(-1)
rho = sum(u*u_1) / sum(u_1*u_1)
scalar rhodiff = abs(rho - rhobak)
rhobak = rho
end loop
ols yr cr x1r x2r
corc 1 0 2 3
end script
Allin Cottrell
More information about the Gretl-users
mailing list