grangers_estimate.R 472 B

1234567891011121314151617
  1. #!/usr/bin/env Rscript
  2. library(grangers)
  3. library(RcppCNPy)
  4. signal_mat <- npyLoad('../data/time_series_small.npy')
  5. x <- signal_mat[1, ]
  6. y <- signal_mat[2, ]
  7. GC <- Granger.unconditional(x, y, ic.chosen='AIC', max.lag=4, plot=F)
  8. frequency <- GC$frequency
  9. gc_x_y <- GC$Unconditional_causality_x.to.y
  10. gc_y_x <- GC$Unconditional_causality_y.to.x
  11. result_df <- data.frame(frequency, gc_x_y, gc_y_x)
  12. gc_matrix <- as.matrix(result_df)
  13. npySave("../data/gc_matrix.npy", gc_matrix)