[R-sig-finance] tips and tricks for rolling regressions?

Ajay Shah ajayshah at mayin.org
Thu Aug 26 07:12:30 CEST 2004


> #moving one-step-ahead GARCH(1,1)
> library(tseries)
> 
> width<-1500 #the size of the sample window
>                         
> data(EuStockMarkets) #data taken from package 'tseries'
> X<- diff(log(EuStockMarkets))[,"DAX"]
> 
> n<-length(X)
> from<-sapply((1:n)-width+1,function(x) max(x,1))
> to<-1:n
> all.elements<-apply(cbind(from,to),1,function(x) seq(x[1],x[2])) 
> good.elements<-all.elements[width:length(all.elements)]
> better.elements<-as.data.frame(good.elements)
> 
> #estimating GARCH(1,1) and extracting the fitted coefficients
> myfun<-function(i){
>     out<-garch(X[better.elements[,i]])
>     garchsum<-summary(out)[[2]][1:3]
>     names(garchsum)<-NULL
>     return(garchsum)
> }
> 
> res<-sapply(1:length(better.elements),function(i) myfun(i))
>     
> #adjusting the output
> RES<-matrix(unlist(res))
> dim(RES)<-dim(res)
> dimnames(RES)<-list(c("a0","a1","b1"),NULL)        
> (RES<-t(RES))

When I run your code, I get lots and lots of 
 ***** FALSE CONVERGENCE *****
error messages from the garch() function in the tseries
library. Should I be worried?

         -ans.

-- 
Ajay Shah                                                   Consultant
ajayshah at mayin.org                      Department of Economic Affairs
http://www.mayin.org/ajayshah           Ministry of Finance, New Delhi



More information about the R-sig-finance mailing list