I'm trying to estimate the parameters for GARCH(1,1) process.
Here's my code:
 
loglikelihood <-function(theta) {

h=((r[1]-theta[1])^2)
p=0

for (t in 2:length(r)) {
h=c(h,theta[2]+theta[3]*((r[t-1]-theta[1])^2)+theta[4]*h[t-1])
p=c(p,dnorm(r[t],theta[1],sqrt(h[t]),log=TRUE))
}

-sum(p)

}

 
Then I use nlminb to minimize the function loglikelihood:
 
nlminb( c(0.001,0.001,0.001,0.001), loglikelihood, lower=c(0.000001,0,0,0))
 
This does not produce a good result: the iteration limit is reached and 
increasing it won't help. I have used "garchFit" from fGarch-package to 
estimate the parameters. I set garchFit to use nlminb as well, and it produces 
a result within just a few seconds. 
However, for modification purposes, I need to get my own code working.
 
                                          
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to