Displaying 1 result from an estimated 1 matches for "logll".
Did you mean:
loglvl
2008 Oct 14
0
nlm return wrong function value - garch fitting
...#######
garchLLH <- function(y,xdata, parm) {
len<-length(parm)
yhat<-as.vector(t(parm[1:(len-3)]%*%t(xdata)))
###compute likelihood
omega<-parm[len-2]; alpha<-parm[len-1]; beta<-parm[len]
z<-(y-yhat)^2; Mean=mean(z); #### z is the squared error
h<-vector(length=length(y) )
logLL<-vector(length=length(y) )
h[1] <- omega + alpha*Mean + beta*Mean;
logLL[1]<- 0.5 * ( log (2*pi) + log (h[1] ) + z[1] / h[1] ) #negative of the
LL
for (i in (2:length(y)) ) {
h[i] <- omega + alpha*z[i-1] + beta*h[i-1]
#logLL[i]<- -0.5 * ( log (2*pi) + log (h[i] ) + z[i] / h[i] )...