Skip to content

Instantly share code, notes, and snippets.

@arimitramaiti
Last active October 2, 2020 06:59
Show Gist options
  • Save arimitramaiti/218783f86d984fd3081600d9331b7989 to your computer and use it in GitHub Desktop.
Save arimitramaiti/218783f86d984fd3081600d9331b7989 to your computer and use it in GitHub Desktop.
#Set the seed
set.seed(30)
#Generate normally distributed series
series1 <- rnorm(10000)
#Store acf values
acf1 <- acf(series1, plot = FALSE)
#Set the seed
set.seed(32)
#Generate two different normally distributed series and combine
series2 <- c(rnorm(5000, mean=0.9, sd=0.2), rnorm(5000))
#Store acf values
acf2 <- acf(series2, plot = FALSE)
par(mfrow=c(2,2))
#plot the series using title, x & ylabels, use lines and a marker at yaxis=0
plot(series1, main="Series-1", xlab="Time", ylab="Values")
lines(series1)
abline(h=0, col="red")
#Plot acf values
plot(acf1, main = "ACF-Series-1")
#plot the series using title, x & ylabels, use lines and a marker at yaxis=0
plot(series2, main="Series-2", xlab="Time", ylab="Values")
lines(series2)
abline(h=0, col="red")
#Plot acf values
plot(acf2, main = "ACF-Series-2")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment