require(MTS)
rt=rnorm(200)
b<-archTest(rt, lag = 10)
This code results in the values
Q(m) of squared series(LM test):
Test statistic: 7.694531 p-value: 0.6586466
Rank-based Test:
Test statistic: 20.80503 p-value: 0.02249487
But when the structure of b is checked using typeof(b)
and str(b)
, it gives NULL
.
How is it possible? How can one knows the structure of b
as it is needed to extract values from this variable.
If you look at the source code of
archTest
, you're question boils down to more or less this one: can I stopcat
from returningNULL
? To which the answer is no.You can modify
archTest
however such that it returns the test statistic and p-value (see below).b
is a named vector.I added three lines at the end of
MTS::archTest
.As pointed out by @42- in the comments, the
return
call is not necessary.