Quantcast

ugarchfit() ARCH LM tests contradict ArchTest()?

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

ugarchfit() ARCH LM tests contradict ArchTest()?

Brian Askins
Hello all,

My name is Brian Askins and I'm a student at the University of Washington
currently working on an M.S. in computational finance. Our current homework
is to fit a few GARCH models and do some diagnostic tests on them, one of
which is an LM test on the residuals to make sure there is no more
autocorrelation among them. If I use the ArchTest() function from the FinTS
package the results make sense and match (to a degree of error) a manual
test that I coded to check this. However, the results from that are
completely different from the results shown in the output of ugarchfit()
under the section "ARCH LM Tests." This also confused other people in the
class, including the TA. So can anyone tell me a little more information
about this discrepancy? I can't find any information on the LM test
performed in ugarchfit() from any of the documentation in the rugarch
package. Any help or pointers on where to find this information would be
greatly appreciated! Thanks!


--Brian

        [[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.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: ugarchfit() ARCH LM tests contradict ArchTest()?

braverock
On Sat, 2012-02-11 at 12:50 -0800, Brian Askins wrote:

> Hello all,
>
> My name is Brian Askins and I'm a student at the University of Washington
> currently working on an M.S. in computational finance. Our current homework
> is to fit a few GARCH models and do some diagnostic tests on them, one of
> which is an LM test on the residuals to make sure there is no more
> autocorrelation among them. If I use the ArchTest() function from the FinTS
> package the results make sense and match (to a degree of error) a manual
> test that I coded to check this. However, the results from that are
> completely different from the results shown in the output of ugarchfit()
> under the section "ARCH LM Tests." This also confused other people in the
> class, including the TA. So can anyone tell me a little more information
> about this discrepancy? I can't find any information on the LM test
> performed in ugarchfit() from any of the documentation in the rugarch
> package. Any help or pointers on where to find this information would be
> greatly appreciated! Thanks!

Brian,

It would help everyone out if you followed the posting guide and took
some time to create a reproducible example that demonstrates what you're
talking about.  From your question, you've obviously already written the
code, and the data is probably readily available, so roll it up, comment
it, and be specific about the differences that are confusing you.

Regards,

   - Brian

--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: ugarchfit() ARCH LM tests contradict ArchTest()?

alexios
I find that they agree completely:

library(rugarch)
data(dji30ret)
fit = ugarchfit(ugarchspec(),dji30ret[,1])

# The ARCH LM Test on the squared standardized residuals shows:
ARCH LM Tests
------------------------------------
              Statistic DoF P-Value
ARCH Lag[2]     0.6795   2  0.7119
ARCH Lag[5]     1.9091   5  0.8616
ARCH Lag[10]    4.2709  10  0.9343

z = residuals(fit)/sigma(fit)

library(FinTS)
ArchTest(z, 2)
Chi-squared = 0.6795, df = 2, p-value = 0.7119
ArchTest(z, 10)
Chi-squared = 4.2709, df = 10, p-value = 0.9343

i.e. EXACTLY the same.

Regards,
Alexios

On 11/02/2012 21:14, Brian G. Peterson wrote:

> On Sat, 2012-02-11 at 12:50 -0800, Brian Askins wrote:
>> Hello all,
>>
>> My name is Brian Askins and I'm a student at the University of Washington
>> currently working on an M.S. in computational finance. Our current homework
>> is to fit a few GARCH models and do some diagnostic tests on them, one of
>> which is an LM test on the residuals to make sure there is no more
>> autocorrelation among them. If I use the ArchTest() function from the FinTS
>> package the results make sense and match (to a degree of error) a manual
>> test that I coded to check this. However, the results from that are
>> completely different from the results shown in the output of ugarchfit()
>> under the section "ARCH LM Tests." This also confused other people in the
>> class, including the TA. So can anyone tell me a little more information
>> about this discrepancy? I can't find any information on the LM test
>> performed in ugarchfit() from any of the documentation in the rugarch
>> package. Any help or pointers on where to find this information would be
>> greatly appreciated! Thanks!
>
> Brian,
>
> It would help everyone out if you followed the posting guide and took
> some time to create a reproducible example that demonstrates what you're
> talking about.  From your question, you've obviously already written the
> code, and the data is probably readily available, so roll it up, comment
> it, and be specific about the differences that are confusing you.
>
> Regards,
>
>     - Brian
>

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: ugarchfit() ARCH LM tests contradict ArchTest()?

Brian Askins
Thank you for posting that, Alexios. I was working on code for an example
(because my current code is homework code so I cannot post it) but you
showed me what was different. I was doing the ArchTest on the residuals,
not the standardized residuals. This makes much more sense now.

My apologies for not including code in the first post, I'll be sure to
include a working example in all future posts.

Thanks again everyone, I'll let the other people in my class know what was
going on with this.

--Brian

On Sat, Feb 11, 2012 at 1:45 PM, alexios <[hidden email]> wrote:

> I find that they agree completely:
>
> library(rugarch)
> data(dji30ret)
> fit = ugarchfit(ugarchspec(),**dji30ret[,1])
>
> # The ARCH LM Test on the squared standardized residuals shows:
> ARCH LM Tests
> ------------------------------**------
>             Statistic DoF P-Value
> ARCH Lag[2]     0.6795   2  0.7119
> ARCH Lag[5]     1.9091   5  0.8616
> ARCH Lag[10]    4.2709  10  0.9343
>
> z = residuals(fit)/sigma(fit)
>
> library(FinTS)
> ArchTest(z, 2)
> Chi-squared = 0.6795, df = 2, p-value = 0.7119
> ArchTest(z, 10)
> Chi-squared = 4.2709, df = 10, p-value = 0.9343
>
> i.e. EXACTLY the same.
>
> Regards,
> Alexios
>
>
> On 11/02/2012 21:14, Brian G. Peterson wrote:
>
>> On Sat, 2012-02-11 at 12:50 -0800, Brian Askins wrote:
>>
>>> Hello all,
>>>
>>> My name is Brian Askins and I'm a student at the University of Washington
>>> currently working on an M.S. in computational finance. Our current
>>> homework
>>> is to fit a few GARCH models and do some diagnostic tests on them, one of
>>> which is an LM test on the residuals to make sure there is no more
>>> autocorrelation among them. If I use the ArchTest() function from the
>>> FinTS
>>> package the results make sense and match (to a degree of error) a manual
>>> test that I coded to check this. However, the results from that are
>>> completely different from the results shown in the output of ugarchfit()
>>> under the section "ARCH LM Tests." This also confused other people in the
>>> class, including the TA. So can anyone tell me a little more information
>>> about this discrepancy? I can't find any information on the LM test
>>> performed in ugarchfit() from any of the documentation in the rugarch
>>> package. Any help or pointers on where to find this information would be
>>> greatly appreciated! Thanks!
>>>
>>
>> Brian,
>>
>> It would help everyone out if you followed the posting guide and took
>> some time to create a reproducible example that demonstrates what you're
>> talking about.  From your question, you've obviously already written the
>> code, and the data is probably readily available, so roll it up, comment
>> it, and be specific about the differences that are confusing you.
>>
>> Regards,
>>
>>    - Brian
>>
>>
>

        [[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.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: ugarchfit() ARCH LM tests contradict ArchTest()?

alexios
Hi Brian,

Testing on the ARMA (or other filtration) residuals should be done prior
to the estimation to test for the presence of ARCH effects. Once a GARCH
model is fitted, then you need to incorporate this information by using
the residuals standardized by the conditional sigma of the GARCH model.
The details of all tests used in the rugarch package are detailed in the
vignette.

Regards,
Alexios

On 11/02/2012 21:58, Brian Askins wrote:

> Thank you for posting that, Alexios. I was working on code for an
> example (because my current code is homework code so I cannot post it)
> but you showed me what was different. I was doing the ArchTest on the
> residuals, not the standardized residuals. This makes much more sense now.
>
> My apologies for not including code in the first post, I'll be sure to
> include a working example in all future posts.
>
> Thanks again everyone, I'll let the other people in my class know what
> was going on with this.
>
> --Brian
>
> On Sat, Feb 11, 2012 at 1:45 PM, alexios <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     I find that they agree completely:
>
>     library(rugarch)
>     data(dji30ret)
>     fit = ugarchfit(ugarchspec(),__dji30ret[,1])
>
>     # The ARCH LM Test on the squared standardized residuals shows:
>     ARCH LM Tests
>     ------------------------------__------
>                  Statistic DoF P-Value
>     ARCH Lag[2]     0.6795   2  0.7119
>     ARCH Lag[5]     1.9091   5  0.8616
>     ARCH Lag[10]    4.2709  10  0.9343
>
>     z = residuals(fit)/sigma(fit)
>
>     library(FinTS)
>     ArchTest(z, 2)
>     Chi-squared = 0.6795, df = 2, p-value = 0.7119
>     ArchTest(z, 10)
>     Chi-squared = 4.2709, df = 10, p-value = 0.9343
>
>     i.e. EXACTLY the same.
>
>     Regards,
>     Alexios
>
>
>     On 11/02/2012 21:14, Brian G. Peterson wrote:
>
>         On Sat, 2012-02-11 at 12:50 -0800, Brian Askins wrote:
>
>             Hello all,
>
>             My name is Brian Askins and I'm a student at the University
>             of Washington
>             currently working on an M.S. in computational finance. Our
>             current homework
>             is to fit a few GARCH models and do some diagnostic tests on
>             them, one of
>             which is an LM test on the residuals to make sure there is
>             no more
>             autocorrelation among them. If I use the ArchTest() function
>             from the FinTS
>             package the results make sense and match (to a degree of
>             error) a manual
>             test that I coded to check this. However, the results from
>             that are
>             completely different from the results shown in the output of
>             ugarchfit()
>             under the section "ARCH LM Tests." This also confused other
>             people in the
>             class, including the TA. So can anyone tell me a little more
>             information
>             about this discrepancy? I can't find any information on the
>             LM test
>             performed in ugarchfit() from any of the documentation in
>             the rugarch
>             package. Any help or pointers on where to find this
>             information would be
>             greatly appreciated! Thanks!
>
>
>         Brian,
>
>         It would help everyone out if you followed the posting guide and
>         took
>         some time to create a reproducible example that demonstrates
>         what you're
>         talking about.  From your question, you've obviously already
>         written the
>         code, and the data is probably readily available, so roll it up,
>         comment
>         it, and be specific about the differences that are confusing you.
>
>         Regards,
>
>             - Brian
>
>
>

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: ugarchfit() ARCH LM tests contradict ArchTest()?

Juan Lin

'Q-Statistics on Standardized Residuals' will be reported as the output of the ugarchfit function.
Here is my sample code (I use ARMA(2,1), t-GARCH(1,1) to estimate the volatility series, rate is the exogenous variable.):
spec=ugarchspec(variance.model=list(model="eGARCH",garchOrder=c(1,1),submodel=NULL,
external.regressors=as.matrix(rate), variance.targeting = FALSE),
mean.model = list(armaOrder = c(2,1), include.mean = TRUE, garchInMean = FALSE,
inMeanType = 1, arfima = FALSE, external.regressors =as.matrix(rate)), distribution.model = "std",
start.pars = list(mxreg1=0.01,vxreg1=3), fixed.pars = list())
fit=ugarchfit(spec,data=volatility)
fit
 
Here is the output,
Q-Statistics on Standardized Residuals
------------------------------------
      statistic   p-value
Lag10     20.22 0.0051156
Lag15     26.46 0.0092400
Lag20     44.40 0.0002987
H0 : No serial correlation
Q-Statistics on Standardized Squared Residuals
------------------------------------
      statistic   p-value
Lag10     13.05 0.0709829
Lag15     37.01 0.0002226
Lag20     38.44 0.0021370
ARCH LM Tests
------------------------------------
             Statistic DoF P-Value
ARCH Lag[2]      1.790   2  0.4085
ARCH Lag[5]      6.719   5  0.2424
ARCH Lag[10]    14.399  10  0.1555

My question is
(1) Are  the Standardized Residuals  in 'Q-Statistics on Standardized Residuals'  equal to residuals(fit)/sigma(fit)£¿
(2) If the p value for the 'Q-Statistics on Standardized Residuals' is very small, like the case in my post,
should I adjust the ARMA model or GARCH model or both?

Thanks,
Juan Lin

 

> Date: Sat, 11 Feb 2012 22:07:22 +0000
> From: [hidden email]
> To: [hidden email]
> CC: [hidden email]
> Subject: Re: [R-SIG-Finance] ugarchfit() ARCH LM tests contradict ArchTest()?
>
> Hi Brian,
>
> Testing on the ARMA (or other filtration) residuals should be done prior
> to the estimation to test for the presence of ARCH effects. Once a GARCH
> model is fitted, then you need to incorporate this information by using
> the residuals standardized by the conditional sigma of the GARCH model.
> The details of all tests used in the rugarch package are detailed in the
> vignette.
>
> Regards,
> Alexios
>
> On 11/02/2012 21:58, Brian Askins wrote:
> > Thank you for posting that, Alexios. I was working on code for an
> > example (because my current code is homework code so I cannot post it)
> > but you showed me what was different. I was doing the ArchTest on the
> > residuals, not the standardized residuals. This makes much more sense now.
> >
> > My apologies for not including code in the first post, I'll be sure to
> > include a working example in all future posts.
> >
> > Thanks again everyone, I'll let the other people in my class know what
> > was going on with this.
> >
> > --Brian
> >
> > On Sat, Feb 11, 2012 at 1:45 PM, alexios <[hidden email]
> > <mailto:[hidden email]>> wrote:
> >
> > I find that they agree completely:
> >
> > library(rugarch)
> > data(dji30ret)
> > fit = ugarchfit(ugarchspec(),__dji30ret[,1])
> >
> > # The ARCH LM Test on the squared standardized residuals shows:
> > ARCH LM Tests
> > ------------------------------__------
> > Statistic DoF P-Value
> > ARCH Lag[2] 0.6795 2 0.7119
> > ARCH Lag[5] 1.9091 5 0.8616
> > ARCH Lag[10] 4.2709 10 0.9343
> >
> > z = residuals(fit)/sigma(fit)
> >
> > library(FinTS)
> > ArchTest(z, 2)
> > Chi-squared = 0.6795, df = 2, p-value = 0.7119
> > ArchTest(z, 10)
> > Chi-squared = 4.2709, df = 10, p-value = 0.9343
> >
> > i.e. EXACTLY the same.
> >
> > Regards,
> > Alexios
> >
> >
> > On 11/02/2012 21:14, Brian G. Peterson wrote:
> >
> > On Sat, 2012-02-11 at 12:50 -0800, Brian Askins wrote:
> >
> > Hello all,
> >
> > My name is Brian Askins and I'm a student at the University
> > of Washington
> > currently working on an M.S. in computational finance. Our
> > current homework
> > is to fit a few GARCH models and do some diagnostic tests on
> > them, one of
> > which is an LM test on the residuals to make sure there is
> > no more
> > autocorrelation among them. If I use the ArchTest() function
> > from the FinTS
> > package the results make sense and match (to a degree of
> > error) a manual
> > test that I coded to check this. However, the results from
> > that are
> > completely different from the results shown in the output of
> > ugarchfit()
> > under the section "ARCH LM Tests." This also confused other
> > people in the
> > class, including the TA. So can anyone tell me a little more
> > information
> > about this discrepancy? I can't find any information on the
> > LM test
> > performed in ugarchfit() from any of the documentation in
> > the rugarch
> > package. Any help or pointers on where to find this
> > information would be
[[elided Hotmail spam]]

> >
> >
> > Brian,
> >
> > It would help everyone out if you followed the posting guide and
> > took
> > some time to create a reproducible example that demonstrates
> > what you're
> > talking about. From your question, you've obviously already
> > written the
> > code, and the data is probably readily available, so roll it up,
> > comment
> > it, and be specific about the differences that are confusing you.
> >
> > Regards,
> >
> > - Brian
> >
> >
> >
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
     
        [[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.
-- Also note that this is not the r-help list where general R questions should go.
Loading...