Title: | Time Series Regression Models with Distributed Lag Models |
---|---|
Description: | Provides time series regression models with one predictor using finite distributed lag models, polynomial (Almon) distributed lag models, geometric distributed lag models with Koyck transformation, and autoregressive distributed lag models. It also consists of functions for computation of h-step ahead forecasts from these models. See Demirhan (2020)(<doi:10.1371/journal.pone.0228812>) and Baltagi (2011)(<doi:10.1007/978-3-642-20059-5>) for more information. |
Authors: | Haydar Demirhan [aut, cre, cph]
|
Maintainer: | Haydar Demirhan <[email protected]> |
License: | GPL-3 |
Version: | 1.1.13 |
Built: | 2025-02-23 03:46:44 UTC |
Source: | https://github.com/cran/dLagM |
Provides time series regression models with one predictor using finite distributed lag models, polynomial (Almon) distributed lag models, geometric distributed lag models with Koyck transformation, and autoregressive distributed lag models. It also consists of functions for computation of h-step ahead forecasts from these models. See Demirhan (2020)(<doi:10.1371/journal.pone.0228812>) and Baltagi (2011)(<doi:10.1007/978-3-642-20059-5>) for more information.
Package: | dLagM |
Type: | Package |
Version: | 1.1.13 |
Date: | 2023-10-02 |
License: | GPL-3 |
To implement time series regression with finite distributed lag models, use dlm
function.
To implement time series regression with polynomial distributed lag models, use polyDlm
function.
To implement time series regression with geometric distributed lag models with Koyck transformation, use koyckDlm
function.
To implement time series regression with autoregressive distributed lag models, use ardlDlm
function.
To implement ARDL Bounds test, use ardlBound
function.
To produce forecasts for any of the models, use forecast
function.
To summarise the results of a model fitting, use summary
function.
Haydar Demirhan (https://orcid.org/0000-0002-8565-4710)
Maintainer: Haydar Demirhan <[email protected]>
Acknowledgements: The author acknowledges the testing effort of of Dr. Rogerio Porto (https://orcid.org/0000-0002-6663-9531) on forecasting function.
B.H. Baltagi. Econometrics, Fifth Ed. Springer, 2011.
H. Demirhan. dLagM: An R package for distributed lag models and ARDL bounds testing. PLoS ONE, 15(2): e0228812, 2020. DOI: 10.1371/journal.pone.0228812.
R.C. Hill, W.E. Griffiths, G.G. Judge. Undergraduate Econometrics. Wiley, 2000.
J. Soren, A.Q. Philips. "pss: Perform bounds test for cointegration and perform dynamic simulations."
P.K. Narayan. The Saving and Investment Nexus for China: Evidence from cointegration tests. Applied Economics 37(17):1979-1990, 2005.
M.H. Pesaran, S. Yongcheol, R.J. Smith. Bounds testing approaches to the analysis of level relationships. Journal of Applied Econometrics 16(3):289-326, 2001.
dlm
, polyDlm
, koyckDlm
, ardlDlm
# --- For examples, please refer to specific functions ---
# --- For examples, please refer to specific functions ---
Applies ARDL bounds test with the approach of Pesaran et al. (2001).
ardlBound(data = NULL, formula = NULL, case = 3, p = NULL, remove = NULL, autoOrder = FALSE, HAC = FALSE, ic = c("AIC", "BIC", "MASE", "GMRAE"), max.p = 15, max.q = 15, ECM = TRUE, stability = TRUE)
ardlBound(data = NULL, formula = NULL, case = 3, p = NULL, remove = NULL, autoOrder = FALSE, HAC = FALSE, ic = c("AIC", "BIC", "MASE", "GMRAE"), max.p = 15, max.q = 15, ECM = TRUE, stability = TRUE)
data |
A |
formula |
A |
case |
An integer up to 5 showing the case number. See details. |
p |
An integer representing the order of short-run response or a |
remove |
A list showing the elements to be removed from the model. It includes elements |
autoOrder |
If |
HAC |
If |
ic |
Information criterion to be used in the search for optimal orders. |
max.p |
Maximum order for the short-run coefficients. |
max.q |
Maximum auto-regressive order. |
ECM |
If |
stability |
If both |
The argument case
takes the values 1 for "no intercept, no trend", 2 for "restricted intercept, no trend", 3 for "unrestricted intercept, no trend",
4 for "unrestricted intercept, restricted trend", and 5 for "unrestricted intercept, unrestricted trend."
If the argument p
is entered as an integer, the same value is used to specify the order of short-run response for all variables.
We follow the formulation of Pesaran et al. (2001). So, the upper limit of summations in the model formulation goes up to (p-1). User should consider this while setting the value(s) of p
.
The names of the element p
of remove
must match with those in the model. For example, to remove lags 2 and 4 of the first differences of X1 and X2 and remove the lags 2 and 5 of the dependent series, remove
should be defined as remove = list( p = list(dX1 = c(2,4), dX2 = c(2,4)), q = c(2,5) )
.
Breusch-Godfrey and Ljung-Box tests are applied to test against the existence of autocorrelations in residuals and Breusch-Pagan test is applied to detect heteroskedasticity in residuals as a part of the bounds testing procedure. Ramsey's RESET test is conducted for correctness of functional form of the model.
The recursive CUSUM chart is plotted by epf
function from the strucchange
package. The recursive CUSUM of squares plot is plotted by the ardlBound
function using the recursive residuals generated by recresid
function of strucchange
package. The testing limits on the recursive CUSUM of squares plot are calculated as described by Brown et al. (1975) based in Table 1 of Durbin (1969). The recursive MOSUM chart is plotted when there is no NA MOSUM values are calculated.
model |
An object including the fitted model under the null and alternative hypotheses. |
F.stat |
The value of F-statistic coming out of the Wald test. |
p |
p-orders in the lag structure. |
k |
The number of independent series. |
bg |
Breusch-Godfrey test results. Returns |
lb |
Ljung-Box test results. Returns |
bp |
Breusch-Pagan test results. Returns |
sp |
Shapiro-Wilk test results. Returns |
ECM |
A list including the error correction series in the element |
ARDL.model |
A model object including the fitted ARDL model. Use this model object to display the long-run coefficients. To see the significance test results for the logn-run coefficients, use |
Haydar Demirhan
Maintainer: Haydar Demirhan <[email protected]>
R.L. Brown, J. Durbin, J. M. Evans. Techniques for testing the constancy of regression relationships over time. Journal of the Royal Statistical Society - Series B, 37, 2, 149-192.
C-S. J. Chu, K. Hornik, C-M. Kuan. MOSUM tests for parameter constancy. Biometrika, 82, 603-617, 1995.
J. Durbin. Tests for serial correlation in regression analysis based on the periodogram of Least-Squares residuals. Biometrika, 56, 1, 1-15.
P.K. Narayan. The Saving and Investment Nexus for China: Evidence from Cointegration Tests. Applied Economics 37(17):1979-1990, 2005.
M.H. Pesaran, S. Yongcheol, R.J. Smith. Bounds testing approaches to the analysis of level relationships. Journal of Applied Econometrics 16(3):289-326, 2001.
J.B. Ramsey. Tests for specification error in classical linear Least Squares regression analysis. Journal of the Royal Statistical Society - Series B, 31, 350-371, 1969.
J. Soren, A.Q. Philips. "pss: Perform bounds test for cointegration and perform dynamic simulations."
A. Zeileis, F. Leisch, K. Hornik, C. Kleiber. strucchange: An R package for testing for structural change in linear regression models. Journal of Statistical Software, 7, 1-38, 2002.
## Not run: data(M1Germany) data <- M1Germany[1:144,] model <- ardlBound(data = data , formula = logprice ~ interest + logm1 , case = 2 , p = 2) # Let ardlBoundOrders() function find the orders model <- ardlBound(data = data , formula = logprice ~ interest + logm1 , case = 2 , max.p = 3, max.q = 3) ## End(Not run)
## Not run: data(M1Germany) data <- M1Germany[1:144,] model <- ardlBound(data = data , formula = logprice ~ interest + logm1 , case = 2 , p = 2) # Let ardlBoundOrders() function find the orders model <- ardlBound(data = data , formula = logprice ~ interest + logm1 , case = 2 , max.p = 3, max.q = 3) ## End(Not run)
Computes optimal orders (lag structure) for the short-run relationships and autoregressive part of the ARDL model prior to ARDL bounds test with the approach of Pesaran et al. (2001).
ardlBoundOrders(data = NULL , formula = NULL, ic = c("AIC", "BIC", "MASE", "GMRAE"), max.p = 15, max.q = 15, FullSearch = FALSE )
ardlBoundOrders(data = NULL , formula = NULL, ic = c("AIC", "BIC", "MASE", "GMRAE"), max.p = 15, max.q = 15, FullSearch = FALSE )
data |
A |
formula |
A |
ic |
Information criterion to be used in the serach for optimal orders. |
max.p |
Maximum order for the short-run coefficients. |
max.q |
Maximum auto-regressive order. |
FullSearch |
If |
If FullSearch = FALSE
, this function first assumes that all p-orders are equal for the short-run relationships and finds the optimal p-order and autoregressive orders. Then, it finds the best subset of p-orders allowing them to change for each series in the short-run relationship part of the ARDL model under alternative hypothesis of ARDL bounds test.
p |
An |
q |
The autoregressive order. |
Stat.table |
The selected statistic of all the considered models where all short-run relationship orders (p-orders) are equal. |
Stat.p |
The selected statistic of all possible combinations of short-run relationship orders (p-orders). The reported lag structure is the one that gives the minimum value to the chosen statistic among these combinations. |
Haydar Demirhan
Maintainer: Haydar Demirhan <[email protected]>
Applies autoregressive distributed lag models of order (p , q) with one predictor.
ardlDlm(formula = NULL , data = NULL , x = NULL , y = NULL , p = 1 , q = 1 , remove = NULL , type = NULL )
ardlDlm(formula = NULL , data = NULL , x = NULL , y = NULL , p = 1 , q = 1 , remove = NULL , type = NULL )
formula |
A |
data |
A |
x |
A vector including the observations of predictor time series. This is not restricted to |
y |
A vector including the observations of dependent time series. This is not restricted to |
p |
An integer representing finite lag length. |
q |
An integer representing the order of autoregressive process. |
remove |
A list object having two elements showing the lags of independent series with |
type |
An integer taking 1 if only x and y vectors are entered, 2 if a formula and data matrix is entered. It can be left |
The autoregressive DLM is a flexible and parsimonious infinite distributed lag model. The model ARDL is written as
When there is only one predictor series, both of model
and formula
objects can be used. But when they are supplied, both x
and y
arguments should be NULL
.
The variable names in formula
must match with the names of variables in data
argument and it must be in the form of a generic formula for R functions.
The argument data
contains dependent series and independent series.
The argument remove = list(p = list() , q = c())
is used to specify which lags of each independent series and the autoregressive lags of dependent series will be removed from the full model. Each element of the list p
shows particular lags that will be removed from each independent series. To remove the main series from the model or to fit a model ARDL(0,q), include 0
within the elements of p
. The element q
is just a vector showing the autoregressive lags of dependent series to be removed.
To remove the intercept from the model, if a formula
is entered, just include "-1" in the model formula. Otherwise, include "-1" in the element q
of the list remove
. See the examples below for implementation details.
The standard function summary()
prints model summary for the model of interest.
model |
An object of class |
order |
A vector composed of |
removed.p |
A list or vector showing the lags of independent series to be removed from the full model. |
removed.q |
A vector showing the autoregressive lags to be removed from the full model. |
formula |
Model formula of the fitted model. This is returned if multiple independent series are entered. |
data |
A |
Haydar Demirhan
Maintainer: Haydar Demirhan <[email protected]>
B.H. Baltagi. Econometrics, Fifth Ed. Springer, 2011.
R.C. Hill, W.E. Griffiths, G.G. Judge. Undergraduate Econometrics. Wiley, 2000.
# Only one independent series data(seaLevelTempSOI) model.ardl = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p = 1 , q = 1 ) summary(model.ardl) # residuals(model.ardl) # coef(model.ardl) # fitted(model.ardl) # Remove some lags rem.p = c(0,1) # 0 removes the main effect of X.t rem.q = c(1,3) remove = list(p = rem.p , q = rem.q) model.ardl = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p = 2 , q = 3 , remove = remove) summary(model.ardl) # To remove intercept as well rem.q = c(1,3,-1) remove = list(p = rem.p , q = rem.q) model.ardl = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p = 2 , q = 3 , remove = remove) summary(model.ardl) # Multiple independent series data(M1Germany) data = M1Germany[1:144,] model.ardlDlm = ardlDlm(formula = logprice ~ interest + logm1, data = data.frame(data) , p = 2 , q = 1 ) summary(model.ardlDlm) # To remove intercept as well model.ardlDlm = ardlDlm(formula = logprice ~ -1 + interest + logm1, data = data.frame(data) , p = 2 , q = 1 ) summary(model.ardlDlm) rem.p = list(interest = c(0,2) , logm1 = c(0)) # Remove the main series of interest and logm1 and the secont lag of # interest from the model rem.q = c(1) remove = list(p = rem.p , q = rem.q) remove model.ardlDlm = ardlDlm(formula = logprice ~ interest + logm1, data = data.frame(data) , p = 2 , q = 2 , remove = remove) summary(model.ardlDlm)
# Only one independent series data(seaLevelTempSOI) model.ardl = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p = 1 , q = 1 ) summary(model.ardl) # residuals(model.ardl) # coef(model.ardl) # fitted(model.ardl) # Remove some lags rem.p = c(0,1) # 0 removes the main effect of X.t rem.q = c(1,3) remove = list(p = rem.p , q = rem.q) model.ardl = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p = 2 , q = 3 , remove = remove) summary(model.ardl) # To remove intercept as well rem.q = c(1,3,-1) remove = list(p = rem.p , q = rem.q) model.ardl = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p = 2 , q = 3 , remove = remove) summary(model.ardl) # Multiple independent series data(M1Germany) data = M1Germany[1:144,] model.ardlDlm = ardlDlm(formula = logprice ~ interest + logm1, data = data.frame(data) , p = 2 , q = 1 ) summary(model.ardlDlm) # To remove intercept as well model.ardlDlm = ardlDlm(formula = logprice ~ -1 + interest + logm1, data = data.frame(data) , p = 2 , q = 1 ) summary(model.ardlDlm) rem.p = list(interest = c(0,2) , logm1 = c(0)) # Remove the main series of interest and logm1 and the secont lag of # interest from the model rem.q = c(1) remove = list(p = rem.p , q = rem.q) remove model.ardlDlm = ardlDlm(formula = logprice ~ interest + logm1, data = data.frame(data) , p = 2 , q = 2 , remove = remove) summary(model.ardlDlm)
Applies distributed lag models with one or multiple predictor(s).
dlm(formula , data , x , y , q , remove , type)
dlm(formula , data , x , y , q , remove , type)
formula |
A |
data |
A |
x |
A vector including the observations of predictor time series. This is not restricted to |
y |
A vector including the observations of dependent time series. This is not restricted to |
q |
An integer representing finite lag length. |
remove |
A list object showing the lags to be removed from the model for each independent series in its elements. Please see the details for the construction of this argument. |
type |
An integer taking 1 if only x and y vectors are entered, 2 if a formula and data matrix is entered. It can be left |
When a decision made on a variable, some of the related variables would be effected through time. For example, when income tax rate is increased, this would reduce expenditures of consumers on goods and services, which reduces profits of suppliers, which reduces the demand for productive inputs, which reduces the profits of the input suppliers, and so on (Judge and Griffiths, 2000). These effects occur over the future time periods; hence, they are distributed across the time.
In a distributed-lag model, the effect of an independent variable on a dependent variable
occurs over the time. Therefore, DLMs are dynamic models. A linear finite DLM with one independent variable is written as follows:
where is a stationary error term with
.
When there is only one predictor series, both of model
and formula
objects can be used. But when they are supplied, both x
and y
arguments should be NULL
.
The variable names in formula
must match with the names of variables in data
argument and it must be in the form of a generic formula for R functions.
The argument data
contains dependent series and independent series. Required lags of dependent series are generated by the dlm
function automatically.
The argument remove = list()
is used to specify which lags will be removed from the full model. Each element of the list remove
shows particular lags that will be removed from each independent series. Notice that it is possible to fit a model with different lag lengths for each independent series by removing the appropriate lags of independent series with remove
argument. To remove the main series from the model include 0
within the elements of remove
.
To remove the intercept from the model, if a formula
is entered, just include "-1" in the model formula. Otherwise, include "-1" in the element remove
of the list remove
. See the examples below for implementation details.
The standard function summary()
prints model summary for the model of interest.
model |
An object of class |
designMatrix |
The design matrix composed of transformed z-variables. |
k |
The number of independent series. This is returned if multiple independent series are entered. |
q |
The lag length. |
removed |
A list or vector showing the removed lags from the model for independent series. Returns |
formula |
Model formula of the fitted model. This is returned if multiple independent series are entered. |
data |
A |
Haydar Demirhan
Maintainer: Haydar Demirhan <[email protected]>
B.H. Baltagi. Econometrics, Fifth Ed. Springer, 2011.
R.C. Hill, W.E. Griffiths, G.G. Judge. Undergraduate Econometrics. Wiley, 2000.
# Only one independent series data(seaLevelTempSOI) model.dlm = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 5) summary(model.dlm) residuals(model.dlm) coef(model.dlm) fitted(model.dlm) removed = list(x = c(1)) model.dlm = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 5, remove = removed) summary(model.dlm) # Remove intercept as well removed = list(x = c(1,-1)) model.dlm = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 5, remove = removed) summary(model.dlm) removed = list(x = c(0,1)) model.dlm = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 5, remove = removed) summary(model.dlm) model.dlm = dlm(formula = GMSL ~ LandOcean , data = seaLevelTempSOI , q = 5) summary(model.dlm) removed = list(x = c(0,1)) model.dlm = dlm(formula = GMSL ~ LandOcean , data = seaLevelTempSOI , q = 5, remove = removed) summary(model.dlm) # Remove intercept as well removed = list(x = c(0,-1)) model.dlm = dlm(formula = GMSL ~ LandOcean , data = seaLevelTempSOI , q = 2, remove = removed) summary(model.dlm) # Multiple independent series data(M1Germany) data = M1Germany[1:144,] model.dlm = dlm(formula = logprice ~ interest + logm1, data = data.frame(data) , q = 4) summary(model.dlm) removed = list(interest = c(1,3), logm1 = c(2)) removed model.dlm = dlm(formula = logprice ~ interest + logm1, data = data.frame(data) , q = 4 , remove = removed) summary(model.dlm) removed = list(interest = c(0,1,3), logm1 = c(0,2)) removed model.dlm = dlm(formula = logprice ~ interest + logm1, data = data.frame(data) , q = 4 , remove = removed) summary(model.dlm) removed = list( logm1 = c(1,2)) removed model.dlm = dlm(formula = logprice ~ interest + logm1, data = data.frame(data) , q = 4 , remove = removed) summary(model.dlm)
# Only one independent series data(seaLevelTempSOI) model.dlm = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 5) summary(model.dlm) residuals(model.dlm) coef(model.dlm) fitted(model.dlm) removed = list(x = c(1)) model.dlm = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 5, remove = removed) summary(model.dlm) # Remove intercept as well removed = list(x = c(1,-1)) model.dlm = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 5, remove = removed) summary(model.dlm) removed = list(x = c(0,1)) model.dlm = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 5, remove = removed) summary(model.dlm) model.dlm = dlm(formula = GMSL ~ LandOcean , data = seaLevelTempSOI , q = 5) summary(model.dlm) removed = list(x = c(0,1)) model.dlm = dlm(formula = GMSL ~ LandOcean , data = seaLevelTempSOI , q = 5, remove = removed) summary(model.dlm) # Remove intercept as well removed = list(x = c(0,-1)) model.dlm = dlm(formula = GMSL ~ LandOcean , data = seaLevelTempSOI , q = 2, remove = removed) summary(model.dlm) # Multiple independent series data(M1Germany) data = M1Germany[1:144,] model.dlm = dlm(formula = logprice ~ interest + logm1, data = data.frame(data) , q = 4) summary(model.dlm) removed = list(interest = c(1,3), logm1 = c(2)) removed model.dlm = dlm(formula = logprice ~ interest + logm1, data = data.frame(data) , q = 4 , remove = removed) summary(model.dlm) removed = list(interest = c(0,1,3), logm1 = c(0,2)) removed model.dlm = dlm(formula = logprice ~ interest + logm1, data = data.frame(data) , q = 4 , remove = removed) summary(model.dlm) removed = list( logm1 = c(1,2)) removed model.dlm = dlm(formula = logprice ~ interest + logm1, data = data.frame(data) , q = 4 , remove = removed) summary(model.dlm)
Fits finite DLMs for a range of lag lengths and orders the fitted models according to a desired measure.
finiteDLMauto(formula , data, x, y, q.min = 1, q.max = 10, k.order = NULL, model.type = c("dlm","poly"), error.type = c("MASE","AIC", "BIC","GMRAE", "MBRAE", "radj"), trace = FALSE , type)
finiteDLMauto(formula , data, x, y, q.min = 1, q.max = 10, k.order = NULL, model.type = c("dlm","poly"), error.type = c("MASE","AIC", "BIC","GMRAE", "MBRAE", "radj"), trace = FALSE , type)
formula |
A |
data |
A |
x |
A vector including the observations of predictor time series. This is not restricted to |
y |
A vector including the observations of dependent time series. This is not restricted to |
q.min |
An integer representing the lower limit of the range of lag lengths to be considered. If missing, it will be set to 1. |
q.max |
An integer representing the upper limit of the range of lag lengths to be considered. If missing, it will be set to 10. |
k.order |
An integer representing order of polynomial distributed lags. |
model.type |
The type of model to be fitted. If set to |
error.type |
The type of goodness-of-fit measure to be used for the selection of optimal lag length. The optimal lag length is determined according to desired goodness-of-fit measure. |
trace |
If |
type |
An integer taking 1 if only x and y vectors are entered, 2 if a formula and data matrix is entered. It can be left |
When there is only one predictor series, both of model
and formula
objects can be used. But when they are supplied, both x
and y
arguments should be NULL
.
The variable names in formula
must match with the names of variables in data
argument and it must be in the form of a generic formula for R functions.
The argument data
contains dependent series and independent series. Required lags of dependent series are generated by the dlm
function automatically.
If q.max
is entered greater than the length of the series, its value will be adjusted to have the length of the series for fitting the regression model.
Returns a data.frame
including the values of goodness-of-fit measures and corresponding lag lengths.
Agung Andiojaya <[email protected]>, Haydar Demirhan
Maintainer: Haydar Demirhan <[email protected]>
## Not run: library(dLagM) # Multiple independent series data(M1Germany) data = M1Germany[1:44,] # Run the search over finite DLMs according to AIC values finiteDLMauto(formula = logprice ~ interest + logm1, data = data.frame(data), q.min = 2, q.max = 5, model.type = "dlm", error.type = "AIC", trace = FALSE) ## End(Not run)
## Not run: library(dLagM) # Multiple independent series data(M1Germany) data = M1Germany[1:44,] # Run the search over finite DLMs according to AIC values finiteDLMauto(formula = logprice ~ interest + logm1, data = data.frame(data), q.min = 2, q.max = 5, model.type = "dlm", error.type = "AIC", trace = FALSE) ## End(Not run)
Computes forecasts for the finite distributed lag models, autoregressive distributed lag models, Koyck transformation of distributed lag models, and polynomial distributed lag models.
forecast(model , x , h = 1 , interval = FALSE, level = 0.95 , nSim = 500)
forecast(model , x , h = 1 , interval = FALSE, level = 0.95 , nSim = 500)
model |
A fitted model by one of |
x |
A vector or matrix including the new observations of independent time series. This is not restricted to |
h |
The number of ahead forecasts. |
interval |
If |
level |
Confidence level of prediction interval. |
nSim |
An integer showing the number of Monte Carlo simulations used to compute prediction intervals for forecasts. |
This function directly uses the model formula and estimates of model coefficients to find forecast one-by-one starting from the one-step ahead forecast.
Prediction intervals are found by the Monte Carlo approach using a Gaussian error distribution with zero mean and empirical variance of the dependent series.
When the model
argument includes multiple independent series, x
must be entered as a matrix including the new observations of each independent series in its rows. The number of columns of x
must be equal to the forecast horizon h
and the rows of x
must match with the independent series in the order they appear in the data
.
When x
and y
are used to fit the model and some elements of the model are removed, you must use model
and formula
instead of x
and y
to fit the model and send the new data as a matrix into the forecast() function.
This function can still be used when some of the lags of independent series are removed from the model.
forecasts |
A vector including forecasts. |
Haydar Demirhan
Maintainer: Haydar Demirhan <[email protected]>
## Not run: # Only one independent series data(seaLevelTempSOI) #--- ARDL dlm --- model.ardl = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p = 1 , q = 1 ) forecast(model = model.ardl , x = c(0.15, 0.45) , h = 2 , interval = FALSE) forecast(model = model.ardl , x = c(0.15, 0.45, 0.20) , h = 3 , interval = FALSE) # Multiple independent series data(M1Germany) data = M1Germany[1:144,] model.ardlDlm1 = ardlDlm(formula = logprice ~ interest + logm1, data = data.frame(data) , p = 2 , q = 1 ) x.new = matrix(c(0.07 , 9.06 , 0.071 , 9.09, 0.08, 9.2), ncol = 3, nrow = 2) forecast(model = model.ardlDlm1 , x = x.new , h = 3 , interval = TRUE, nSim = 100) rem.p = list(interest = c(1,2)) rem.q = c(1) remove = list(p = rem.p , q = rem.q) model.ardlDlm2 = ardlDlm(formula = logprice ~ interest + logm1, data = data.frame(data) , p = 2 , q = 2 , remove = remove) forecast(model = model.ardlDlm2 , x = x.new , h = 2 , interval = FALSE) #--- Finite dlm --- model.dlm = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q = 2) forecast(model = model.dlm , x = c(0.15, 0.45, 0.20) , h = 3) # Multiple independent series model.dlm = dlm(formula = logprice ~ interest + logm1, data = data.frame(data) , q = 4) x.new = matrix(c(0.07 , 9.06 , 0.071 , 9.09), ncol = 2, nrow = 2) forecast(model = model.dlm , x = x.new , h = 2 , interval = FALSE) # Some lags are removed: # Remove lags 0 and 2 from "interest" and # lags 1 and 3 from "logm1" removed = list(interest = c(0,2), logm1 = c(1,3)) removed model.dlm = dlm(formula = logprice ~ interest + logm1 -1, data = data.frame(data) , q = 4 , remove = removed) x.new = matrix(c(0.07 , 9.06 , 0.071 , 9.09 , 0.079 , 9.19 , 0.069 , 9.21) , ncol = 4, nrow = 2) forecast(model = model.dlm , x = x.new , h = 4 , interval = FALSE) forecast(model = model.dlm , x = x.new , h = 4 , interval = FALSE) x.new = matrix(c(0.07 , 9.06 , 0.071 , 9.09, 0.08 , 9.12), ncol = 3, nrow = 2) forecast(model = model.dlm , x = x.new , h = 3, interval = FALSE) #--- Koyck dlm --- model.koyck = koyckDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL) forecast(model = model.koyck , x = c(0.15, 0.45, 0.20), h = 3 , interval = FALSE) #--- Polynomial dlm --- model.poly = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q = 2 , k = 2 , show.beta = TRUE) forecast(model = model.poly , x = c(0.15, 0.45) , h = 1 , interval = FALSE) ## End(Not run)
## Not run: # Only one independent series data(seaLevelTempSOI) #--- ARDL dlm --- model.ardl = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p = 1 , q = 1 ) forecast(model = model.ardl , x = c(0.15, 0.45) , h = 2 , interval = FALSE) forecast(model = model.ardl , x = c(0.15, 0.45, 0.20) , h = 3 , interval = FALSE) # Multiple independent series data(M1Germany) data = M1Germany[1:144,] model.ardlDlm1 = ardlDlm(formula = logprice ~ interest + logm1, data = data.frame(data) , p = 2 , q = 1 ) x.new = matrix(c(0.07 , 9.06 , 0.071 , 9.09, 0.08, 9.2), ncol = 3, nrow = 2) forecast(model = model.ardlDlm1 , x = x.new , h = 3 , interval = TRUE, nSim = 100) rem.p = list(interest = c(1,2)) rem.q = c(1) remove = list(p = rem.p , q = rem.q) model.ardlDlm2 = ardlDlm(formula = logprice ~ interest + logm1, data = data.frame(data) , p = 2 , q = 2 , remove = remove) forecast(model = model.ardlDlm2 , x = x.new , h = 2 , interval = FALSE) #--- Finite dlm --- model.dlm = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q = 2) forecast(model = model.dlm , x = c(0.15, 0.45, 0.20) , h = 3) # Multiple independent series model.dlm = dlm(formula = logprice ~ interest + logm1, data = data.frame(data) , q = 4) x.new = matrix(c(0.07 , 9.06 , 0.071 , 9.09), ncol = 2, nrow = 2) forecast(model = model.dlm , x = x.new , h = 2 , interval = FALSE) # Some lags are removed: # Remove lags 0 and 2 from "interest" and # lags 1 and 3 from "logm1" removed = list(interest = c(0,2), logm1 = c(1,3)) removed model.dlm = dlm(formula = logprice ~ interest + logm1 -1, data = data.frame(data) , q = 4 , remove = removed) x.new = matrix(c(0.07 , 9.06 , 0.071 , 9.09 , 0.079 , 9.19 , 0.069 , 9.21) , ncol = 4, nrow = 2) forecast(model = model.dlm , x = x.new , h = 4 , interval = FALSE) forecast(model = model.dlm , x = x.new , h = 4 , interval = FALSE) x.new = matrix(c(0.07 , 9.06 , 0.071 , 9.09, 0.08 , 9.12), ncol = 3, nrow = 2) forecast(model = model.dlm , x = x.new , h = 3, interval = FALSE) #--- Koyck dlm --- model.koyck = koyckDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL) forecast(model = model.koyck , x = c(0.15, 0.45, 0.20), h = 3 , interval = FALSE) #--- Polynomial dlm --- model.poly = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q = 2 , k = 2 , show.beta = TRUE) forecast(model = model.poly , x = c(0.15, 0.45) , h = 1 , interval = FALSE) ## End(Not run)
Computes mean absolute error (MAE), mean squared error (MSE), mean percentage error (MPE), symmetric mean absolute percentage error (sMAPE), mean absolute percentage error (MAPE), mean absolute scaled error (MASE), mean relative absolute error (MRAE), geometric mean relative absolute error (GMRAE), mean bounded relative absolute error (MBRAE), unscaled MBRAE (UMBRAE) for distributed lag models.
GoF(model, ...) MASE(model, ...) sMAPE(model, ...) MAPE(model, ...) MRAE(model, ...) GMRAE(model, ...) MBRAE(model, ...)
GoF(model, ...) MASE(model, ...) sMAPE(model, ...) MAPE(model, ...) MRAE(model, ...) GMRAE(model, ...) MBRAE(model, ...)
model |
Model object fitted for time series data. |
... |
Optionally, more fitted models. |
See Chen et al. (2017) for the definitions of MSE, MAE, MAPE, sMAPE, MRAE, GMRAE, MBRAE, UMBMRAE.
Let be the one-step-ahead forecast error. Then, a scaled error is defined as
which is independent of the scale of the data. Mean absolute scaled error is defined as
(Hyndman and Koehler, 2006).
Fitted models would be finite, polynomial, Koyck, ARDL DLMs, or linear model fitted with lm()
function. This function also computes MASE values of multiple models when fed at the same time.
Haydar Demirhan
Maintainer: Haydar Demirhan <[email protected]>
Chen, C., Twycross, J., Garibaldi, J.M. (2017). A new accuracy measure based on bounded relative error for time series forecasting. PLoS ONE, 12(3), e0174202.
Hyndman, R.J. and Koehler, A.B. (2006). Another look at measures of forecast accuracy. International Journal of Forecasting, 22, 679-688.
## Not run: data(seaLevelTempSOI) # Fit a bunch of polynomial DLMs model.poly1 = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q = 2 , k = 2 , show.beta = TRUE) model.poly2 = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q = 3 , k = 2 , show.beta = TRUE) model.poly3 = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q = 4 , k = 2 , show.beta = TRUE) MASE(model.poly1, model.poly2, model.poly3) # Fit a bunch of finite DLMs model.dlm1 = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q =2) model.dlm2 = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q =3) model.dlm3 = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q =4) MASE(model.dlm1, model.dlm2, model.dlm3) MBRAE(model.dlm1, model.dlm2, model.dlm3) GoF(model.dlm1, model.dlm2, model.dlm3) # Fit a linear model model.lm = lm(GMSL ~ LandOcean , data = seaLevelTempSOI) MASE(model.lm) GoF(model.lm) # Fit a Koyck model model.koyck = koyckDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL) MASE(model.koyck) GoF(model.koyck) # Fit a bunch of ARDLs model.ardl1 = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p=1, q=2) model.ardl2 = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p=2, q=2) model.ardl3 = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p=3, q=2) MASE(model.ardl1 , model.ardl2 , model.ardl3) GoF(model.ardl1 , model.ardl2 , model.ardl3) # Find MASEs of different model objects MASE(model.ardl1 , model.dlm1 , model.poly1, model.lm) GoF(model.ardl1 , model.dlm1 , model.poly1, model.lm) ## End(Not run)
## Not run: data(seaLevelTempSOI) # Fit a bunch of polynomial DLMs model.poly1 = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q = 2 , k = 2 , show.beta = TRUE) model.poly2 = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q = 3 , k = 2 , show.beta = TRUE) model.poly3 = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q = 4 , k = 2 , show.beta = TRUE) MASE(model.poly1, model.poly2, model.poly3) # Fit a bunch of finite DLMs model.dlm1 = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q =2) model.dlm2 = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q =3) model.dlm3 = dlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, q =4) MASE(model.dlm1, model.dlm2, model.dlm3) MBRAE(model.dlm1, model.dlm2, model.dlm3) GoF(model.dlm1, model.dlm2, model.dlm3) # Fit a linear model model.lm = lm(GMSL ~ LandOcean , data = seaLevelTempSOI) MASE(model.lm) GoF(model.lm) # Fit a Koyck model model.koyck = koyckDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL) MASE(model.koyck) GoF(model.koyck) # Fit a bunch of ARDLs model.ardl1 = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p=1, q=2) model.ardl2 = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p=2, q=2) model.ardl3 = ardlDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL, p=3, q=2) MASE(model.ardl1 , model.ardl2 , model.ardl3) GoF(model.ardl1 , model.ardl2 , model.ardl3) # Find MASEs of different model objects MASE(model.ardl1 , model.dlm1 , model.poly1, model.lm) GoF(model.ardl1 , model.dlm1 , model.poly1, model.lm) ## End(Not run)
This data set is composed of annual world total CO2 emissions, oats, corn, rice, and wheat production, cropland area, and annual average temperature anomalies series between 1961 and 2018.
data(grainProduction)
data(grainProduction)
Multiple time series
CO2(Tons)
column shows the global mean annual carbon dioxide (CO2) emissions measured in tons.
Land-OceanTempIndex(C)
column shows the land-ocean temperature index without smoothing.
Cropland(1Mha)
column shows the annual cropland area in the world scale in million hectares.
Oats(1Mt)
column shows the annual world oats production in million tons.
Corn(1Mt)
column shows the annual world corn production in million tons.
Rice(1Mt)
column shows the annual world rice production in million tons.
Wheat(1Mt)
column shows the annual world wheat production in million tons.
CO2 emissions data: Hannah Ritchie and Max Roser (2020) - "CO2 and Greenhouse Gas Emissions". Published online at OurWorldInData.org.
Temperature anomalies data: NASA
Grain production data: United States Department of Agriculture, Foreign Agricultural Service
Cropland data: Food and Agriculture Organization of United Nations
CO2 emissions data: https://ourworldindata.org/co2-and-other-greenhouse-gas-emissions
Temperature anomalies: https://climate.nasa.gov/vital-signs/global-temperature/
Grain production data: psd_grains_pulses.csv from https://apps.fas.usda.gov/psdonline/app/index.html#/app/downloads
Cropland data: https://www.fao.org/faostat/en/#data/RL/visualize
data(grainProduction) oatsProduction.ts = ts(grainProduction[,5], start = 1961) plot(oatsProduction.ts, main="Time series plot of world oats production series.")
data(grainProduction) oatsProduction.ts = ts(grainProduction[,5], start = 1961) plot(oatsProduction.ts, main="Time series plot of world oats production series.")
Applies distributed lag models with Koyck transformation with one predictor.
koyckDlm(x , y , intercept)
koyckDlm(x , y , intercept)
x |
A vector including the observations of predictor time series. This is not restricted to |
y |
A vector including the observations of dependent time series. This is not restricted to |
intercept |
Set to |
To deal with infinite DLMs, we can use the Koyck transformation. When we apply Koyck transformation, we get the following:
When we solve this equation for , we obtain Koyck DLM as follows:
where and the random error after the transformation is
(Judge and Griffiths, 2000).
Then, instrumental variables estimation is employed to fit the model.
The standard function summary()
prints model summary for the model of interest.
AIC/BIC of a fitted KOyck model is displayed by setting the class
attribute of model to lm
. See the example.
model |
An object of class |
geometric.coefficients |
A vector composed of corresponding geometric distributed lag model coefficients. |
Haydar Demirhan
Maintainer: Haydar Demirhan <[email protected]>
B.H. Baltagi. Econometrics, Fifth Ed. Springer, 2011.
R.C. Hill, W.E. Griffiths, G.G. Judge. Undergraduate Econometrics. Wiley, 2000.
data(seaLevelTempSOI) model.koyck = koyckDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL) summary(model.koyck, diagnostics = TRUE) residuals(model.koyck) coef(model.koyck) fitted(model.koyck) AIC(model.koyck) BIC(model.koyck)
data(seaLevelTempSOI) model.koyck = koyckDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL) summary(model.koyck, diagnostics = TRUE) residuals(model.koyck) coef(model.koyck) fitted(model.koyck) AIC(model.koyck) BIC(model.koyck)
Applies polynomial distributed lag models with one predictor.
polyDlm(x , y , q , k , show.beta = TRUE)
polyDlm(x , y , q , k , show.beta = TRUE)
x |
A vector including the observations of predictor time series. This is not restricted to |
y |
A vector including the observations of dependent time series. This is not restricted to |
q |
An integer representing finite lag length. |
k |
An integer representing order of polynomial distributed lags. |
show.beta |
If |
Finite distributed lag models, in general, suffer from the multicollinearity due to inclusion of the lags of the same variable in the model. To reduce the impact of this multicollinearity, a polynomial shape is imposed on the lag distribution (Judge and Griffiths, 2000). The resulting model is called Polynomial Distributed Lag model or Almond Distributed Lag Model.
Imposing a polynomial pattern on the lag distribution is equivalent to representing parameters with another $k$th order polynomial model of time. So, the effect of change in
on the expected value of
is represented as follows:
where (Judge and Griffiths, 2000). Then the model becomes:
The standard function summary()
prints model summary for the model of interest.
model |
An object of class |
designMatrix |
The design matrix composed of transformed z-variables. |
designMatrix.x |
The design matrix composed of original x-variables. |
beta.coefficients |
Estimates and t-tests of original beta coefficients. This will be generated if |
Haydar Demirhan
Maintainer: Haydar Demirhan <[email protected]>
B.H. Baltagi. Econometrics, Fifth Ed. Springer, 2011.
R.C. Hill, W.E. Griffiths, G.G. Judge. Undergraduate Econometrics. Wiley, 2000.
data(seaLevelTempSOI) model.poly = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 4 , k = 2 , show.beta = TRUE) summary(model.poly) residuals(model.poly) coef(model.poly) fitted(model.poly)
data(seaLevelTempSOI) model.poly = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 4 , k = 2 , show.beta = TRUE) summary(model.poly) residuals(model.poly) coef(model.poly) fitted(model.poly)
Plots the rolling correlations along with other required statistics to visualise the approach of Gershunov et al. (2001) to test the significance of signal from rolling correlation analysis.
rolCorPlot(x , y , width, level = 0.95, main = NULL, SDtest = TRUE, N = 500)
rolCorPlot(x , y , width, level = 0.95, main = NULL, SDtest = TRUE, N = 500)
x |
A ts object. |
y |
A ts object. |
width |
A numeric vector of window lengths of the rolling correlation analysis. |
level |
Confidence level for intervals. |
main |
The main title of the plot. |
SDtest |
Set to |
N |
An integer showing the number of series to be generated in Monte Carlo simulation. |
rolCor |
A matrix showing rolling correlations for each |
rolcCor.avr.filtered |
A vector showing average rolling correlations filtered by running median nonlinear filter against outliers. |
rolcCor.avr.raw |
A vector showing unfiltered average rolling correlations. |
rolCor.sd |
A vector showing standard deviations of rolling correlations for each |
rawCor |
Pearson correlation between two series. |
sdPercentiles |
Percentiles of MC distribution of standard deviations of rolling correlations as the test limits. |
test |
A data frame showing the standard deviations of rolling correlations for each |
Haydar Demirhan
Maintainer: Haydar Demirhan <[email protected]>
Gershunov, A., Scheider, N., Barnett, T. (2001). Low-Frequency Modulation of the ENSO-Indian Monsoon Rainfall Relationship: Signal or Noise? Journal of Climate, 14, 2486 - 2492.
## Not run: data(wheat) prod.ts <-ts(wheat[,5], start = 1960) CO2.ts <- ts(wheat[,2], start = 1960) rolCorPlot(x = prod.ts, y = CO2.ts , width = c(7, 11, 15), level = 0.95, N = 50) ## End(Not run)
## Not run: data(wheat) prod.ts <-ts(wheat[,5], start = 1960) CO2.ts <- ts(wheat[,2], start = 1960) rolCorPlot(x = prod.ts, y = CO2.ts , width = c(7, 11, 15), level = 0.95, N = 50) ## End(Not run)
Implements the approach of Gershunov et al. (2001) to test the significance of signal from rolling correlation analysis.
sdPercentiles(n = 150, cor = 0.5, width = 5, N = 500, percentiles = c(.05, .95))
sdPercentiles(n = 150, cor = 0.5, width = 5, N = 500, percentiles = c(.05, .95))
n |
The length of the series in the rolling correlation analysis. |
cor |
The magnitude of raw correaltion betweeen two time series in the rolling correlation analysis. |
width |
Window length of the rolling correlation analysis. |
N |
Number of Monte Carlo replications for simulations. |
percentiles |
Percentiles to be reported for the Monte Carlo distribution of standard deviations of rolling correlations for the given window width. |
N
samples of correlated white noise series are generated with a magnitude of cor
; rolling correlations analysis is applied with the window length of width
; Monte Carlo distribution of standard deviations of rolling correlations are generated; and desired percentiles
of the MC distribution of standard deviations are reported (Gershunov et al. 2001).
rollCorSd.limits |
Percentiles of MC distribution of standard deviations of rolling correlations as the test limits. |
Haydar Demirhan
Maintainer: Haydar Demirhan <[email protected]>
Gershunov, A., Scheider, N., Barnett, T. (2001). Low-Frequency Modulation of the ENSO-Indian Monsoon Rainfall Relationship: Signal or Noise? Journal of Climate, 14, 2486 - 2492.
# sdPercentiles(n = 50, cor = 0.5, width = 5, N = 50, # percentiles = c(.025, .975))
# sdPercentiles(n = 50, cor = 0.5, width = 5, N = 50, # percentiles = c(.025, .975))
This data set is composed of monthly global mean sea level (compared to 1993-2008 average) series by CSIRO, land ocean temperature anomalies (1951-1980 as a baseline period) by GISS, NASA, and monthly Southern Oscillation Index (SOI) by Australian Government Bureau of Meteorology (BOM) between July 1885 and June 2013. GMSL and temperature anomalies series are smoothed and seasonally adjusted.
data(seaLevelTempSOI)
data(seaLevelTempSOI)
Multiple time series
Goddard Institute for Space Studies, NASA, US. Marine and Atmospheric Research, CSIRO, Australia. Australian Government Bureau of Meteorology (BOM).
Church, J. A. and N.J. White (2011), Sea-level rise from the late 19th to the early 21st Century. Surveys in Geophysics, doi:10.1007/s10712-011-9119-1.
https://www.cmar.csiro.au/sealevel/sl_data_cmar.html
https://data.giss.nasa.gov/gistemp/graphs_v4/
https://www.bom.gov.au/climate/current/soihtm1.shtml
data(seaLevelTempSOI) level.ts <- ts(seaLevelTempSOI[,1], start = c(1880,7), freq = 12) temp.ts <- ts(seaLevelTempSOI[,2], start = c(1880,7), freq = 12) plot(level.ts, main="Time series plot of GMSL series.")
data(seaLevelTempSOI) level.ts <- ts(seaLevelTempSOI[,1], start = c(1880,7), freq = 12) temp.ts <- ts(seaLevelTempSOI[,2], start = c(1880,7), freq = 12) plot(level.ts, main="Time series plot of GMSL series.")
Displays sorted AIC, BIC, and MASE scores.
sortScore(x, score = c("bic", "aic", "mase", "smape", "mape", "mrae", "gmrae", "mbrae"))
sortScore(x, score = c("bic", "aic", "mase", "smape", "mape", "mrae", "gmrae", "mbrae"))
x |
A vector of AIC, BIC, MASE, MAPE, sMAPE, MRAE, GMRAE, or MBRAE values. |
score |
The type of scores to be sorted. |
This function sorts the AIC, BIC, MASE, MAPE, sMAPE, MRAE, GMRAE, or MBRAE scores to display the smallest one at the top of a bunch of AIC, BIC, MASE, MAPE, sMAPE, MRAE, GMRAE, or MBRAE scores.
Cameron Doyle
Maintainer: Cameron Doyle <[email protected]>
## Not run: data(seaLevelTempSOI) model.poly1 = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 2 , k = 2 , show.beta = TRUE) model.poly2 = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 3 , k = 2 , show.beta = TRUE) model.poly3 = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 4 , k = 2 , show.beta = TRUE) aic = AIC(model.poly1$model, model.poly2$model, model.poly3$model) bic = BIC(model.poly1$model, model.poly2$model, model.poly3$model) mase = MASE(model.poly1$model, model.poly2$model, model.poly3$model) mbrae = MBRAE(model.poly1$model, model.poly2$model, model.poly3$model) sortScore(aic , score = "aic") sortScore(bic , score = "bic") sortScore(mase , score = "mase") sortScore(mbrae , score = "mbrae") ## End(Not run)
## Not run: data(seaLevelTempSOI) model.poly1 = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 2 , k = 2 , show.beta = TRUE) model.poly2 = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 3 , k = 2 , show.beta = TRUE) model.poly3 = polyDlm(x = seaLevelTempSOI$LandOcean, y = seaLevelTempSOI$GMSL , q = 4 , k = 2 , show.beta = TRUE) aic = AIC(model.poly1$model, model.poly2$model, model.poly3$model) bic = BIC(model.poly1$model, model.poly2$model, model.poly3$model) mase = MASE(model.poly1$model, model.poly2$model, model.poly3$model) mbrae = MBRAE(model.poly1$model, model.poly2$model, model.poly3$model) sortScore(aic , score = "aic") sortScore(bic , score = "bic") sortScore(mase , score = "mase") sortScore(mbrae , score = "mbrae") ## End(Not run)
This data set is composed of monthly mean global surface temperature series by GISS NASA and sunspot numbers recorded by SWPC Space Weather Operations (SWO) between January 1991 and November 2019.
data(sunspotTemp)
data(sunspotTemp)
Multiple time series
Goddard Institute for Space Studies, NASA, US. Space Weather Prediction Center National Oceanic and Atmospheric Administration, US.
https://data.giss.nasa.gov/gistemp/graphs_v4/
ftp://ftp.swpc.noaa.gov/pub/weekly/RecentIndices.txt
data(sunspotTemp) sunspots.ts <- ts(sunspotTemp[,3], start = c(1991,1), freq = 12) temp.ts <- ts(sunspotTemp[,4], start = c(1991,1), freq = 12) plot(sunspots.ts, main="Time series plots of sunspot numbers series.")
data(sunspotTemp) sunspots.ts <- ts(sunspotTemp[,3], start = c(1991,1), freq = 12) temp.ts <- ts(sunspotTemp[,4], start = c(1991,1), freq = 12) plot(sunspots.ts, main="Time series plots of sunspot numbers series.")
This data set is composed of annual mean global warming series between 1997 and 2016 showing the change in global surface temperature relative to 1951-1980 average temperatures and the number of vehicles produced (in millions) within the same time span over the globe.
data(warming)
data(warming)
Multiple time series
Global Climate Center, NASA Organisation Internationale des Constructeurs d'Automobiles (OICA)
https://climate.nasa.gov/vital-signs/global-temperature/
https://www.oica.net/category/production-statistics/
data(warming) vehicleWarming.ts = ts(warming[,2:3], start = 1997) plot(vehicleWarming.ts, main="Time series plots of global warming and the nuber of produced motor vehciles series.")
data(warming) vehicleWarming.ts = ts(warming[,2:3], start = 1997) plot(vehicleWarming.ts, main="Time series plots of global warming and the nuber of produced motor vehciles series.")
This data set is composed of annual world total CO2 emissions, wheat production, harvested area, wheat production per hectare, and annual average temperature anomalies series between 1960 and 2017.
data(wheat)
data(wheat)
Multiple time series
CO2..ppm.
column shows the global mean annual concentration of carbon dioxide (CO2) measured in parts per million (ppm).
CO2..tons
column shows the global mean annual carbon dioxide (CO2) emissions measured in tons.
HarvestedArea..million.ha.
column shows the annual harvested area in the world scale in million hectare.
Production..Mt.
column shows the annual world wheat production in million tons.
ProducationPerArea
column shows the annual wheat production per hectare in tons.
TempAnomaly..C.degrees.
column shows the land-ocean temperature index without smoothing.
Australian Government Department of Agriculture and Water Services, ABARES CO2 and other Greenhouse Gas Emissions by Hannah Ritchie and Max Roser
https://www.agriculture.gov.au/abares/research-topics/agricultural-commodities/agricultural-commodities-trade-data#australian-crop-report-data
https://www.agriculture.gov.au/abares/research-topics/agricultural-outlook/data
https://ourworldindata.org/co2-and-other-greenhouse-gas-emissions#annual-co2-emissions
https://climate.nasa.gov/vital-signs/global-temperature/
data(wheat) wheatProduction.ts = ts(wheat[,4], start = 1960) plot(wheatProduction.ts, main="Time series plot of world wheat production series.")
data(wheat) wheatProduction.ts = ts(wheat[,4], start = 1960) plot(wheatProduction.ts, main="Time series plot of world wheat production series.")