Created
May 14, 2015 19:38
-
-
Save chrisvoncsefalvay/c80140a7f5b63b6036cc to your computer and use it in GitHub Desktop.
Useful R functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple little suite for testing | |
test_stationarity <- function(Ts){ | |
# First, display ACF. | |
message("Rendering ACF. Does it look like a random walk to you?") | |
acf(Ts) | |
# Calculate Ljung-Box | |
box <- Box.test(Ts, lag = 3, type = "Ljung-Box") | |
message(sprintf("The Ljung-Box statistic was %f.", box$p.value)) | |
message("This indicates that the distribution of values is ", appendLF = FALSE) | |
if(box$p.value <= 0.05){ | |
message("not random.\nConsider differencing or scaling.") | |
} | |
else { | |
message("random.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment