knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width=8 )
The forecastLM package provides a framework for forecasting regular time series data with a linear regression model. This vignette introduces the basic forecasting process with the package. The following vignettes cover advanced functionalities of the package.
Basic forecasting
library(forecastLM) data("ny_gas")
head(ny_gas) class(ny_gas)
library(TSstudio) ts_plot(ny_gas, title = "The New York Natural Gas Residential Monthly Consumption", Ytitle = "Million Cubic Feet", Xtitle = "Source: US Energy Information Administration (Jan 2020)")
md1 <- trainLM(input = ny_gas, y = "y", seasonal = "month", trend = list(linear = TRUE))
names(md1)
summary(md1$model)
plot_fit(md1)
plot_res(md1)
events <- list(outlier = c(as.Date("2015-01-01"), as.Date("2015-02-01"), as.Date("2018-01-01"), as.Date("2019-01-01")))
md2 <- trainLM(input = ny_gas, y = "y", seasonal = "month", trend = list(linear = TRUE), events = events)
plot_res(md2)
md3 <- trainLM(input = ny_gas, y = "y", seasonal = "month", trend = list(linear = TRUE), events = events, lags = c(1,12))
plot_res(md3)
fc3 <- forecastLM(md3, h = 60)
plot_fc(fc3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.