[R] [R ] Writing loop to estimate ARCH test for a multiple columns of a data frame?
Jim Lemon
drj|m|emon @end|ng |rom gm@||@com
Fri May 8 11:07:37 CEST 2020
Hi Subhamitra,
This isn't too hard:
# read in the sample data that was
# saved in the file "sp_8_5.tab"
sp_8_5<-read.table("sp_8_5.tab",sep="\t",
header=TRUE,stringsAsFactors=FALSE)
library(tseries)
library(FinTS)
# using "sapply", run the test on each column
spout<-sapply(sp_8_5[,2:12],ArchTest)
The list "spout" contains the test results. If you really want to use a
loop:
spout<-list()
for(i in 2:12) spout[[i-1]]<-ArchTest(sp_8_5[,i])
Jim
On Fri, May 8, 2020 at 5:27 PM Subhamitra Patra <subhamitra.patra using gmail.com>
wrote:
> Dear Sir,
>
> Herewith I am pasting a part of my sample data having 12 columns below,
> and want to calculate ARCH test for the 12 columns by using a loop.
>
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list