0
$\begingroup$

I have 14 months(01/07/2018 to 30/08/2019) of one minute data, which I have aggregated to 10 mins block. So I have a data of dimension "61056 * 350". From this I am using 12 months of data to train the model and 2 months of data to validate it. I am using R version 3.6.0 to build my model.

I want to forecast the temperature for all 144 time points for next day using the data till previous day. Let's say I want to forecast temperature for 12/10/2019 (00:00 -23:59) using data till 10/10/2019 23:59. After building my model using data till 30/06/2019, how can I do that? I am using the following method to build my model.

library(data.table)
library(tseries)
library(astsa)
library(forecast)

#reading the dataset
dataset<-fread(file = "/Project/data/dataset.csv")

#unitroot test for the DV
adf.test(dataset$DV,alternative = "stationary" , k= trunc((nrow(dataset)-1)^(1/3)))
#gives strong evidence that the series is stationary

#separating the training and testing dataset
train<-dataset[as.Date(dataset$Time)<="2019-06-30",]
test<-dataset[as.Date(dataset$Time)>"2019-07-01",]

#converting the DV into a time series
y<-ts(train$DV,start = c(2018,7),frequency = 24*6)

#Fitting a tslm model to find out the important regressors for DV
tslm_fit<-tslm(y~as.matrix(train[,2:350]))
summary(tslm_fit)

#converting the regressors into a matrix of time series
xreg<-as.matrix(cbind(important vars selected from tslm fun))
names(xreg)<-names(variable names)

#fitting an auto.arima model
auto.arima(y,xreg = xreg,stepwise = F,allowdrift = F,trace = T)
fit<-Arima(y,xreg = xreg, order = c(2,0,2), seasonal = c(1,0,0))
#Forecasting for the test data
newregx<-as.matrix(cbind(same vars as train data))
pred<-forecast(fit,xreg = newxreg, h = nrow(newxreg), level = 97)


Sorry for taking so much of your time. Thanks for paying attention to this question.

EDIT: Removed two questions from this thread.

$\endgroup$
  • $\begingroup$ I think your questions are distinct enough so that they should be posted in separate threads. $\endgroup$ – Richard Hardy Oct 11 at 12:14
  • $\begingroup$ stats.stackexchange.com/search?q=user%3A3382+96+per should be of interest to you ...AND your three questions. $\endgroup$ – IrishStat Oct 11 at 16:10
  • $\begingroup$ Thank you for the suggestion. I'll do so. @Richard Hardy $\endgroup$ – Crystal Snow Oct 14 at 5:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.