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))]))}
jarquebera_test_results
3 messages · Szűcs Ákos, David Winsemius, Dennis Murphy
Sz?cs ?kos 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+
The power is out here so I have no access to R. I can tell you what I would have done. Go to the help page for that function and look at the Value section. Generally functions return a list and you need to find the name of the item that has the p-value. It's possible that there will be a print method for the object returned and you might need to look at that page. As a last resort you would look at the object returned with str().
David. -- View this message in context: http://r.789695.n4.nabble.com/jarquebera-test-results-tp3953541p3953795.html Sent from the R help mailing list archive at Nabble.com.
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.