[R] jarquebera_test_results

Dennis Murphy djmuser at gmail.com
Sun Oct 30 21:01:36 CET 2011


Hi:

I'd double check the form of the upper bound of the sequence. In the
first case (i = 1), it uses the subvector loghozamok[1:220]; when i =
2, it uses the subvector loghozamok[21:260], etc. In the last case, it
uses loghozamok[1181:1420]. If instead you want to split the vector
into 60 groups of size 20, then this is easier (assuming that
loghozamok has length 1200):

gp <- rep(1:60, each = 20)
# Returns a vector
do.call(c, lapply(split(loghozamok, gp),
     function(z) unname(tseries::jarque.bera.test(z)$p.value)))

This works when gp and loghozamok have the same length.

# Small test:
x <- rnorm(100)
gp <- rep(1:5, each = 20)
do.call(c, lapply(split(x, gp),
     function(z) unname(tseries::jarque.bera.test(z)$p.value)))

        1         2         3         4         5
0.5849843 0.6745735 0.9453412 0.5978477 0.7207138

HTH,
Dennis

On Sun, Oct 30, 2011 at 10:23 AM, Szűcs Ákos <szucsakos at t-online.hu> wrote:
> Hi!
> I got a loop where i print out the results of Jarque Bera tests, but I have
> to put, the p-values in a vector. Can you help me how to do it in an
> effective way and not just typing in the results to a vector? Thanks a lot,
> here is the code:
> for(i in 1:60){
> print(jarque.bera.test(loghozamok[((20*(i-1))+1):(20*(i+11))]))}
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list