Description Usage Arguments Details Value See Also Examples

Much like the ecmback function, ecmaveback uses backwards selection to build an error correction model. However, it uses the averaging method of ecmave to build models and then choose variables based on lowest AIC or BIC, or highest adjusted R-squared.

1 2 | ```
ecmaveback(y, xeq, xtr, includeIntercept = T, criterion = "AIC", k,
method = "boot", seed = 5, weights = NULL, keep = NULL, ...)
``` |

`y` |
The target variable |

`xeq` |
The variables to be used in the equilibrium term of the error correction model |

`xtr` |
The variables to be used in the transient term of the error correction model |

`includeIntercept` |
Boolean whether the y-intercept should be included |

`criterion` |
Whether AIC (default), BIC, or adjustedR2 should be used to select variables |

`k` |
The number of models or data partitions desired |

`method` |
Whether to split data by folds ("fold"), nested folds ("nestedfold"), or bootstrapping ("boot") |

`seed` |
Seed for reproducibility (only needed if method is "boot") |

`weights` |
Optional vector of weights to be passed to the fitting process |

`keep` |
Optional character vector of variables to forcibly retain |

`...` |
Additional arguments to be passed to the 'lm' function (careful in that these may need to be modified for ecm or may not be appropriate!) |

When inputting a single variable for xeq or xtr, it is important to input it in the format "xeq=df['col1']" in order to retain the data frame class. Inputting such as "xeq=df[,'col1']" or "xeq=df$col1" will result in errors in the ecm function.

If using weights, the length of weights should be one less than the number of rows in xeq or xtr.

an lm object representing an error correction model using backwards selection

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ```
##Not run
#Use ecm to predict Wilshire 5000 index based on corporate profits,
#Federal Reserve funds rate, and unemployment rate
data(Wilshire)
#Use 2015-12-01 and earlier data to build models
trn <- Wilshire[Wilshire$date<='2015-12-01',]
#Use backwards selection to choose which predictors are needed
xeq <- xtr <- trn[c('CorpProfits', 'FedFundsRate', 'UnempRate')]
modelaveback <- ecmaveback(trn$Wilshire5000, xeq, xtr, k = 5)
print(modelaveback)
#Backwards selection chose CorpProfits and FedFundsRate in the equilibrium term,
#CorpProfits and UnempRate in the transient term.
modelavebackFFR <- ecmaveback(trn$Wilshire5000, xeq, xtr, k = 5, keep = 'UnempRate')
print(modelavebackFFR)
#Backwards selection was forced to retain UnempRate in both terms.
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.