Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dragstar328
Last active April 12, 2016 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dragstar328/f47ecc52ece3c41af2530a2a7f1ce7d1 to your computer and use it in GitHub Desktop.
Save dragstar328/f47ecc52ece3c41af2530a2a7f1ce7d1 to your computer and use it in GitHub Desktop.
温度をARIMA時系列分析
library(forecast)
# データ読み込み
d = read.csv("temp.csv")
# unixtimeをPOSIXctに変換
tsPOSIX = as.POSIXct(d[,1], origin="1970-01-01")
d = cbind(tsPOSIX, d)
colnames(d)[1] = "ts"
head(d)
tail(d)
# auto.arimaを使って時系列分析
d.arima = auto.arima(d[, 2], stepwise = T, trace=T)
# 100期先まで予測する
d.arima.forecast = forecast(d.arima, level=c(50,95), h = 100)
# 予測値をプロット
plot(d.arima.forecast)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment