Learn R Programming

RGAP: Output Gap Estimation in R

'RGAP' provides tools for modeling and estimating the bivariate unobserved component models involved in the European Commission's Cobb-Douglas production function methodology to estimate potential output and the output gap.

KOF Working Paper

If you use 'RGAP' in your paper, please cite it properly, see citation("RGAP") in R, or above link to the paper.

Details

The output gap indicates the percentage difference between the actual output of an economy and its potential. Since potential output is a latent process, the estimation of the output gap poses a challenge and numerous filtering techniques have been proposed. 'RGAP' facilitates the estimation of a Cobb-Douglas production function type output gap, as suggested by the European Commission (Havik et al. 2014). To that end, the non-accelerating wage rate of unemployment (NAWRU) and the trend of total factor productivity (TFP) can be estimated in two bivariate unobserved component (UC) models by means of Kalman filtering and smoothing. 'RGAP' features a flexible modeling framework for the appropriate state-space models and offers frequentist as well as Bayesian estimation techniques. Additional functionalities include direct access to the 'AMECO' database and automated model selection procedures.

Main features

  • Data fetching from 'AMECO' database
  • Data pre processing
  • Modeling bivariate state-space models for the NARWU and the TFP trend
  • Estimation of defined models via the Kalman filter and smoother and
    • maximum likelihood estimation or
    • bayesian estimation via Gibbs procedure
  • Output gap computation
  • Prediction
  • Alternative approaches: HP-filter and bivariate UC model by Kuttner (1994)
  • Additional features: automated model selection

Install the package

You can install the package from ‘Github’ using the install_github function from the devtools package.

library(devtools)
install_github('sinast3000/RGAP')

Kuttner, K. N. (1994), Estimating potential output as a latent variable, Journal of Business & Economic Statistics 12(3), 361–368.

Havik, K., Mc Morrow, K., Orlandi, F., Planas, C., Raciborski, R., Roeger, W., Rossi, A., Thum-Thysen, A. & Vandermeulen, V. (2014), The production function methodology for calculating potential growth rates & output gaps, Technical report, Directorate General Economic and Financial Affairs (DG ECFIN), European Commission.

Copy Link

Version

Install

install.packages('RGAP')

Monthly Downloads

175

Version

0.1.1

License

GPL-3

Maintainer

Sina Streicher

Last Published

November 2nd, 2023

Functions in RGAP (0.1.1)

cubs

CUBS indicator
constraint

Applies contraints to parameters.
.SSmodelfit

Computes figures regarding the model fit of the maximum likelihood estimation.
.assignGibbsFUN

Assigns the appropriate function and its input variables for the Gibbs procedure.
.aggregate

Temporally Aggregates time series.
cycleOptim

Find suitable cycle specification
dateTsList

Finds first/last starting/end date in list of time series deepening on the input functions.
.SSSystem

Prepares state space model system matrices to create an object of type NAWRUmodel or TFPmodel.
.BayesFitTFP

Estimates the parameters and states of a two-dimensional state-space model by Bayesian methods to obtain the tfp trend.
.cubsTa

Adjusts the frequency of cubs input series.
.checkModelMLEfit

Checks whether model, prior and MLE fit match.
autoTFPmodel

TFP model suggestion
.MLEfitTFP

Estimates a two-dimensional state-space model and performs filtering and smoothing to obtain the tfp trend.
.checkBayesInput

Checks the input parameters of .BayesFitTFP and .BayesFitNAWRU for consistency.
.MLEfitNAWRU

Estimates a two-dimensional state-space model and performs filtering and smoothing to obtain the nawru.
.checkNawru

Checks the input variables for the procedure NAWRUmodel for consistency and validity.
.getXYcubs

defines Y and X in the CUBS equation.
.BayesFitNAWRU

Estimates the parameters and states of a two-dimensional state-space model by Bayesian methods to obtain the nawru.
.gibbsStepDT

Draws from the posterior of the parameters of the damped trend equation, conditional on the states.
.covCUBS

computes the unconditional variance of the cubs equation with p lags of cubs and k additional lags of the cycle. The cycle follows an AR process of order l.
.checkKuttner

Checks the input variables for the procedure KuttnerModel for consistency and validity.
computeCovar

Computes the covariance of the estimated parameters given restrictions.
.RAR2transform

Transforms the parameters of an AR(2) process to its re-parametrized version RAR(2) and vice versa.
.checkModelPrior

Checks whether model and prior match.
.getXYpcInd

defines Y and X for the Phillips curve.
.checkBoundaries

Checks whether estimated parameters lie on boundaries.
.gibbsStepRAR2

Draws from the posterior of the parameters of the RAR2 cycle equation, conditional on the states.
.intervalIGamma

Computes confidence interval of Inverse Gamma distributed variable with given mean and standard deviation.
.SSresults

Computes additional results of the Kalman filter and smoother.
.meanStd2Beta

Converts the mean and standard deviation of a (possibly scaled) Beta-distributed variable into the two shape parameters \(\alpha\) and \(\beta\).
.mvrnorm

Draws from the multivariate normal distribution.
.updateParConstraints

Updates the parameter constraints for on object of class NAWRUmodel or TFPmodel.
fit.KuttnerModel

Maximum likelihood estimation of a KuttnerModel
.checkTfp

Checks the input variables for the procedure TFPmodel for consistency and validity.
.updateSSSystem

Updates the system matrices of an object of class NAWRUmodel or TFPmodel during optimization or during a Bayesian Gibbs procedure.
.modifySSSystem

