[英]Modelling time series data from multiple cities (one week period)
I am trying to model temperature data from my df which contains 4 different cities, i initially want to fit a model to model the temperature for 1 of my locations.我正在尝试从包含 4 个不同城市的 df 中获取 model 温度数据,我最初想将 model 安装到 model 我的 1 个位置的温度。 Initially i want to fit a model to predict for High Wycombe but I'm not sure how to do this whilst keeping the data for each location.最初我想安装一个 model 来预测海威科姆,但我不确定如何在保留每个位置的数据的同时做到这一点。 Is this something that is possible or do i need to split the data up further before doing this and model separately?这是可能的吗,还是我需要在执行此操作之前进一步拆分数据并分别 model ? For example I initially done this although want able to get my predicions and plot working;例如,我最初这样做虽然希望能够让我的预测和 plot 工作;
dat_hw = c(15.4, 15.5, 9.8, 10.1, 11.7, 10.0, 14.1)
hw_ts = ts(dat_hw, frequency = 365, start = c(2020, 305))
mod = auto.arima(hw_ts)
preds = predict(mod)
plot(preds$pred)
In an ideal world i would be able to model all of my data and then jst predict for each individual location if possible在理想的世界中,我将能够 model 我的所有数据,然后尽可能预测每个单独的位置
overall data整体数据
Date Machrihanish High_Wycombe Camborne Dun_Fell
1 20201101 11.8 15.4 15 10.4
2 20201102 11.1 15.5 15 10.5
3 20201103 9.7 9.8 10.5 2.2
4 20201104 11 10.1 11.6 3.3
5 20201105 11.7 11.7 11.6 9.7
6 20201106 11.3 10 13.1 10.4
7 20201107 10 14.1 14.4 11.9
You could wrap your prediction code in a function, and apply
it to each column:您可以将预测代码包装在 function 中, apply
其应用于每一列:
f <- function(d) {
hw_ts = ts(d, frequency = 365, start = c(2020, 305))
mod = auto.arima(hw_ts)
predict(mod)
}
predictions = apply(data[,-(1:2)],2,f)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.