lundi 30 octobre 2017

Jarque - Bera test for all columns in R

I´m trying to run the "Jarque - Bera" test for normality in R. I have a dataset with 30 time series and would like to run a test for each column since the time series har independent.

What I have tried so far:

> head(PF_ret)
           ATCOA SS Equity ATCOB SS Equity ELUXB SS Equity HMB SS Equity INDUC SS Equity INVEB SS Equity
1990-03-30    -0.037661051     -0.07646475     -0.04595186   0.008474576      0.01250000     -0.04595805
1990-04-30     0.006179197      0.02365591      0.06001529   0.008403361      0.06172840      0.02420949
1990-05-31     0.114636643      0.08823529     -0.07573026   0.108333333      0.19209302      0.05885191
1990-06-29     0.044077135      0.04343629      0.06554819   0.090225564     -0.04877097      0.05558087
1990-07-31    -0.014072120     -0.02127660      0.00000000   0.137931034      0.02543068      0.00000000
1990-08-31    -0.285459411     -0.25425331     -0.28451117  -0.151515152     -0.08000000     -0.21061718

library(tseries)


> jarque.bera.test(PF_ret[,1])

    Jarque Bera Test

data:  PF_ret[, 1]
X-squared = 24.465, df = 2, p-value = 4.87e-06

I know that [,1] means that we are looking at the first column in the dataset. But even if I try to define the test so that the code will run the test separately for each column I fail. I have tried to run the test for the columns above and expect R to write out 6 results for the JB-test.

> jarque.bera.test(PF_ret[,1:6])
Error in jarque.bera.test(PF_ret[, 1:6]) : 
  x is not a vector or univariate time series

Can anyone help me with this issue?

Aucun commentaire:

Enregistrer un commentaire