Modifies a an object of type NAWRUmodel or TFPmodel in case the variance constraint for the trend is set to zero or in case a signal-to-noise ratio is specified.
.meanStd2GammasNu

Converts the mean and standard deviation of a Gamma-distributed variable into the parameters \(s\) and \(\nu\).
.covAR

Computes the covariance of an AR(q) process.
.gibbsStep2Eq

Draws from the posterior of the parameters of the cubs equation, conditional on the states.
fit.NAWRUmodel

Estimation of a NAWRUmodel
gapProd

Production function output gap
hpfilter

HP filter
indicator

Indicators fo CUBS
.checkParRestr

Checks the given variance restrictions for consistency.
gewekeTest

Conducts a Geweke test for convergence of the draws.
helper_model_comparison

model comparison helper function
.checkPrior

Checks the given prior information for consistency and applicability.
initializePrior

Initialization of prior distributions
.priorMSd2Parameter

Transforms the prior distribution defined by mean and standard deviation to the appropriate input parameters.
.printSSModelFit

Prints the model fit and possibly specifications.
.normalize

Normalizes a time series / vector.
helper_model_fit

model selection helper function
fetchAmecoData

Current 'AMECO' data vintage
is.gap

gap object check
firstLetterUp

Capitalizes the first letter of a string.
.gibbsStepAR

Draws from the posterior of the parameters of the AR(p), p = 1,2 cycle equation, conditional on the states.
matmult3d

Capitalizes the first letter of a string.
obs2Optim

Find suitable 2nd observation specification
.deltaMethodState

Computes standard errors of the state using the delta method.
.deltaMethodObs

Computes standard errors of the observation equation using the delta method (for forecast).
extract_indicator_data

Extracts the relevant 'AMECO' indicator data.
extract_ameco_data

Extracts the relevant 'AMECO' data
.postAR1

Draws from the posterior the autoregressive parameter of a stationary AR(1) process without starting values.
mcmcSummary

Computes MCMC summary statistics.
fit.TFPmodel

Estimation of a TFPmodel
fit

Fit Method
.postARp

Draws from the posterior of the autoregressive paramteres of a stationary AR(p), \(p > 1\) process without starting values.
plot.KuttnerFit

Plots for a KuttnerFit object
is.TFPfit

TFPfit object check
.postNIG

Draws from the posterior of parameters of a normal model with normal inverse gamma prior.
print.KuttnerFit

Print KuttnerFit object
.accessDfSystem

Accesses the internal data frame dfSystem which contains data on the parameters to be estimated.
operTsLists

Performs a mathematical operation to the ts elements of two lists with the same names
plotSSprediction

Plots the trend series and the (fitted) second observation equation and gives diagnostic plots based on standardized residuals.
helper_fit_comparison

model selection fit comparison helper function
.postRW

Draws from the posterior of the variance parameter of a random walk or a random walk with constant or stochastic drift.
.SSresultsBayesian

Computes additional results of the Kalman filter and smoother for Bayesian output.
growth

Growth rate
is.TFPmodel

TFPmodel object check
plotSSresults

Plots the trend series and the (fitted) second observation equation and gives diagnostic plots based on standardized residuals.
.checkCubs

Checks the input variables for the procedure cubs for consistency and validity.
is.KuttnerFit

KuttnerFit object check
.printGeweke

Prints the results of the Geweke test for the states and the parameters.
.checkCV

Checks the covariance matrix for invertibility and negative entries on the diagonal.
print.KuttnerModel

Print KuttnerModel object
is.KuttnerModel

KuttnerModel object check
.initializeLoc

Initializes the location file containing default parameter constraints, among other things.
.initializeVar

Initializes variance restrictions.
gapHP

HP-filter output gap
initializeRestr

Initialization of parameter restrictions
print.gap

Print gap object
plotGap

Plots the trend series and the (fitted) second observation equation and gives diagnostic plots based on standardized residuals.
.printSSModel

Prints the model specifications.
plot.gap

Plots for a gap object
gap

gap data set
print.TFPfit

Print TFPfit object
initializeExo

Initialization of exogenous variables
inference

Computes standard errors, t-statistics, and p-values for the estimated state space parameters using the delta method.
print.TFPmodel

Print TFPmodel object
trendAnchor

Trend anchor
plot.TFPfit

Plots for a TFPfit object
plot.NAWRUfit

Plots for a NAWRUfit object
trendVolaMeasures

Trend volatility measures
print.NAWRUfit

Print NAWRUfit object
trendOptim

Find suitable trend specification
print.NAWRUmodel

Print NAWRUmodel object
is.NAWRUmodel

NAWRUodel object check
predict.fit

Predictions
predictMLE

Predictions for MLE
plot_gibbs_output

Plots the diagnostic plots of the posterior distribution.
predictBayes

Predictions for Bayesian estimation
is.NAWRUfit

NAWRUfit object check
FUNcov

Computes mean and variance of the part of the posterior distribution that relies on starting values. It then computes the density of the first p observations of Y.
NAWRUmodel

NAWRU model
autoGapProd

Fit best production function model
Dconstraint

Extracts the derivative of the applied restriction function.
autoNAWRUmodel

NAWRU model suggestion
KuttnerModel

Kuttner model
HPDinterval

Computes the approximate highest posterior density interval (HPDI).
TFPmodel

TFP trend model
assignConstraints

Applies suitable contraining functions to parameters.
amecoData2input

Data for estimation