VECM - GARCH using maxLik()
On 9 February 2011 18:33, Philipp Grueber <philipp.grueber at ebs.edu> wrote:
thanks for the quick answer & sorry for the mistake. Please find a corrected version of the code below. Unfortunately, the model still does not work ? due to an error I believed to have overcome: ?In log(2 * pi * sig2[i]) : NaNs produced?
You should make sure that "2 * pi * sig2" is always positive, e.g. by using a different parametrisation for sig2, e.g. sig2[i] <- exp( omega + alpha*res[i-1]^2 + beta*sig2[i-1] )
... and how can I avoid the for-loop?
for (i in 2:99) {
sig2[i] <- omega + alpha*res[i-1]^2 + beta*sig2[i-1]
ll[i] <- -1/2*log(2*pi*sig2[i]) - 1/2*res[i]^2/sig2[i]
}
I have no idea for sig2 but you could move ll out of the loop:
ll[2:99] <- -1/2*log(2*pi*sig2[2:99]) - 1/2*res[2:99]^2/sig2[2:99]
/Arne
Arne Henningsen http://www.arne-henningsen.name