Have a look at the 'lmtest'-contributed package.
maybe the following function is of use, too. Pls. check, if I got the
calculation of the test statistic right.
arch<-function(x, lag=4)
{
xfit<-lm(x)
res<-xfit$residuals
ressq<-res^2
#
tslag<-function(x,d=1)
{
n<-length(x)
c(rep(NA,d),x)[1:n]
}
#
ressq.data<-array(NA,c(length(ressq), lag))
labels<-paste("ressq.l",1:lag, sep="")
colnames(ressq.data)<-labels
for ( i in 1:lag)
{
ressq.data[,i]<-tslag(ressq,d=i)
}
residssq<-as.data.frame(ressq.data)
attach(residssq)
aux<-as.formula(paste("ressq~",paste(labels,collapse="+")))
auxfit<-lm(aux)
auxsum<-summary(auxfit)
stat<-length(auxsum$residuals)* auxsum$r.squared
pval<-1-pchisq(stat,df=lag)
detach(residssq)
ARCH.Stat<-c(stat,pval)
ARCH.Stat
}
As input you have tp provide your model formula, the test itself is based
upon the lm-residuals.
HTH,
Bernhard
-----Original Message-----
From: Vincent Spiesser [mailto:Vincent.Spiesser at univ-tlse1.fr]
Sent: 09 December 2002 15:07
To: r-help at stat.math.ethz.ch
Subject: [R] heteroscedasticity analysis
Hello,
First, sorry for my poor english, I will try to be understood.
It's the first time I try this "r-help mailing list" and I hope it
will be
a success.
I am working on heteroscedasticity analysis. I would like to get the
"Box-Ljung" and the "Lagrange multipliers" test.
I found the first one in the library "ts", but I can't find the
second one.
Does anybody know how this test can be called.
Vincent Spiesser
______________________________________________
R-help at stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help
----------------------------------------------------------------------
If you have received this e-mail in error or wish to read our e-mail
disclaimer statement and monitoring policy, please refer to
http://www.drkw.com/disc/email/ or contact the sender.
----------------------------------------------------------------------