RE: [R] Testing autocorrelation & heteroskedasticity of residuals in ts

From: Wayne Jones <>
Date: Wed 21 Jul 2004 - 18:41:07 EST

Hi Vito,
I would treat the residuals as a time series. You can fit an arima model to the residuals. For example:

temp<-stl(nottem, "per")
my.arima<-arima(temp$time.series[,3], order=c(1,0,0), include.mean = FALSE) my.arima

If the ar1 term is significant then the residuals are auto-correlated. The DW statistic is just another test for this. The command tsdiag gives diagnostic plots for the arima model fit.

In terms of heteroskedasticity, the Bruce-Pagan test from package lmtest tests for variance changing as a function of another variable. I think (although I am less sure) you can still use the test.

To test whether your variance of residuals is monotonically increasing (or maybe decreasing) over time I would use:

Y<- as.numeric(temp$time.series[,3])



-----Original Message-----
From: Vito Ricci []
Sent: 21 July 2004 08:35
Subject: [R] Testing autocorrelation & heteroskedasticity of residuals in ts


I'm dealing with time series. I usually use stl() to estimate trend, stagionality and residuals. I test for normality of residuals using shapiro.test(), but I can't test for autocorrelation and heteroskedasticity. Is there a way to perform Durbin-Watson test and Breusch-Pagan test (or other simalar tests) for time series?
I find dwtest() and bptest() in the package lmtest, but it requieres an lm object, while I've a ts object. Any help will be appreciated.

Diventare costruttori di soluzioni

Visitate il portale e in particolare la sezione su Palese mailing list PLEASE do read the posting guide!

Seventh Floor St James's Buildings 79 Oxford Street Manchester M1 6SS England Company Registration Number 2800886

Tel: +44 (0) 161 228 0040	Fax: +44 (0) 161 236 6305

The information in this Internet email is confidential and m...{{dropped}} mailing list PLEASE do read the posting guide! Received on Wed Jul 21 18:55:37 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:09 EST