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

data(nottem)
temp<-stl(nottem, "per")
my.arima<-arima(temp$time.series[,3], order=c(1,0,0), include.mean = FALSE) 
my.arima
tsdiag(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: 

library(lmtest)
Y<- as.numeric(temp$time.series[,3])
X<-1:nrow(temp$time.series)
bptest(Y~X)



Regards

Wayne



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

Hi,

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.
Best
Vito

=====
Diventare costruttori di soluzioni

Visitate il portale http://www.modugno.it/
e in particolare la sezione su Palese
http://www.modugno.it/archivio/cat_palese.shtml

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html


KSS Ltd
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
mailto:[EMAIL PROTECTED]                http://www.kssg.com


The information in this Internet email is confidential and m...{{dropped}}

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to