Analisis Deret Waktu dengan R
David S. Matteson
Associate Professor at Cornell University
# Autokorelasi lag 1:
# Korelasi saham A "hari ini" dan saham A "kemarin"
cor(stock_A[-100], stock_A[-1])
0.84

# Autokorelasi lag 2:
# Korelasi saham A “hari ini” dan saham A “dua hari sebelumnya”
cor(stock_A[-(99:100)],stock_A[-(1:2)])
0.76

cor(stock_A[-100],stock_A[-1])
0.84
cor(stock_A[-(99:100)],stock_A[-(1:2)])
0.76
acf(stock_A, lag.max = 2, plot = FALSE)
Autokorelasi deret ‘stock_A’, menurut lag
1 2
0.84 0.76

# Autokorelasi menurut lag: “Fungsi Autokorelasi”
(ACF)acf(stock_A, plot = FALSE)
Autokorelasi deret ‘stock_A’, menurut lag
1 2 3 4 5 6 7 8 9 10
0.84 0.76 0.64 0.57 0.52 0.46 0.41 0.36 0.29 0.25
acf(stock_A, plot = TRUE)

Analisis Deret Waktu dengan R