Specify ic = aic - aic is the information criterion used to determine model.
Specify seasonality = F - no seasonal (repeating) pattern in the data.
Create Time Series (ts) and Model
Show the code
# create time series for forecastfemale_ts <-ts(med_mar$Females, freq=1, start=1947)# model data using auto.arima functionfemale_model <-auto.arima(female_ts, ic="aic", seasonal=F)
Female Model Forecast
Create forecasts (until 2040)
h = 19 indicates we want to forecast 17 years
Most recent year in data is 2023
2040 - 2023 - 17
Forecasts become less accurate the further into the future you specify.
Show the code
# create forecasts (until 2040)female_forecast <-forecast(female_model, h=17)# plot forecasts with 2 prediction interval bounds shownautoplot(female_forecast) +labs(y ="Median Age of First Marriage (Females)") +theme_classic()
Female Model Fit
Show the code
# examine numerical forecasts # and prediction intervalsfemale_forecast
Specify start = c(2001,1) - first year/Q in dataset
Model data using auto.arima function
Specify ic = aic - aic is the information criterion used to determine model.
Specify seasonality = T - seasonal (repeating) pattern is present in these data.
This chunk will create and save the model to be used below.
Create Time Series (ts) and Model
Show the code
# create time series for forecastak_res_ts <-ts(ak_res$Revenue, freq=4, start=c(2001, 1))# model data using auto.arima functionak_res_model <-auto.arima(ak_res_ts, ic="aic", seasonal=T)
AK Revenue Model Forecast
Create forecasts (until 2026)
h = 12 indicates we want to forecast 12 quarters
Most recent year in data is 2023
\(2026-2023=3\times4Qtrs. = 12Qtrs.\)
Note that forecasts become less accurate the further into the future you specify.
Show the code
# create forecasts (until end of 2024)ak_res_forecast <-forecast(ak_res_model, h=12)# plot forecasts with 2 prediction interval bounds shownautoplot(ak_res_forecast) +labs(y ="AK Resid. Elec. Revenue ($ Mill)") +theme_classic()
AK Revenue Model Fit
Show the code
# examine numerical forecasts # and prediction intervals# examine numerical forecasts # and prediction intervalsak_res_forecast