[R] How can I test if a not independently and not identically distributed time series residuals' are uncorrelated ?
Adrian Trapletti
a.trapletti at bluewin.ch
Thu Jan 15 11:08:31 CET 2004
>
>
>I'm analizing the Argentina stock market (merv)
>I download the data from yahoo
>
>library(tseries)
>Argentina <- get.hist.quote(instrument="^MERV","1996-10-08","2003-11-03", quote="Close")
>
>merv <- na.remove(log(Argentina))
>
>I made the Augmented Dickey-Fuller test to analyse
>if merv have unit root:
>adf.test(merv,k=13)
>Dickey-Fuller = -1.4645, p-value = 0.805,
>merv have unit root than diff(merv,1) is stationary.
>
>Than I made Breushch-Pagan test to test if residuals are identically distributed:
>library(lmtest)
>bptest(merv[2:1730]~-1+merv[1:1729],~merv[1:1729]+I(merv[1:1729])2)
>BP = 81.3443, df = 2, p-value = < 2.2e-16
>So merv.reg$resid aren't identically distributed. Than merv is heteroscedastik.
>
>Finally I made Box-Ljung test to test if residuals are independently distributed:
>(H0: merv.reg$resid are independently distributed)
>library(ts)
>merv.reg <- lm(merv[2:1730]~-1+merv[1:1729])
>Box.test(merv.reg$resid, lag=25,type="Ljung")
>X-squared = 54.339, df = 25, p-value = 0.0006004
>So, there is evidence to not reject the null hypothesis,
>than the residuals are independently distributed.
>
Palhoto,
Box.test is a test, which tests for independence using the acf of a time
series. That means the test is in fact a test for uncorrelatedness
rather than independence. Applying Box.test to the squares of the
residuals is testing for ARCH effects in the time series. With stock
index data, usually the time series are uncorrelated, but show strong
ARCH effects, ie., are not independent. Other tests for independence are
bds.test and terasvirta.test from tseries. The former is a more general
test for independence, the latter focuses on neglected non-linearity in
the conditional mean (white.test is designed for the same, but I do not
recommend it). With stock index data, usually the time series are not
i.i.d. according to the bds.test due to ARCH effects. With
terasvirta.test you find sometimes neglected non-linearity in the
conditional mean. However, from my experience, this is often due to an
exogenuous structural break and not due to endogenuous non-linearity in
conditional mean.
best
Adrian
>Because the residuals are not independently distributed, we know that the
>squares of residuals are correlated:
>cov[(residuals_t)2, (residuals_(t-k))2] <> 0 (not zero for k <> 0)
>
>But, the residuals could be uncorrelated, (even when they
>are not independent distributed):
>cov[residuals_t, residual_(t-k)]=0 !
>How can I test that merv.reg$residuals are uncorrelated ?
>
>Thanks a lot.
>
>
> [[alternative HTML version deleted]]
>
--
Dr. Adrian Trapletti
Trapletti Statistical Computing
Wildsbergstrasse 31, 8610 Uster
Switzerland
Phone & Fax : +41 (0) 1 994 5631
Mobile : +41 (0) 76 370 5631
Email : mailto:a.trapletti at bluewin.ch
WWW : http://trapletti.homelinux.com
More information about the R-help
mailing list