diff --git a/R/var.R b/R/var.R index b7c67e30..615ce57a 100644 --- a/R/var.R +++ b/R/var.R @@ -132,7 +132,7 @@ specials_var <- new_specials( #' #' @section Specials: #' -#' \subsection{pdq}{ +#' \subsection{AR}{ #' The `AR` special is used to specify the lag order for the auto-regression. #' \preformatted{ #' AR(p = 0:5) @@ -438,8 +438,6 @@ generate.VAR <- function(x, new_data, specials, ...){ #' @param impulse A character string specifying the name of the variable that is shocked (the impulse variable). #' @param orthogonal If TRUE, orthogonalised impulse responses will be computed. #' -#' @seealso [`fabletools::IRF.mdl_df`] -#' #' @export IRF.VAR <- function(x, new_data, specials, impulse = NULL, orthogonal = FALSE, ...) { # Zero out end of data diff --git a/R/vecm.R b/R/vecm.R index 94a50601..b9264ea8 100644 --- a/R/vecm.R +++ b/R/vecm.R @@ -177,7 +177,7 @@ specials_vecm <- new_specials( #' #' @section Specials: #' -#' \subsection{pdq}{ +#' \subsection{AR}{ #' The `AR` special is used to specify the lag order for the auto-regression. #' \preformatted{ #' AR(p = 0:5) @@ -189,7 +189,7 @@ specials_vecm <- new_specials( #' } #' #' \subsection{xreg}{ -#' Exogenous regressors can be included in an VAR model without explicitly using the `xreg()` special. Common exogenous regressor specials as specified in [`common_xregs`] can also be used. These regressors are handled using [stats::model.frame()], and so interactions and other functionality behaves similarly to [stats::lm()]. +#' Exogenous regressors can be included in an VECM model without explicitly using the `xreg()` special. Common exogenous regressor specials as specified in [`common_xregs`] can also be used. These regressors are handled using [stats::model.frame()], and so interactions and other functionality behaves similarly to [stats::lm()]. #' #' The inclusion of a constant in the model follows the similar rules to [`stats::lm()`], where including `1` will add a constant and `0` or `-1` will remove the constant. If left out, the inclusion of a constant will be determined by minimising `ic`. #' @@ -415,8 +415,6 @@ generate.VECM <- function(x, new_data, specials, ...){ #' @param impulse A character string specifying the name of the variable that is shocked (the impulse variable). #' @param orthogonal If TRUE, orthogonalised impulse responses will be computed. #' -#' @seealso [`fabletools::IRF.mdl_df`] -#' #' @export IRF.VECM <- function(x, new_data, specials, impulse = NULL, orthogonal = FALSE, ...) { # Zero out end of data diff --git a/man/VECM.Rd b/man/VECM.Rd index fc986fc8..295f6b88 100644 --- a/man/VECM.Rd +++ b/man/VECM.Rd @@ -4,7 +4,7 @@ \alias{VECM} \title{Estimate a VECM model} \usage{ -VECM(formula, ic = c("aicc", "aic", "bic"), ...) +VECM(formula, ic = c("aicc", "aic", "bic"), r = 1L, ...) } \arguments{ \item{formula}{Model specification (see "Specials" section).} @@ -18,7 +18,8 @@ A model specification. } \description{ Searches through the vector of lag orders to find the best VECM model which -has lowest AIC, AICc or BIC value. It is implemented using OLS per equation. +has lowest AIC, AICc or BIC value. The model is estimated using the Johansen +procedure (maximum likelihood). } \details{ Exogenous regressors and \code{\link{common_xregs}} can be specified in the model @@ -67,6 +68,3 @@ fit \%>\% forecast() \%>\% autoplot(lung_deaths) } -\seealso{ -\href{https://otexts.com/fpp2/VAR.html}{Forecasting: Principles and Practices, Vector autoregressions (section 11.2)} -} diff --git a/man/fitted.VECM.Rd b/man/fitted.VECM.Rd deleted file mode 100644 index 0b7056cb..00000000 --- a/man/fitted.VECM.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vecm.R -\name{fitted.VECM} -\alias{fitted.VECM} -\title{Extract fitted values from a fable model} -\usage{ -\method{fitted}{VECM}(object, ...) -} -\arguments{ -\item{object}{A model for which forecasts are required.} - -\item{...}{Other arguments passed to methods} -} -\value{ -A vector of fitted values. -} -\description{ -Extracts the fitted values. -} -\examples{ -lung_deaths <- cbind(mdeaths, fdeaths) \%>\% - as_tsibble(pivot_longer = FALSE) - -lung_deaths \%>\% - model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) \%>\% - fitted() -} diff --git a/man/forecast.VECM.Rd b/man/forecast.VECM.Rd deleted file mode 100644 index 1ac5407a..00000000 --- a/man/forecast.VECM.Rd +++ /dev/null @@ -1,42 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vecm.R -\name{forecast.VECM} -\alias{forecast.VECM} -\title{Forecast a model from the fable package} -\usage{ -\method{forecast}{VECM}( - object, - new_data = NULL, - specials = NULL, - bootstrap = FALSE, - times = 5000, - ... -) -} -\arguments{ -\item{object}{A model for which forecasts are required.} - -\item{new_data}{A tsibble containing the time points and exogenous regressors to produce forecasts for.} - -\item{specials}{(passed by \code{\link[fabletools:forecast]{fabletools::forecast.mdl_df()}}).} - -\item{bootstrap}{If \code{TRUE}, then forecast distributions are computed using simulation with resampled errors.} - -\item{times}{The number of sample paths to use in estimating the forecast distribution when \code{bootstrap = TRUE}.} - -\item{...}{Other arguments passed to methods} -} -\value{ -A list of forecasts. -} -\description{ -Produces forecasts from a trained model. -} -\examples{ -lung_deaths <- cbind(mdeaths, fdeaths) \%>\% - as_tsibble(pivot_longer = FALSE) - -lung_deaths \%>\% - model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) \%>\% - forecast() -} diff --git a/man/glance.VECM.Rd b/man/glance.VECM.Rd index 9044cb71..b423a571 100644 --- a/man/glance.VECM.Rd +++ b/man/glance.VECM.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/vecm.R \name{glance.VECM} \alias{glance.VECM} -\title{Glance a VAR} +\title{Glance a VECM} \usage{ \method{glance}{VECM}(x, ...) } @@ -15,17 +15,10 @@ A one row tibble summarising the model's fit. } \description{ -Construct a single row summary of the VAR model. +Construct a single row summary of the VECM model. } \details{ -Contains the variance of residuals (\code{sigma2}), the log-likelihood (\code{log_lik}), -and information criterion (\code{AIC}, \code{AICc}, \code{BIC}). -} -\examples{ -lung_deaths <- cbind(mdeaths, fdeaths) \%>\% - as_tsibble(pivot_longer = FALSE) - -lung_deaths \%>\% - model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) \%>\% - glance() +Contains the variance of residuals (\code{sigma2}), the log-likelihood +(\code{log_lik}), the cointegrating vector (\code{beta}) and information criterion +(\code{AIC}, \code{AICc}, \code{BIC}). } diff --git a/man/residuals.VECM.Rd b/man/residuals.VECM.Rd deleted file mode 100644 index 0b4e0e98..00000000 --- a/man/residuals.VECM.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vecm.R -\name{residuals.VECM} -\alias{residuals.VECM} -\title{Extract residuals from a fable model} -\usage{ -\method{residuals}{VECM}(object, ...) -} -\arguments{ -\item{object}{A model for which forecasts are required.} - -\item{...}{Other arguments passed to methods} -} -\value{ -A vector of fitted residuals. -} -\description{ -Extracts the residuals. -} -\examples{ -lung_deaths <- cbind(mdeaths, fdeaths) \%>\% - as_tsibble(pivot_longer = FALSE) - -lung_deaths \%>\% - model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) \%>\% - residuals() -} diff --git a/man/tidy.VECM.Rd b/man/tidy.VECM.Rd deleted file mode 100644 index 77363e54..00000000 --- a/man/tidy.VECM.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vecm.R -\name{tidy.VECM} -\alias{tidy.VECM} -\title{Tidy a fable model} -\usage{ -\method{tidy}{VECM}(x, ...) -} -\arguments{ -\item{x}{An object to be converted into a tidy \code{\link[tibble:tibble]{tibble::tibble()}}.} - -\item{...}{Additional arguments to tidying method.} -} -\value{ -The model's coefficients in a \code{tibble}. -} -\description{ -Returns the coefficients from the model in a \code{tibble} format. -} -\examples{ -lung_deaths <- cbind(mdeaths, fdeaths) \%>\% - as_tsibble(pivot_longer = FALSE) - -lung_deaths \%>\% - model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) \%>\% - tidy() -}