Page 1 of 1
Koyck Model MLE
Posted: Mon May 12, 2014 3:40 am
by BiXiC
Hi, I want to estimate Koyck model with ML in Eviews
https://www.google.ru/url?sa=t&rct=j&q= ... GE&cad=rjt
S = mu + beta*A + lambda*S(-1) + e - lambda*e(-1)
But i don't get how to make BFGS algorithm or the Newton-Raphson algorithm in Eviews. Can smb help me?
P.S. I use Eviews 8
Re: Koyck Model MLE
Posted: Thu May 15, 2014 11:20 am
by EViews Glenn
Chapter 10 - User Defined Optimization
EViews 8 Command and Programming Reference
Re: Koyck Model MLE
Posted: Fri May 16, 2014 7:10 am
by BiXiC
I got it. But is it possible to estimate that kind of models in equation object?
If I try: S = c(1) + c(2)*A + c(3)*S(-1)+[ma(1) = c(3)], i get error message: MA and SMA terms are only allowed in equations specified by a list of regressors.
Re: Koyck Model MLE
Posted: Fri May 16, 2014 8:48 am
by EViews Glenn
You can, but you'll have to build the likelihood evaluation yourself. There is nothing in the optimize that handles those terms directly.
Re: Koyck Model MLE
Posted: Fri May 16, 2014 2:01 pm
by trubador
I got it. But is it possible to estimate that kind of models in equation object?
If I try: S = c(1) + c(2)*A + c(3)*S(-1)+[ma(1) = c(3)], i get error message: MA and SMA terms are only allowed in equations specified by a list of regressors.
Franses and van Oest (2004) draw attention to two things:
1) Importance of parameter restriction. Correct specification would be S = c(1) + c(2)*A + c(3)*S(-1) + [ar(1) = c(3)]. EViews utilizes nonlinear least squares in estimating ARMA models by default. This seems to be fine with the paper as imposing the restriction results in a much more material difference than the choice of estimation algorithm. Please see the following if you need further information on ARMA estimation in EViews:
http://forums.eviews.com/viewtopic.php?f=7&t=465
2) Necessity of a new t-statistic for hypothesis testing on the coefficient of advertising, c(2), as the asymptotic distribution would not be standard normal. You can either use the critical values in Table 2, or run a similar monte carlo simulation after you estimate the model and obtain the value of c(2).
Re: Koyck Model MLE
Posted: Fri May 16, 2014 2:25 pm
by startz
I got it. But is it possible to estimate that kind of models in equation object?
If I try: S = c(1) + c(2)*A + c(3)*S(-1)+[ma(1) = c(3)], i get error message: MA and SMA terms are only allowed in equations specified by a list of regressors.
Franses and van Oest (2004) draw attention to two things:
1) Importance of parameter restriction. Correct specification would be S = c(1) + c(2)*A + c(3)*S(-1) + [ar(1) = c(3)]. EViews utilizes nonlinear least squares in estimating ARMA models by default. This seems to be fine with the paper as imposing the restriction results in a much more material difference than the choice of estimation algorithm. Please see the following if you need further information on ARMA estimation in EViews:
http://forums.eviews.com/viewtopic.php?f=7&t=465
2) Necessity of a new t-statistic for hypothesis testing on the coefficient of advertising, c(2), as the asymptotic distribution would not be standard normal. You can either use the critical values in Table 2, or run a similar monte carlo simulation after you estimate the model and obtain the value of c(2).
Trubador,
I think the paper does give a (problematic for EViews) MA rather than AR specification.
Re: Koyck Model MLE
Posted: Fri May 16, 2014 3:53 pm
by trubador
Ah yes, Startz you are right. Then the only way to estimate this model, as Glenn pointed out, would be the use of optimize along the following lines:
Code: Select all
subroutine loglikelihood(series logl,coef beta,series y,series x)
smpl @first @first
series res = 0
smpl @first+1 @last
series res = y - beta(1)*x - beta(2)*y(-1) - beta(3)*@seas(1) - beta(4)*@seas(2) - beta(5)*@seas(3) - beta(6)*@seas(4) - beta(7)*@seas(5) - beta(8)*@seas(6) - beta(9)*@seas(7) - beta(10)*@seas(8) - beta(11)*@seas(9) - beta(12)*@seas(10) - beta(13)*@seas(11) - beta(14)*@seas(12) + beta(2)*res(-1)
logl = @log((1/beta(15))*@dnorm(res/beta(15)))
endsub
'Initialize coefficients and series
series logl = 0
coef(15) beta = .5
beta(15) = 100 'standard error of regression
smpl @first+2 @last
optimize(ml=1, finalh=hessmat, hess=bfgs) loglikelihood(logl,beta,sales,advertising)
vector semat = @sqrt(@getmaindiagonal(-@inverse(hessmat))) 'standard errors of estimated parameters
scalar loglik = @sum(logl) 'log likelihood
smpl @all
Re: Koyck Model MLE
Posted: Mon May 19, 2014 2:20 am
by BiXiC
I constructed similar code but I have an error: Objective function evalueates to NA for one or more observations in "OPTIMIZE..."
My Sales and tvrs seriesd don't have any NA values. What is wrong?
Code: Select all
' Koyck model:
' S = c(1) + c(2) * S(-1) + c(3) * TVR + e - c(2) * e(-1)
' e = S - c(1) - c(2) * S(-1) - c(3) * TVR + c(2) * e(-1)
subroutine loglike(series logl, vector beta, series S, series TVR)
smpl @first @first
series r = 0
smpl @first+1 @last
series r = S - beta(1) - beta(2) * S(-1) - beta(3) * TVR + beta(2) * r(-1)
logl = @log((1 / beta(4)) * @dnorm(r / beta(4)))
endsub
' create series LL which holds the likelihood contribution
series LL = 0
' create the coefficient vector BETA
vector(4) coefs_Koyck_model_ML
coefs_Koyck_model_ML = 0.5
coefs_Koyck_model_ML(4) = 10
smpl @first+1 @last
optimize(ml=1, finalh=mlhess, hess=bfgs) loglike(LL, coefs_Koyck_model_ML, sales, tvrs)
smpl @all
' MLSE - The coefficient standard errors for the maximum likelihood estimates
vector MLSE = @sqrt(@getmaindiagonal(-@inverse(mlhess)))
' Calculating unbiased estimate of sigma
scalar ubsig = mlcoefs(2)*@sqrt(@obs(LL)/(@obs(LL) - @rows(coefs_Koyck_model_ML)+ 1))
%status = @optmessage
statusline {%status}
Re: Koyck Model MLE
Posted: Mon May 19, 2014 5:40 am
by trubador
Try adjusting the sample period before Optimize as follows:
Re: Koyck Model MLE
Posted: Mon May 19, 2014 11:42 pm
by BiXiC
I tried. Still do not working. Same problem :(