I have a large dataset consisting of 13, 513 temperature observations for a given city. I am trying to forecast the following month's daily temperatures (in other words, my goal is to forecast the following 30 observations). When removing seasonality, should I choose this based on a frequency of 365 days or 30 days?
Code:
## Setting Up Data
dta <- read.csv("data.csv", header = F)
values <- seq(from = as.Date("1993-01-01"), to = as.Date("2029-12-30"), by = 'day')
values <- format(values, format = "%m-%d")
dta$Date <- values
colnames(dta) <- c("Temp", "Date")
## Calculating Moving Averages
dta$cnt_ma <- ma(dta$Temp, order = 7) # Weekly
dta$cnt_ma30 <- ma(dta$Temp, order = 30) # Monthly
dta$cnt_ma365 <- ma(dta$Temp, order = 365) # Yearly
## Entering means for NA's
dta2 <- replace(dta, TRUE, lapply(dta, na.aggregate))
##### Removing Seasonality #####
count_ma <- ts(na.omit(dta2$Temp), frequency = 365)
decomp <- stl(count_ma, "periodic")
deseasonal_cnt <- seasadj(decomp)
plot(decomp)
## Test for Stationarity
adf.test(count_ma, alternative = "stationary")
Acf(count_ma, main = '')
Pacf(count_ma, main = '')
## Fitting Model via auto.arima
fit <- auto.arima(deseasonal_cnt, seasonal = F)
tsdisplay(residuals(fit), main = "(0,1,5) Model Residuals")
par(mfrow = c(1,1))
fcast <- forecast(fit, h = 30)
plot(fcast)