Quantcast

garch in R vs Matlab

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

garch in R vs Matlab

troger19
Hello guys
Why residuals in R are different than in matlab. Here is example
fit = garchFit(~garch(1, 1), data =ret)
res1<-fit@residuals
garch11<-ret-res1
garch11 = 0.0001074985  0.0001074985   0.0001074985 ......     which is coefficient  mu  from garchFit

in MATLAB
[coeff,errors,LLF,innovations,sigmas,summary] = garchfit(ret);

garch11<-ret-innovations =    3.066250e-04    1.075012e-04   -1.909928e-04   5.055000e-04 ..

Innovations (in help there is also use name "residuals") in Matlab should be the same residuals that those in R (fit@residuals) ? Even when coefficients alpha, beta, omega are same. Also simulation results are totally different. Does R count garch different than Matlab, or just additional mathematical operation are needed?
Regards Jano

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: garch in R vs Matlab

Spencer Graves
      Your example is not self contained, and I'm unable to replicate it.

      Consider the following (from ch03.R in the 'FinTS' package):

library(FinTS)
library(fGarch)
data(sp500)
spFit00.11a <- garchFit(sp500~garch(1,1), data=as.numeric(sp500))
str(spFit00.11a@residuals)
 num [1:792]  0.015050 -0.051450 -0.066550  0.015250  0.000250 ...

      Clearly, these residuals are not constant.

      Would you mind running this example through the Matlab 'garchfit'
function and reporting the answers to us?

      Also, would you mind providing us with the following:

str(ret)
sessionInfo()

      Finally, if you'd like to increase the expected utility of replies
to future posts, I suggest you check the Posting Guide at
www.r-project.org -> "Mailing Lists" -> "Posting Guide" (in the top line).
       
      Hope this helps.
      Spencer

[hidden email] wrote:

> Hello guys
> Why residuals in R are different than in matlab. Here is example
> fit = garchFit(~garch(1, 1), data =ret)
> res1<-fit@residuals
> garch11<-ret-res1
> garch11 = 0.0001074985  0.0001074985   0.0001074985 ......     which is coefficient  mu  from garchFit
>
> in MATLAB
> [coeff,errors,LLF,innovations,sigmas,summary] = garchfit(ret);
>
> garch11<-ret-innovations =    3.066250e-04    1.075012e-04   -1.909928e-04   5.055000e-04 ..
>
> Innovations (in help there is also use name "residuals") in Matlab should be the same residuals that those in R (fit@residuals) ? Even when coefficients alpha, beta, omega are same. Also simulation results are totally different. Does R count garch different than Matlab, or just additional mathematical operation are needed?
> Regards Jano
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: garch in R vs Matlab

michal miklovic
In reply to this post by troger19
Hi

I would suggest you to compare standardised residuals, defined as fit@residuals / [hidden email], from garchFit estimation with innovations from matlab.
Simulation results could be different because random numbers generated by the two programs are different.

Regards

Michal



----- Original Message ----
From: "[hidden email]" <[hidden email]>
To: R-SIG-Finance <[hidden email]>
Sent: Tuesday, February 26, 2008 11:29:39 PM
Subject: [R-SIG-Finance] garch in R vs Matlab

Hello guys
Why residuals in R are different than in matlab. Here is example
fit = garchFit(~garch(1, 1), data =ret)
res1<-fit@residuals
garch11<-ret-res1
garch11 = 0.0001074985  0.0001074985   0.0001074985 ......     which is coefficient  mu  from garchFit

in MATLAB
[coeff,errors,LLF,innovations,sigmas,summary] = garchfit(ret);

garch11<-ret-innovations =    3.066250e-04    1.075012e-04   -1.909928e-04   5.055000e-04 ..

Innovations (in help there is also use name "residuals") in Matlab should be the same residuals that those in R (fit@residuals) ? Even when coefficients alpha, beta, omega are same. Also simulation results are totally different. Does R count garch different than Matlab, or just additional mathematical operation are needed?
Regards Jano

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.






      ____________________________________________________________________________________
Looking for last minute shopping deals?  

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: garch in R vs Matlab

Spencer Graves
      I now see things I didn't see before:

           (1) With "garch11<-ret-res1", garch11 = mu.  Since the model
is "~garch(1,1)", I'd be worried if it were otherwise, because the model
for the 'mean' in this case is only the mean.

           (2) Per Michal's suggestions, it looks like 'innovations' may
be standardized residuals, which suggests we might want to compare
'innovations' with (fit@residuals / [hidden email]).

      In addition, you may wish to consider the following:

           (3) Using 'garchSim{fGarch}, you could simulate anything you
want in R, then export the numbers to Matlab and compare the estimates.  
If you made that comparison, I'm sure that other people would be
interested in the answers.  [If you export from R to a csv file, I
suggest you first round the numbers off to, say, 4 significant digits,
then apply 'garchFit' to the rounded numbers, to ensure you are actually
analyzing the same numbers in R and Matlab.]

           (4) If you do very much with both R and Matlab, you may wish
to investigate the R.matlab package if you haven't already.  It's not
the easiest thing to use, but if you do very much with both R and
Matlab, you may wish to look at it if you haven't already.  
   
     Spencer    

michal miklovic wrote:

> Hi
>
> I would suggest you to compare standardised residuals, defined as fit@residuals / [hidden email], from garchFit estimation with innovations from matlab.
> Simulation results could be different because random numbers generated by the two programs are different.
>
> Regards
>
> Michal
>
>
>
> ----- Original Message ----
> From: "[hidden email]" <[hidden email]>
> To: R-SIG-Finance <[hidden email]>
> Sent: Tuesday, February 26, 2008 11:29:39 PM
> Subject: [R-SIG-Finance] garch in R vs Matlab
>
> Hello guys
> Why residuals in R are different than in matlab. Here is example
> fit = garchFit(~garch(1, 1), data =ret)
> res1<-fit@residuals
> garch11<-ret-res1
> garch11 = 0.0001074985  0.0001074985   0.0001074985 ......     which is coefficient  mu  from garchFit
>
> in MATLAB
> [coeff,errors,LLF,innovations,sigmas,summary] = garchfit(ret);
>
> garch11<-ret-innovations =    3.066250e-04    1.075012e-04   -1.909928e-04   5.055000e-04 ..
>
> Innovations (in help there is also use name "residuals") in Matlab should be the same residuals that those in R (fit@residuals) ? Even when coefficients alpha, beta, omega are same. Also simulation results are totally different. Does R count garch different than Matlab, or just additional mathematical operation are needed?
> Regards Jano
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>
>
>
>
>
>
>       ____________________________________________________________________________________
> Looking for last minute shopping deals?  
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
Loading...