Type: Package
Title: Production Function Output Gap Estimation
Version: 0.1.1
Depends: R (≥ 3.1.0)
Description: 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) https://ideas.repec.org/p/euf/ecopap/0535.html. 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 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' https://economy-finance.ec.europa.eu/economic-research-and-databases/economic-databases/ameco-database_en database and automated model selection procedures. See the paper by Streicher (2022) http://hdl.handle.net/20.500.11850/552089 for details.
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
Imports: stats, KFAS, zoo, dlm, openxlsx, ggplot2, gridExtra
Suggests: testthat (≥ 3.0.0), R.rsp
VignetteBuilder: R.rsp
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2023-11-02 07:56:36 UTC; sinast
Author: Sina Streicher ORCID iD [aut, cre]
Maintainer: Sina Streicher <streicher@kof.ethz.ch>
Repository: CRAN
Date/Publication: 2023-11-02 09:00:02 UTC

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

Description

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

Usage

.BayesFitNAWRU(
  model,
  prior = initializePrior(model),
  R = 10000,
  burnin = ceiling(R/10),
  thin = 1,
  HPDIprob = 0.85,
  FUN = mean,
  MLEfit = NULL
)

Arguments

model

An object of class NAWRUmodel.

prior

A list of matrices with parameters for the prior distribution and box constraints. By default, prior is initialized by initializePrior(model). See details. Only used if method = "bayesian".

R

An integer specifying the number of MCMC draws. The default is R = 10000. Only used if method = "bayesian".

burnin

An integer specifying the burn-in phase of the MCMC chain. The default is burnin = ceiling(R / 10). Only used if method = "bayesian".

thin

An integer specifying the thinning interval between consecutive draws. The default is thin = 1, implying that no draws are dopped. For thin = 2, every second draw is dropped and so on. Only used if method = "bayesian".

HPDIprob

A numeric in the interval (0,1) specifying the target probability of the highest posterior density intervals. The default is HPDIprob = 0.9. Only used if method = "bayesian".

FUN

A function to be used to compute estimates from the posterior distribution. Possible options are "mean" and "median". The default is FUN = "mean". Only used if method = "bayesian".

MLEfit

(Optional) An object of class NAWRUfit which is used for initialization. Only used if method = "bayesian".


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

Description

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

Usage

.BayesFitTFP(
  model,
  prior = initializePrior(model),
  R = 10000,
  burnin = ceiling(R/10),
  thin = 1,
  HPDIprob = 0.85,
  FUN = mean,
  MLEfit = NULL
)

Arguments

model

An object of class TFPmodel.

prior

A list of matrices with parameters for the prior distribution and box constraints. By default, prior is initialized by initializePrior(model). See details. Only used if method = "bayesian".

R

An integer specifying the number of MCMC draws. The default is R = 10000. Only used if method = "bayesian".

burnin

An integer specifying the burn-in phase of the MCMC chain. The default is burnin = ceiling(R / 10). Only used if method = "bayesian".

thin

An integer specifying the thinning interval between consecutive draws. The default is thin = 1, implying that no draws are dopped. For thin = 2, every second draw is dropped and so on. Only used if method = "bayesian".

HPDIprob

A numeric in the interval (0,1) specifying the target probability of the highest posterior density intervals. The default is HPDIprob = 0.9. Only used if method = "bayesian".

FUN

A function to be used to compute estimates from the posterior distribution. Possible options are "mean" and "median". The default is FUN = "mean". Only used if method = "bayesian".

MLEfit

(Optional) An object of class TFPfit which is used for initialization. Only used if method = "bayesian".


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

Description

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

Usage

.MLEfitNAWRU(
  model,
  parRestr = initializeRestr(model = model),
  signalToNoise = NULL,
  control = NULL
)

Arguments

model

An object of class NAWRUmodel.

parRestr

A list of matrices containing the parameter restrictions for the cycle, trend, and the Phillip's curve. Each matrix contains the lower and upper bound of the involved parameters. NA implies that no restriction is present. Autoregressive parameters are automatically restricted to the stationary region unless box constraints are specified. By default, parRestr is initialized by the function initializeRestr(model). Only used if method = "MLE".

signalToNoise

(Optional) signal to noise ratio. Only used if method = "MLE".

control

(Optional) A list of control arguments to be passed on to optim.


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

Description

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

Usage

.MLEfitTFP(
  model,
  parRestr = initializeRestr(model),
  signalToNoise = NULL,
  control = NULL
)

Arguments

model

An object of class TFPmodel.

parRestr

A list of matrices containing the parameter restrictions for the cycle, trend, and the CUBS equation. Each matrix contains the lower and upper bound of the involved parameters. NA implies that no restriction is present. Autoregressive parameters are automatically restricted to the stationary region unless box constraints are specified. By default, parRestr is initialized by the function initializeRestr(model). Only used if method = "MLE".

signalToNoise

(Optional) signal to noise ratio. Only used if method = "MLE".

control

(Optional) A list of control arguments to be passed on to optim.


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

Description

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

Usage

.RAR2transform(par, phi2Atau = TRUE)

Arguments

par

vector of parameters

phi2Atau

logical indicating whether the transformation should be from AR(2) to RAR(2) or vice versa.

Value

A vector with the transformed parameters


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

Description

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

Usage

.SSSystem(tsl, cycle, trend, cycleLag, type = NULL, errorARMA)

Arguments

tsl

A list of input time series computed during the procedure NAWRUmodel or TFPmodel.

cycle

A character string specifying the cycle model. cycle = "AR1" denotes an AR(1) process, cycle = "AR2" an AR(2) process. The default is cycle = "AR2".

trend

A character string specifying the trend model. trend = "RW1" denotes a first order random walk, trend = "RW2" a second order random walk (local linear trend) and trend = "DT" a damped trend model. The default is trend = "RW2".

cycleLag

A vector specifying the cycle lags that are included in the Phillip's curve. The default is cycleLag = 0, see details.

type

A character string specifying the type of the Phillip's curve. type = "TKP" denotes the traditional Keynesian Phillip's curve and type = "NKP" the New Keynesian Phillip's curve, see details. The default is type = "TKP".

errorARMA

A vector with non-negative integers specifying the AR and MA degree of the error term in the second observation equation.


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

Description

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

Usage

.SSmodelfit(out, nPar)

Arguments

out

The return object of the function KFS from the package KFAS.

nPar

A scalar specifying the number of estimated parameters.


Computes additional results of the Kalman filter and smoother.

Description

Computes additional results of the Kalman filter and smoother.

Usage

.SSresults(out, model, prediction = FALSE)

Arguments

out

The return object of the function KFS from the package KFAS.

model

An object of class NAWRUmodel, TFPmodel, or KuttnerModel.

prediction

Logical indicating whether out includes predictions.


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

Description

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

Usage

.SSresultsBayesian(model, HPDIprob, state, obsFitted, FUN)

Arguments

model

The return object of the function fitSSM from the package KFAS.

HPDIprob

A numeric in the interval (0,1) specifying the target probability of the highest posterior density intervals. The default is HPDIprob = 0.9. Only used if method = "bayesian".

state

An array with the smoothed state.

obsFitted

An array with the fitted observables.


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

Description

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

Usage

.accessDfSystem(model)

Arguments

model

A model of class NAWRUmodel or TFPmodel.

Value

A data frame containing information on each involved parameter, for instance its corresponding system matrix, variable names, and parameter restrictions.


Temporally Aggregates time series.

Description

Temporally Aggregates time series.

Usage

.aggregate(x, freqLow, FUN)

Arguments

x

A time series object.

freqLow

Frequency of low frequency series.

FUN

A function for aggregation.


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

Description

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

Usage

.assignGibbsFUN(
  loc,
  type,
  trend,
  cycle,
  cubsAR,
  cycleLag,
  errorARMA,
  exoNames = NULL
)

Arguments

loc

A data frame containing information on each involved parameter, for instance its corresponding system matrix, variable names, and parameter restrictions.

type

A character string specifying the type of the Phillip's curve. type = "TKP" denotes the traditional Keynesian Phillip's curve and type = "NKP" the New Keynesian Phillip's curve, see details. The default is type = "TKP".

trend

A character string specifying the trend model. trend = "RW1" denotes a first order random walk, trend = "RW2" a second order random walk (local linear trend) and trend = "DT" a damped trend model. The default is trend = "DT".

cycle

A character string specifying the cycle model. cycle = "AR1" denotes an AR(1) process, cycle = "AR2" an AR(2) process, cycle = "RAR2" a reparametrized AR(2) process. The default is cycle = "AR2".

cubsAR

A non-negative integer specifying the maximum CUBS lag that is included in the CUBS equation. The default is cubsAR = 0, see details.

cycleLag

A non-negative integer specifying the maximum cycle lag that is included in the CUBD equation. The default is cycleLag = 0, see details.

errorARMA

A vector with non-negative integers specifying the AR and MA degree of the error term in the second observation equation.

exoNames

A character vector containing the names of the exogenous variables.


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

Description

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

Usage

.checkBayesInput(
  model,
  type,
  prior = NULL,
  R = NULL,
  burnin = NULL,
  thin = NULL,
  HPDIprob = NULL,
  FUN = NULL,
  MLEfit = NULL
)

Arguments

model

An object of class TFPmodel.

type

A character specifying whether a "nawru" or "tfp" model should be checked.

prior

A list of matrices with parameters for the prior distribution and box constraints. By default, prior is initialized by initializePrior(model). See details. Only used if method = "bayesian".

R

An integer specifying the number of MCMC draws. The default is R = 10000. Only used if method = "bayesian".

burnin

An integer specifying the burn-in phase of the MCMC chain. The default is burnin = ceiling(R / 10). Only used if method = "bayesian".

thin

An integer specifying the thinning interval between consecutive draws. The default is thin = 1, implying that no draws are dopped. For thin = 2, every second draw is dropped and so on. Only used if method = "bayesian".

HPDIprob

A numeric in the interval (0,1) specifying the target probability of the highest posterior density intervals. The default is HPDIprob = 0.9. Only used if method = "bayesian".

FUN

A function to be used to compute estimates from the posterior distribution. Possible options are "mean" and "median". The default is FUN = "mean". Only used if method = "bayesian".

MLEfit

(Optional) An object of class TFPfit which is used for initialization. Only used if method = "bayesian".


Checks whether estimated parameters lie on boundaries.

Description

Checks whether estimated parameters lie on boundaries.

Usage

.checkBoundaries(fit, loc)

Arguments

fit

Output of fitSSM from KFAS.

loc

A data frame containing information on each involved parameter (list element of objects of class NAWRUmodel, TFPmodel, KuttnerModel).


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

Description

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

Usage

.checkCV(fit, loc)

Arguments

fit

Output of fitSSM from KFAS.

loc

A data frame containing information on each involved parameter (list element of objects of class NAWRUmodel, TFPmodel, KuttnerModel).


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

Description

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

Usage

.checkCubs(tsCU, tsVA, lambda, frequency)

Arguments

tsCU

A multiple time series containing three survey time series, the first element needs to be capacity utilization in industry, see details. Alternatively, a list of time series can be supplied.

tsVA

A multiple time series containing three value added series that correspond to tsCU. Alternatively, a list of time series can be supplied.

lambda

The smoothing parameter for the application of the HP filter (see details). If not supplied, lambda = 6.25 is used for yearly data and lambda = 1600 for quarterly data.

frequency

The frequency of the computed cubs indicator. Possible entries are frequency = 1 (annual), frequency = 4 (quarterly). The default is frequency = 1.


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

Description

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

Usage

.checkKuttner(
  tsl,
  trend,
  cycle,
  cycleLag,
  errorARMA,
  start,
  end,
  anchor,
  anchor.h
)

Arguments

tsl

A list of time series objects, see details.

trend

A character string specifying the trend model. trend = "RW1" denotes a first order random walk, trend = "RW2" a second order random walk (local linear trend) and trend = "DT" a damped trend model. The default is trend = "RW1".

cycle

A character string specifying the cycle model. cycle = "AR1" denotes an AR(1) process, cycle = "AR2" an AR(2) process. The default is cycle = "AR2".

cycleLag

A non-negative integer specifying the maximum cycle lag that is included in the inflation equation. The default is cycleLag = 0, see details.

errorARMA

A vector with non-negative integers specifying the AR and MA degree of the error term in the inflation equation.

start

(Optional) Start vector for the estimation, e.g. c(1980, 1).

end

(Optional) End vector for the estimation, e.g. c(2020, 1).

anchor

(Optional) Anchor value for the logarithm of trend gdp.

anchor.h

(Optional) Anchor horizon in the frequency of the given time series.


Checks whether model, prior and MLE fit match.

Description

Checks whether model, prior and MLE fit match.

Usage

.checkModelMLEfit(model, MLEfit)

Arguments

model

An object of class TFPmodel.

MLEfit

(Optional) An object of class TFPfit which is used for initialization. Only used if method = "bayesian".


Checks whether model and prior match.

Description

Checks whether model and prior match.

Usage

.checkModelPrior(model, prior)

Arguments

model

An object of class TFPmodel.

prior

A list of matrices with parameters for the prior distribution and box constraints. By default, prior is initialized by initializePrior(model). See details. Only used if method = "bayesian".


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

Description

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

Usage

.checkNawru(
  tsl,
  trend,
  cycle,
  type,
  cycleLag,
  errorARMA,
  exoNames,
  exoType,
  start,
  end,
  anchor,
  anchor.h
)

Arguments

tsl

A list of time series objects, see details.

trend

A character string specifying the trend model. trend = "RW1" denotes a first order random walk, trend = "RW2" a second order random walk (local linear trend) and trend = "DT" a damped trend model. The default is trend = "RW2".

cycle

A character string specifying the cycle model. cycle = "AR1" denotes an AR(1) process, cycle = "AR2" an AR(2) process. The default is cycle = "AR2".

type

A character string specifying the type of the Phillip's curve. type = "TKP" denotes the traditional Keynesian Phillip's curve and type = "NKP" the New Keynesian Phillip's curve, see details. The default is type = "TKP".

cycleLag

A vector specifying the cycle lags that are included in the Phillip's curve. The default is cycleLag = 0, see details.

errorARMA

A vector with non-negative integers specifying the AR and MA degree of the error term in the Phillip's curve equation.

exoNames

A character vector containing the names of the exogenous variables.

exoType

An optional n x m x 2 array specifying the possible difference and lag transformation for the variables. exoType can be initialized using the function inizializeExo. The column names give the variable names. exoType[, , 1] contains the difference transformations and exoType[, , 2] the subsequent lag transformations, see details.

start

(Optional) Start vector for the estimation, e.g. c(1980, 1).

end

(Optional) End vector for the estimation, e.g. c(2020, 1).

anchor

(Optional) Anchor value for the unemployment rate.

anchor.h

(Optional) Anchor horizon in the frequency of the given time series.


Checks the given variance restrictions for consistency.

Description

Checks the given variance restrictions for consistency.

Usage

.checkParRestr(model, parRestr)

Arguments

model

An object of class NAWRUmodel or TFPmodel.

parRestr

list of matrices containing the parameter restrictions for the cycle, trend, and the second observation equation (Phillips curve, CUBS equation). Each matrix contains the lower and upper bound of the involved parameters. NA implies that no restriction is present.


Checks the given prior information for consistency and applicability.

Description

Checks the given prior information for consistency and applicability.

Usage

.checkPrior(model, prior)

Arguments

model

An object of class TFPmodel.

prior

A list of matrices with parameters for the prior distribution and box constraints.


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

Description

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

Usage

.checkTfp(
  tsl,
  trend,
  cycle,
  cycleLag,
  cubsAR,
  errorARMA,
  start,
  end,
  anchor,
  anchor.h
)

Arguments

tsl

A list of time series objects, see details.

trend

A character string specifying the trend model. trend = "RW1" denotes a first order random walk, trend = "RW2" a second order random walk (local linear trend) and trend = "DT" a damped trend model. The default is trend = "DT".

cycle

A character string specifying the cycle model. cycle = "AR1" denotes an AR(1) process, cycle = "AR2" an AR(2) process, cycle = "RAR2" a reparametrized AR(2) process. The default is cycle = "AR2".

cycleLag

A non-negative integer specifying the maximum cycle lag that is included in the CUBD equation. The default is cycleLag = 0, see details.

cubsAR

A non-negative integer specifying the maximum CUBS lag that is included in the CUBS equation. The default is cubsAR = 0, see details.

errorARMA

A vector with non-negative integers specifying the AR and MA degree of the error term in the CUBS equation.

start

(Optional) Start vector for the estimation, e.g. c(1980, 1).

end

(Optional) End vector for the estimation, e.g. c(2020, 1).

anchor

(Optional) Snchor value for the log of the TFP trend.

anchor.h

(Optional) Anchor horizon in the frequency of the given time series.


Computes the covariance of an AR(q) process.

Description

Computes the covariance of an AR(q) process.

Usage

.covAR(k, phi, sigma)

Arguments

k

integer indicating the lag length of the covariance.

phi

q x 1 vector of parameters.

sigma

the innovation variance of the AR(q) process.

Value

A k x k covariance matrix.


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.

Description

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.

Usage

.covCUBS(mu, phi, beta, sigma, phiC, sigmaC)

Arguments

mu

constant.

phi

p x 1 vector of parameters for cubs lags.

beta

k x 1 vector of parameters for contemporaneous cycle and cycle lags.

sigma

the innovation variance of the cubs process.

phiC

l x 1 vector of cycle process parameters.

sigmaC

the innovation variance of the cycle process.

Value

A list with a two covariance matrices; the first one depicts the covariance between the cycle and cubs and the second onf the covariance of cubs.


Adjusts the frequency of cubs input series.

Description

Adjusts the frequency of cubs input series.

Usage

.cubsTa(tsObj, conversion, frequency)

Arguments

tsObj

A time series object.

conversion

An appropriate conversion method, i.e., "average" or "sum".

frequency

The frequency of the aggregated time series, i.e., frequency = 4 for quarterly and frequency = 1 for annual.

Details

If frequency == 1, then the values for the latest and the first year are averaged over the existing months/quarters. However, for the latest year, this is only done if the third quarter is available.


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

Description

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

Usage

.deltaMethodObs(out, nameObs, model, constant = 1)

Arguments

out

The return object of the function KFS from the package KFAS.

nameObs

The name of the observation equation as character.

model

An object of class NAWRUmodel, TFPmodel, or KuttnerModel.

constant

A constant used in the transformation functions.


Computes standard errors of the state using the delta method.

Description

Computes standard errors of the state using the delta method.

Usage

.deltaMethodState(out, nameState, constant = 1)

Arguments

out

The return object of the function KFS from the package KFAS.

nameState

The name of the state as character.

constant

A constant used in the transformation functions.


defines Y and X in the CUBS equation.

Description

defines Y and X in the CUBS equation.

Usage

.getXYcubs(stateSmoothed, model, cycleLag, cubsAR, names, trim = FALSE)

Arguments

stateSmoothed

The smoothed states.

model

An object of class TFPmodel.

cycleLag

A non-negative integer specifying the maximum cycle lag that is included in the CUBD equation. The default is cycleLag = 0, see details.

cubsAR

A non-negative integer specifying the maximum CUBS lag that is included in the CUBS equation. The default is cubsAR = 0, see details.

names

The names of the columns.

trim

A logical indicating whether NAs should be trimmed.


defines Y and X for the Phillips curve.

Description

defines Y and X for the Phillips curve.

Usage

.getXYpcInd(stateSmoothed, model, cycleLag, pcIndAR, names, trim = FALSE)

Arguments

stateSmoothed

The smoothed states.

model

An object of class NAWRUmodel.

cycleLag

A vector specifying the cycle lags that are included in the Phillip's curve. The default is cycleLag = 0, see details.

pcIndAR

Lag of the Phillips curve indicator.

names

The names of the columns.

trim

A logical indicating whether NAs should be trimmed.


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

Description

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

Usage

.gibbsStep2Eq(
  Y,
  X,
  p,
  pk,
  pa,
  betaLast,
  sigmaLast,
  betaDistr,
  sigmaDistr,
  phiLast = NULL,
  phiDistr = NULL,
  phiC,
  sigmaC
)

Arguments

Y

a Tn x 1 vector.

X

a Tn x n matrix, includes a constant, the contemporaneous cycle, cycle lags, and lags of cubs.

p

integer, lag of cubs.

pk

integer, contemporaneous cycle and cycle lags.

pa

integer, autoregressive order of error term.

betaLast

last draw from posterior of beta.

sigmaLast

last draw from posterior of cubs innovation variance.

betaDistr

prior distribution of beta.

sigmaDistr

prior distribution of cubs innovation variance.

phiLast

(optional) vector, last draw from posterior of the autoregressive parameter of the error term.

phiDistr

(optional) prior of the autoregressive parameter of the error term.

phiC

parameter vector of the cycle equation.

sigmaC

innovation variance of the cycle equation

Details

The parameter vector beta and the innovation variance are Normal-inverse Gamma distributed. A draw from their posterior is obtained by conjugacy.

If there are additional lags of the cycle or cubs, conjugacy does not apply since the starting values are not given. In this case, a Metropolis-Hasting step is implemented.

If the error term is an AR(1) or AR(2) process, an additional Gibbs step draws from the posterior of the autoregressive parameter, given all other parameters.


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

Description

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

Usage

.gibbsStepAR(Y, parLast, parDistr, varNames)

Arguments

Y

a Tn x 1 vector.

parLast

A (p + 1) x 1 vector containing the last draw for the autoregressive coefficients and the innovation variance (in that order).

parDistr

A 4 x (p + 1) matrix with prior distribution and box constraints for the parameters of each variable (the order of the columns is as for parLast). In each column, the first two entries contain the prior hyperparameters and the last two entries the upper and lower bound.

varNames

A vector with parameter names in the correct order, i.e., autoregressive coefficients, variance.

Details

The autoregressive parameter and the innovation variance are drawn sequentially.

If the cycle is AR(1) process, the posterior is obtained by conjugacy. If it is an AR(2) process, a Metropolis-Hastings step is implemented.

Conditional on the autoregressive parameters, the innovation variance is drawn from the Inverse Gamma posterior which is obtained by conjugacy.


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

Description

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

Usage

.gibbsStepDT(Y, par, distr, varName)

Arguments

Y

A Tn x 1 vector.

par

A 3 x 1 vector with parameters.

distr

A 4 x 3 matrix with prior parameters and box constraints.

varName

A 3 x 1 vector with parameter names in the correct order, i.e., mean reversion, autoregressive parameter, variance.

Details

The three parameters are drawn sequentially in a Gibbs procedure. (conditional on the two other parameters).

The parameter \omega is drawn from a normal posterior which is obtained by conjugancy.

The autoregressive parameter \phi is drawn via a Metropolis-Hastings step.

The innovation variance is drwan from the Inverse-Gamma distribution which obtained by conjugacy.


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

Description

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

Usage

.gibbsStepRAR2(Y, parLast, parDistr, varNames)

Arguments

Y

a Tn x 1 vector.

parLast

A 3 x 1 vector containing the last draw for amplitude, mean cycle periodicity, innovation variance (in that order).

parDistr

A 4 x 3 matrix with prior distribution and box constraints for the parameters of each variable (the order of the columns is as for parLast). In each column, the first two entries contain the prior hyperparameters and the last two entries the upper and lower bound.

varNames

A vector with parameter names in the correct order, i.e., amplitude, mean cycle periodicity, variance.

Details

The parameters A and \tau are Beta distributed and the variance \sigma^2 is Gamma distributed.

The posterior is not available in closed form, instead it is obtained via an ARMS step.

Value

A list with the draws.


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

Description

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

Usage

.initializeLoc(model)

Arguments

model

A model of class NAWRUmodel or TFPmodel.

Value

A data frame containing information on each involved parameter, for instance its corresponding system matrix, variable names, and parameter restrictions.


Initializes variance restrictions.

Description

Initializes variance restrictions.

Usage

.initializeVar(
  model,
  type = NULL,
  lambda = NULL,
  prior = FALSE,
  errorARMA = c(0, 0),
  q = 0.05
)

Arguments

model

An object of class NAWRUmodel, TFPmodel, or KuttnerModel.

type

The variance restriction type. Possible options are "basic", "hp", see details. The default is type = "basic".

lambda

The smoothing constant for the HP-filter if type = "hp".

prior

A logical indicating whether prior parameters should be returned.

errorARMA

The ARMA order of the second equation error process.

q

Quantile for the Inverse Gamma distribution (only used if type = "hp"). The default is q = 0.01.


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

Description

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

Usage

.intervalIGamma(mu, sd, qlower = 0.025, qupper = 1 - qlower)

Arguments

mu

A k x 1 vector of means.

sd

A k x 1 vector of standard deviations.

qlower

A k x 1 vector of lower quantiles.

qupper

A k x 1 vector of upper quantiles.

Value

A 2 x k matrix containing the lower and upper bounds of the intervals.


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

Description

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

Usage

.meanStd2Beta(m, std, lb = 0, ub = 1)

Arguments

m

mean parameter

std

standard deviation

lb

lower bound

ub

upper bound

Value

A vector with shape parameters \alpha and \beta.


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

Description

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

Usage

.meanStd2GammasNu(m, std)

Arguments

m

mean parameter

std

standard deviation

Details

The parameters s and nu are related to the regular shape \alpha and rate \beta parametrization in the following way: \alpha = \nu / 2 \beta = s / 2

Value

A vector with parameters s and \nu.


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.

Description

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.

Usage

.modifySSSystem(model, signalToNoise)

Arguments

model

An object of class TFPmodel.

signalToNoise

(Optional) signal to noise ratio. Only used if method = "MLE".


Draws from the multivariate normal distribution.

Description

Draws from the multivariate normal distribution.

Usage

.mvrnorm(mu, sigma)

Arguments

mu

A n x 1 vector, the mean vector.

sigma

A n x n matrix, the covariance matrix.


Normalizes a time series / vector.

Description

Normalizes a time series / vector.

Usage

.normalize(x)

Arguments

x

E.g. a time series.


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

Description

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

Usage

.postAR1(Y, phi, phi0, Q0, sigma, lb = -Inf, ub = Inf)

Arguments

Y

a Tn x 1 vector.

phi

a scalar containing the last draw of the autoregressive parameter \phi.

phi0

a scalar containing the prior mean for phi.

Q0

a scalar containing the prior precision for phi.

sigma

a scalar containing the innovation variance.

lb

(optional) lower bound for phi.

ub

(optional) upper bound for phi.

Details

The corresponding model is given by Y_t = \phi Y_{t-1} + e_t, where e_t ~ N(0, \sigma) with prior distribution p(\phi) = N(\phi_0, 1/Q_0 ).

Conditional on the variance \sigma, the posterior is normal and known.

Stationarity and box constraints are enforced. If the stationarity constraint is not fulfilled, the last draw is returned.


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

Description

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

Usage

.postARp(Y, phi, phi0, Q0, sigma, lb = -Inf, ub = Inf)

Arguments

Y

A Tn x 1 vector with the time series.

phi

a 1 x p vector containing the last draw of the autoregressive parameters \phi. p has to be larger than one.

phi0

a 1 x p vector containing the prior mean for phi.

Q0

a p x p matrix containing the prior precision for phi.

sigma

a scalar containing the innovation variance.

lb

(optional) 1 x p vector with lower bounds for phi.

ub

(optional) 1 x p vector with upper bounds for phi.

Details

The corresponding model is given by Y_t = \phi_1 Y_{t-1} + ... + \phi_p Y_{t-p} + e_t, where e_t ~ N(0, \sigma) with prior distribution p(\phi) = N(\phi_0, 1/Q_0 ).

The posterior draw is obtained via a Metropolis Hastings step with proposal density q = \prod_{t=p+1}^Tn p(Y_t, \phi, \sigma, Y_{t-1}, ..., Y_{t-p} ) which is known due to conjugacy. The acceptance probability is given by \alpha = \min{1, p(Y_1, ... Y_p | \phi_r, \sigma) / p(Y_1, ... Y_p | \phi_{r-1}, \sigma)} where the subscript r denotes the r-th draw. p(Y_1, ... Y_p | \phi_r, \sigma) is itself normal.

Stationarity and box constraints are enforced. If the constraints are not fulfilled, the last draw is returned.


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

Description

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

Usage

.postNIG(Y, X, betaLast, betaDistr, sigmaDistr)

Arguments

Y

A Tn x 1 vector with the dependent variable.

X

A Tn x k matrix with the k explanatory variables.

betaLast

A k x 1 vector containing the last draw.

betaDistr

A 4 x k matrix with prior distribution and box constraints for the parameters of each variable. In each column, the first two entries contain the prior hyperparameters and the last two entries the upper and lower bound.

sigmaDistr

A 1 x k matrix with prior distribution and box constraints for the innovation variance. The first two entries contain the prior hyperparameters and the last two entries the upper and lower bound.

Details

Draws from the posterior are obtained by conjugacy of the Normal-Inverse-Gamma distribution.

Value

A list with a draws for beta and the innovation variance.


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

Description

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

Usage

.postRW(Y, sigmaDistr, sigmaLast = NULL, muDistr = NULL)

Arguments

Y

A Tn x 1 vector with the dependent variable.

sigmaDistr

A 1 x k matrix with prior distribution and box constraints for the innovation variance. The first two entries contain the prior hyperparameters and the last two entries the upper and lower bound.

sigmaLast

A scalar containing the last draw of the innovation variance.

muDistr

A k x 1 matrix with prior distribution and box constraints for the constant trend. The first two entries contain the prior hyperparameters and the last two entries the upper and lower bound.

Details

If the process follows a random walk with constant drift, the two parameters are drawn sequentially (conditional on the other parameter). The constant is drawn from a normal posterior given by conjugacy.

The innovation variance is drawn from a Inverse-Gamma posterior given by conjugacy.


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

Description

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

Usage

.printGeweke(tsl, df, alpha = 0.05)

Arguments

tsl

A multiple time series list containing the Geweke test statistic for the states.

df

A data frame containing the Geweke test statistic for the parameters.

alpha

The significance level used to reach a test decision, a scalar between zero and one.


Prints the model specifications.

Description

Prints the model specifications.

Usage

.printSSModel(x, call = TRUE, check = TRUE)

Arguments

x

An object of class NAWRUmodel, TFPmodel, or KuttnerModel.

call

A logical. If TRUE, the call will be printed.

check

A logical. If TRUE, the model class will be checked.


Prints the model fit and possibly specifications.

Description

Prints the model fit and possibly specifications.

Usage

.printSSModelFit(x, call = TRUE, check = TRUE, print.model = TRUE)

Arguments

x

An object of class NAWRUmodel, TFPmodel, or KuttnerModel.

call

A logical. If TRUE, the call will be printed.

check

A logical. If TRUE, the model class will be checked.

print.model

A logical indicating whether the model specification should be printed.


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

Description

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

Usage

.priorMSd2Parameter(
  prior,
  restr,
  namesInvGammaDistr,
  namesNormalDistr,
  namesBetaDistr
)

Arguments

prior

A matrix containing the mean and standard deviation of the priors.

restr

A matrix containing box constraints for the parameters.

namesInvGammaDistr

A character vector specifying the names of all inverse Gamma distributed parameters.

namesNormalDistr

A character vector specifying the names of all normally distributed parameters.

namesBetaDistr

A character vector specifying the names of all Beta distributed parameters.


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

Description

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

Usage

.updateParConstraints(model, parRestr)

Arguments

model

A model of class NAWRUmodel or TFPmodel.

parRestr

A list of matrices containing the parameter restrictions for the cycle, trend, and the Phillip's curve. Each matrix contains the lower and upper bound of the involved parameters. NA implies that no restriction is present. Autoregressive parameters are automatically restricted to the stationary region unless box constraints are specified. By default, parRestr is initialized by the function initializeRestr(model). Only used if method = "MLE".

Value

The same model with updated list item loc.


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

Description

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

Usage

.updateSSSystem(
  pars,
  SSModel,
  loc,
  cycle,
  trend,
  errorARMA,
  signalToNoise = NULL,
  type = NULL,
  bayes = FALSE
)

Arguments

pars

A vector of parameters.

SSModel

An object of class SSModel specifying the state-space model.

loc

A data frame containing information on each involved parameter, for instance its corresponding system matrix, variable names, and parameter restrictions.

cycle

A character string specifying the cycle model. cycle = "AR1" denotes an AR(1) process, cycle = "AR2" an AR(2) process. The default is cycle = "AR2".

trend

A character string specifying the trend model. trend = "RW1" denotes a first order random walk, trend = "RW2" a second order random walk (local linear trend) and trend = "DT" a damped trend model. The default is trend = "RW2".

errorARMA

A vector with non-negative integers specifying the AR and MA degree of the error term in the second observation equation.

signalToNoise

(Optional) signal to noise ratio. Only used if method = "MLE".

type

A character string specifying the type of the Phillip's curve. type = "TKP" denotes the traditional Keynesian Phillip's curve and type = "NKP" the New Keynesian Phillip's curve, see details. The default is type = "TKP".

bayes

A logical indicating whether the update is part of a Bayesian procedure, i.e., the parameter constraints do not need to be enforced.


Extracts the derivative of the applied restriction function.

Description

Extracts the derivative of the applied restriction function.

Usage

Dconstraint(par, type = NA)

Arguments

par

names vector with parameters

type

character with constraint type


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.

Description

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.

Usage

FUNcov(Xcubs, Xc, Y, mu, phi, beta, sigma, phiC, sigmaC)

Arguments

Xcubs

matrix containing lags of cubs.

Xc

matrix containing the contemporaneous cycle and lags thereof..

Y

a Tn x 1 vector.

mu

constant parameter.

phi

cubs lag coeefficients.

beta

cycle coefficients.

sigma

innovation variance.

phiC

cycle process parameter vector.

sigmaC

cycle innovation variance


Computes the approximate highest posterior density interval (HPDI).

Description

Computes the approximate highest posterior density interval (HPDI).

Usage

HPDinterval(x, prob = 0.95)

Arguments

x

A R x n matrix with R draws of n variables.

prob

The probability mass of the interval, a scalar between zero and one.


Kuttner model

Description

Creates a state space object object of class KuttnerModel which can be fitted using fit.

Usage

KuttnerModel(
  tsl,
  cycle = "AR2",
  cycleLag = 1,
  trend = "RW1",
  inflErrorARMA = c(0, 3),
  start = NULL,
  end = NULL,
  anchor = NULL,
  anchor.h = NULL
)

Arguments

tsl

A list of time series objects, see details.

cycle

A character string specifying the cycle model. cycle = "AR1" denotes an AR(1) process, cycle = "AR2" an AR(2) process. The default is cycle = "AR2".

cycleLag

A non-negative integer specifying the maximum cycle lag that is included in the inflation equation. The default is cycleLag = 0, see details.

trend

A character string specifying the trend model. trend = "RW1" denotes a first order random walk, trend = "RW2" a second order random walk (local linear trend) and trend = "DT" a damped trend model. The default is trend = "RW1".

inflErrorARMA

A 2 x 1 vector with non-negative integers specifying the AR and MA degree of the error term in the inflation equation. The default is inflErrorARMA = c(0, 3), see details.

start

(Optional) Start vector for the estimation, e.g. c(1980, 1).

end

(Optional) End vector for the estimation, e.g. c(2020, 1).

anchor

(Optional) Anchor value for the logarithm of trend gdp.

anchor.h

(Optional) Anchor horizon in the frequency of the given time series.

Details

The list of time series tsl needs to have the following components:

gdp

Real gross domestic product.

infl

Inflation.

A cycleLag equal to 0 implies that only the contemporaneous cycle is included in the inflation equation. A cycleLag equal to 0:1 implies that the contemporaneous as well as the lagged cycle are included.

A inflErrorARMA equal to c(0, 0) implies that the error term in the inflation equation is white noise. inflErrorARMA = c(1, 0) implies that the error is an AR(1) process and for inflErrorARMA = c(1, 2) the error follows an ARMA(1, 2) process.

Value

Object of class KuttnerModel, which is a list with the following components:

tsl

A list of used time series.

SSModel

An object of class SSModel specifying the state-space model.

loc

A data frame containing information on each involved parameter, for instance its corresponding system matrix, variable names, and parameter restrictions.

call

Original call to the function.

In addition, the object contains the following attributes:

cycle

Cycle specification.

trend

Trend specification.

inflation equation

A list containing the components cycleLag, errorARMA, exoVariables.

anchor

A list containing the components value, horizon.

period

A list containing the components start, end, frequency.

Examples

# load data for the Netherlands
data("gap")
country <- "Netherlands"
tsList <- as.list(gap[[country]][, c("cpih", "gdp")])
tsList$infl <- diff(tsList$cpih)
model <- KuttnerModel(tsl = tsList, trend = "RW2", start = 1980)

NAWRU model

Description

Creates a state space object object of class NAWRUmodel which can be fitted using fit.

Usage

NAWRUmodel(
  tsl,
  trend = "RW2",
  cycle = "AR2",
  type = "TKP",
  cycleLag = 0,
  pcErrorARMA = c(0, 0),
  exoType = NULL,
  start = NULL,
  end = NULL,
  anchor = NULL,
  anchor.h = NULL
)

Arguments

tsl

A list of time series objects, see details.

trend

A character string specifying the trend model. trend = "RW1" denotes a first order random walk, trend = "RW2" a second order random walk (local linear trend) and trend = "DT" a damped trend model. The default is trend = "RW2".

cycle

A character string specifying the cycle model. cycle = "AR1" denotes an AR(1) process, cycle = "AR2" an AR(2) process. The default is cycle = "AR2".

type

A character string specifying the type of the Phillip's curve. type = "TKP" denotes the traditional Keynesian Phillip's curve and type = "NKP" the New Keynesian Phillip's curve, see details. The default is type = "TKP".

cycleLag

A vector specifying the cycle lags that are included in the Phillip's curve. The default is cycleLag = 0, see details.

pcErrorARMA

A 2 x 1 vector with non-negative integers specifying the AR and MA degree of the error term in the Phillip's curve equation. The default is pcErrorARMA = c(0, 0), see details.

exoType

An optional n x m x 2 array specifying the possible difference and lag transformation for the variables. exoType can be initialized using the function inizializeExo. The column names give the variable names. exoType[, , 1] contains the difference transformations and exoType[, , 2] the subsequent lag transformations, see details.

start

(Optional) Start vector for the estimation, e.g. c(1980, 1).

end

(Optional) End vector for the estimation, e.g. c(2020, 1).

anchor

(Optional) Anchor value for the unemployment rate.

anchor.h

(Optional) Anchor horizon in the frequency of the given time series.

Details

The list of time series tsl needs to have the following components:

ur

Unemployment rate.

nulc

Nominal Unit labor costs, if type = "TKP".

rulc

Real unit labor costs, if type = "NKP".

and optionally other variables included in exoType.

A cycleLag equal to 0 implies that only the contemporaneous cycle is included in the Phillip's curve. A cycleLag equal to 0:1 implies that the contemporaneous as well as the lagged cycle are included.

A pcErrorARMA equal to c(0, 0) implies that the error term in the Phillip's curve is white noise. pcErrorARMA = c(1, 0) implies that the error is an AR(1) process and for pcErrorARMA = c(1, 2) the error follows an ARMA(1, 2) process.

For the New Keynesian Phillip's curve, the cycleLag cannot be chosen. cycleLag will be set to 0 if cycle = "AR1" and to 1 if cycle = "AR2". In the latter case, the forward solution of the Phillip's curve implies parameter restrictions for the lagged cycle on the Phillip's curve. Moreover, exogenous variables will be ignored in the case of the New Keynesian Phillip's curve.

The array exoType consists of non-negative integers or NAs. exoType[, , 1] = c(NA,1) and exoType[, , 2] = c(NA,2) implies that the first variable is not included in the Phillip's curve whereas the second lag of the first difference of the second variable is included.

Value

Object of class NAWRUmodel, which is a list with the following components:

tsl

A list of used time series.

SSModel

An object of class SSModel specifying the state-space model.

loc

A data frame containing information on each involved parameter, for instance its corresponding system matrix, variable names, and parameter restrictions.

call

Original call to the function.

In addition, the object contains the following attributes:

cycle

Cycle specification.

trend

Trend specification.

phillipsCurve

A list containing the components type, cycleLag, errorARMA, exoVariables.

anchor

A list containing the components value, horizon.

period

A list containing the components start, end, frequency.

Examples

# load data for France
data("gap")
tsList <- amecoData2input(gap$France, alpha = 0.65)
# Traditional phillips curve
model <- NAWRUmodel(tsl = tsList, trend = "RW2", cycle = "AR2", type = "TKP", cycleLag = 0)

# New-Keynesian Phillips curve
model <- NAWRUmodel(tsl = tsList, trend = "RW2", cycle = "AR2", type = "NKP", cycleLag = 0:1)

# Traditional Phillips curve with 6 exogenous variables
# specify exogenous variable transformations
D <- matrix(c(2, 2, 2, 1, 1, 1), 2, 3, byrow = TRUE)
L <- matrix(c(0, 0, 0, 1, 1, 1), 2, 3, byrow = TRUE)
exoType <- initializeExo(varNames = c("tot", "prod","ws"), D = D, L = L)
model <- NAWRUmodel(tsl = tsList, cycleLag = 0:1, exoType = exoType)

TFP trend model

Description

Creates a state space object object of class TFPmodel which can be fitted using fit.

Usage

TFPmodel(
  tsl,
  trend = "DT",
  cycle = "AR2",
  cycleLag = 0,
  cubsAR = 0,
  cubsErrorARMA = c(0, 0),
  start = NULL,
  end = NULL,
  anchor = NULL,
  anchor.h = NULL
)

Arguments

tsl

A list of time series objects, see details.

trend

A character string specifying the trend model. trend = "RW1" denotes a first order random walk, trend = "RW2" a second order random walk (local linear trend) and trend = "DT" a damped trend model. The default is trend = "DT".

cycle

A character string specifying the cycle model. cycle = "AR1" denotes an AR(1) process, cycle = "AR2" an AR(2) process, cycle = "RAR2" a reparametrized AR(2) process. The default is cycle = "AR2".

cycleLag

A non-negative integer specifying the maximum cycle lag that is included in the CUBD equation. The default is cycleLag = 0, see details.

cubsAR

A non-negative integer specifying the maximum CUBS lag that is included in the CUBS equation. The default is cubsAR = 0, see details.

cubsErrorARMA

A vector with non-negative integers specifying the AR and MA degree of the error term in the CUBS equation. The default is cubsErrorARMA = c(0, 0), see details.

start

(Optional) Start vector for the estimation, e.g. c(1980, 1).

end

(Optional) End vector for the estimation, e.g. c(2020, 1).

anchor

(Optional) Snchor value for the log of the TFP trend.

anchor.h

(Optional) Anchor horizon in the frequency of the given time series.

Details

The list of time series tsl needs to have the following components:

tfp

Total factor productivity.

cubs

Capacity utilization economic sentiment indicator.

A cycleLag equal to 0 implies that only the contemporaneous cycle is included in the CUBS equation. A cycleLag equal to 0:1 implies that the contemporaneous as well as the lagged cycle are included.

A cubsAR equal to 0 implies that no autoregressive term is included in the CUBS equation. cubsAR = 1 implies that a lagged term is included, cubsAR = 2 implies that a two lags are included, and so on.

A cubsErrorARMA equal to c(0, 0) implies that the error term in the CUBS equation is white noise. cubsErrorARMA = c(1, 0) implies that the error is an AR(1) process and for cubsErrorARMA = c(1, 2) the error follows an ARMA(1, 2) process.

Value

Object of class TFPmodel, which is a list with the following components:

tsl

A list of used time series.

SSModel

An object of class SSModel specifying the state-space model.

loc

A data frame containing information on each involved parameter, for instance its corresponding system matrix, variable names, and parameter restrictions.

call

Original call to the function.

In addition, the object contains the following attributes:

cycle

Cycle specification.

trend

Trend specification.

cubs

A list containing the components cycleLag, cubsAR, errorARMA, exoVariables.

anchor

A list containing the components value, horizon.

period

A list containing the components start, end, frequency.

Examples

# load data for Germany
data("gap")
data("indicator")
country <- "Germany"
tsList <- amecoData2input(gap[[country]], alpha = 0.65)

# compute cubs indicator
namesCubs <- c("indu", "serv", "buil")
namesVACubs <- paste0("va", namesCubs)
tscubs <- cubs(
  tsCU = gap[[country]][, namesCubs],
  tsVA = gap[[country]][, namesVACubs]
)
tsList <- c(tsList, tscubs)

# define tfp model
model <- TFPmodel(tsl = tsList, cycle = "RAR2", cubsErrorARMA = c(1,0))

Data for estimation

Description

Computes the necessary input data for the EC output gap estimation on the basis of AMECO data.

Usage

amecoData2input(tslAmeco, alpha = 0.65)

Arguments

tslAmeco

A time series list or a multiple time series object containing AMECO data.

alpha

A number between 0 and 1 indicating the labor share. The default is alpha = 0.65.

Details

The list of time series tslAmeco needs to have the following components:

popw

Population: 15 to 64 years (unit: 1000 persons, code: NPAN)

ur

Unemployment rate, total; Member States: definition EUROSTAT (unit: Percentage of civilian labor force, code: ZUTN)

etd

Employment, persons: total economy (National accounts) (unit: 1000 persons, code: NETN)

et

Employment, persons: all domestic industries (National accounts) (unit: 1000 persons, code: NETD)

eet

Employees, persons: all domestic industries (National accounts) (unit: 1000 persons, code: NWTD)

pconsp

Price deflator private final consumption expenditure (unit: National currency reference year = 100, code: PCPH)

ngdp

Gross domestic product at current prices (unit: bn National currency, code: UVGD)

gdp

Gross domestic product at constant prices (unit: bn National currency, code: OVGD)

l

Total annual hours worked: total economy (unit: millions, code: NLHT)

wtotal

Compensation of employees: total economy (unit: bn National currency, code: UWCD)

nulc

Nominal unit labour costs: total economy (Ratio of compensation per employee to real GDP per person employed.) (unit: National currency reference year = 100, code: PLCD)

k

Net capital stock at constant prices: total economy (unit: bn National currency, code: OKND)

Value

A list of time series containing the same components as the input list tslAmeco and the following additional components:

gdpdefl

Gross domestic product deflator

tfp

Total factor productivity

lfnd

Labor force non-domestic (unit: 1000 persons)

parts

Participation rate

ahours

Average hours worked (unit: hours)

prod

Labor productivity (unit: real output in millions per person)

tot

Terms of trade (pconcp / gdpdefl)

ws

Wage share (unit: compensation per unit of nominal output)

winfl

Wage inflation

rulc

Real unit labor costs

Examples

# load data for Germany
data("gap")
country <- "Germany"
tsListRaw <- gap[[country]]
tsListInput <- amecoData2input(tslAmeco = tsListRaw)

Applies suitable contraining functions to parameters.

Description

Applies suitable contraining functions to parameters.

Usage

assignConstraints(par, loc)

Arguments

par

names vector with parameters

loc

A data frame containing information on each involved parameter (list element of objects of class NAWRUmodel, TFPmodel, KuttnerModel).


Fit best production function model

Description

Finds the most suitable model for the NAWRU and the TFP trend according to the BIC or the RMSE. The function computes the output gap based on the chosen models.

Usage

autoGapProd(
  tsl,
  type = "hp",
  q = 0.01,
  method = "MLE",
  criterion = "BIC",
  fast = TRUE,
  nModels = 5,
  nawruPoss = list(maxCycleLag = 2, trend = c("RW2", "DT"), cycle = c("AR1", "AR2"),
    errorARmax = 1, errorMAmax = 0, type = c("TKP", "NKP"), exoNames = c("ws", "prod",
    "tot"), signalToNoise = NULL),
  tfpPoss = list(maxCycleLag = 2, trend = c("RW2", "DT"), cycle = c("AR1", "AR2",
    "RAR2"), cubsARmax = 0, errorARmax = 1, errorMAmax = 0, signalToNoise = NULL),
  auto = "gap"
)

Arguments

tsl

A list of time series objects, see details.

type

The variance restriction type. Possible options are "basic", "hp", see initializeRestr. The default is type = "hp".

q

Quantile for the Inverse Gamma distribution (only used if type = "hp"), see initializeRestr. The default is q = 0.01.

method

The estimation method. Options are maximum likelihood estimation "MLE" and bayesian estimation "bayesian". If method = c("MLE", "bayesian") the NAWRU is fitted by MLE and the TFP trend by Bayesian methods. The default is method = "MLE".

criterion

Model selection criterion. Options are the Bayesian information criterion "BIC" and the root mean squared error "RMSE", both computed for the second observation equation. The default is criterion = "BIC". For Bayesian estimation and criterion = "RMSE", the mean RMSE is used.

fast

Boolean, indicating whether a "fast" procedure should be used, see details.

nModels

Integer, the maximum number of models for each unobserved component model.

nawruPoss

List with possible model specifications for the NAWRU, see details.

tfpPoss

List with possible model specifications for the NAWRU, see details.

auto

If auto = "NAWRU" or auto = "TFP", the function only finds the most suitable NAWRU or TFP model, respectively. The default is auto = "gap".

Details

For fast = TRUE, the function pre-selects suitable models by applying the following procedure: A HP-filtered trend is computed based on which the best trend and cycle models are chosen according to the BIC. Also based on the HP trend, a variety of different specifications for the second observation equation are estimated in a univariate regression and the best models are selected via the BIC. The nModels best models are subsequently estimated in the usual bivariate unobserved component model. For fast = FALSE, a variety of models is estimated in the usual bivariate unobserved component framework.

The input component nawruPoss is a list containing a (sub-) set of the following components:

maxCycleLag

Maximum cycle lag included in the second observation equation.

trend

Trend model specification.

cycle

Cycle model specification.

errorARmax

Maximum autoregressive order of the error term in the second observation equation.

errorMAmax

Maximum moving average order of the error term in the second observation equation.

type

Type of Phillip's curve.

exoNames

Names of the exogenous variables potentially included in the Phillip's curve (need to be included in the list of time series tsl).

signal-to-noise

Signal-to-noise ratio.

The input component tfpPoss is a list containing a (sub-) set of the following components:

maxCycleLag

Maximum cycle lag included in the second observation equation.

trend

Trend model specification.

cycle

Cycle model specification.

cubsARmax

Maximum CUBS autoregressive order.

errorARmax

Maximum autoregressive order of the error term in the second observation equation.

errorMAmax

Maximum moving average order of the error term in the second observation equation.

signal-to-noise

Signal-to-noise ratio.

The list of time series tsl needs to have the following components (plus those series included in the list component exoNames in nawruPoss):

ur

Unemployment rate.

nulc

Nominal Unit labor costs, if type = "TKP".

rulc

Real unit labor costs, if type = "NKP".

tfp

Total factor productivity.

cubs

Capacity utilization economic sentiment indicator.

lfnd

Labor force non-domestic (unit: 1000 persons).

parts

Participation rate.

ahours

Average hours worked (unit: hours).

gdp

Gross domestic product at constant prices (unit: bn National currency, code: OVGD).

k

Net capital stock at constant prices: total economy (unit: bn National currency, code: OKND).

popw

Population: 15 to 64 years (unit: 1000 persons, code: NPAN).

The set of tested models is extensive but not exhaustive. The best model is solely based on convergence and the chosen criterion (RMSE or BIC). A manual check of the results is highly recommended.

In some cases, more than nModels are checked. For instance, if a re-parametrized and regular AR(2) process are options for the cycle.

Value

A list containing three components: gap (the best model of class "gap"), tfp (a nested list of TFP models, fitted objects and model fit criteria), nawru (a nested list of NAWRU models, fitted objects and model fit criteria). The lists nawru and tfp contain a list of models, a list of fitted objects and a dataframe info, which contains

loglik

log-likelihood function at optimum

AIC

Akaike information criterion

BIC

Bayesian information criterion

HQC

Hannan-Quinn information criterion

RMSE

Root mean squared error

R2

Coefficient of determination (R squared)

signal-to-noise

Signal-to-noise ratio

LjungBox

p-value of Ljung-Box test for autocorrelation (H0 = no autocorrelation)

convergence

0 indicates convergence of the optimization

rrange

relative range of trend series w.r.t original series

neg

1 indicates that negative values are present in the trend series

rev

relative excess volatility w.r.t. original series (stationary series)

rsd

relative standard deviation w.r.t. original series (stationary series)

cor

correlation between trend and original series (stationary series)

msdtg

mean standardized deviation (stationary trend)

magtg

mean absolute growth of trend (stationaty trend)

drop

1 indicates the model should be dropped


NAWRU model suggestion

Description

Finds the most suitable NAWRU models.

Usage

autoNAWRUmodel(tsl, poss, nModels = 10)

Arguments

tsl

A list of time series objects, see details.

poss

A list with the characteristics of possible models (see autoGapProd)

nModels

Integer, the maximum number of models for each unobserved component model.

Value

A nested list with one model specification per list entry.


TFP model suggestion

Description

Finds the most suitable TFP models.

Usage

autoTFPmodel(tsl, poss, nModels = 10)

Arguments

tsl

A list of time series objects, see details.

poss

A list with the characteristics of possible models (see autoGapProd)

nModels

Integer, the maximum number of models for each unobserved component model.

Value

A nested list with one model specification per list entry.


Computes the covariance of the estimated parameters given restrictions.

Description

Computes the covariance of the estimated parameters given restrictions.

Usage

computeCovar(par, loc, CV)

Arguments

par

names vector with parameters

loc

A data frame containing information on each involved parameter (list element of objects of class NAWRUmodel, TFPmodel, KuttnerModel).

CV

unconstrained variance covariance matrix


Applies contraints to parameters.

Description

Applies contraints to parameters.

Usage

constraint(par, type = NA)

Arguments

par

names vector with parameters

type

character with constraint type


CUBS indicator

Description

Computes the capacity utilization economic sentiment (CUBS) indicator.

Usage

cubs(tsCU, tsVA, frequency = 1, lambda = NULL)

Arguments

tsCU

A multiple time series containing three survey time series, the first element needs to be capacity utilization in industry, see details. Alternatively, a list of time series can be supplied.

tsVA

A multiple time series containing three value added series that correspond to tsCU. Alternatively, a list of time series can be supplied.

frequency

The frequency of the computed cubs indicator. Possible entries are frequency = 1 (annual), frequency = 4 (quarterly). The default is frequency = 1.

lambda

The smoothing parameter for the application of the HP filter (see details). If not supplied, lambda = 6.25 is used for yearly data and lambda = 1600 for quarterly data.

Details

The list tslCU contains capacity utilization in industry, and the relevant survey outcomes of the construction and service sector. The first list object needs to contain capacity utilization in industry.

The list tslVA contains the real value added series for the industry, construction and service sector in the same order as tslCU.

The computed CUBS indicator consists exclusively of capacity utilization in industry until both other series become available.

Value

A list containing the two time series capacity utilization in industry cu and the CUBS indicator cubs.

Examples

# load data for Germany
data("gap")
country <- "Germany"

# compute cubs indicator
namesCubs <- c("indu", "serv", "buil")
namesVACubs <- paste0("va", namesCubs)
tscubs <- cubs(
  tsCU = gap[[country]][, namesCubs],
  tsVA = gap[[country]][, namesVACubs]
)

Find suitable cycle specification

Description

Finds the most suitable cycle model according to the BIC.

Usage

cycleOptim(x, opt = c("AR1", "AR2", "RAR2"))

Arguments

x

A time series.

opt

A character vector with the cycle models to be tested. The default is opt = c("AR1", "AR2", "RAR2").

Value

A character string with the chosen cycle model.


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

Description

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

Usage

dateTsList(x, FUN1 = start, FUN2 = max)

Arguments

x

A list.

FUN1

A function, namely either start or end from stats.

FUN2

A function, namely either max or min from base.


Extracts the relevant 'AMECO' data

Description

Extracts the relevant 'AMECO' data

Usage

extract_ameco_data(df)

Arguments

df

A data frame containing all macro-economic 'AMECO' data.


Extracts the relevant 'AMECO' indicator data.

Description

Extracts the relevant 'AMECO' indicator data.

Usage

extract_indicator_data(folder)

Arguments

folder

A file path with relevant files.


Current 'AMECO' data vintage

Description

Fetches the 'AMECO' data for the EC output gap estimation from the current vintage.

Usage

fetchAmecoData(country = NULL, cubs = TRUE)

Arguments

country

The country name. If left unspecified, data for all countries will be returned.

cubs

A logical indicating whether the CUBS indicator should be computed if possible (see details).

Details

For the computation of CUBS, the following three seasonally adjusted series are used: the utilization indicators in the service industry, the building and construction industry, and capacity utilization in manufacturing/industry.

The confidence indicator in the service industry is composed of question 1, 2, and 3 of the monthly service sector survey ((Q1 + Q2 + Q3)/3). The underlying survey questions are as follows:

The confidence indicator in the building and construction industry is composed of question 3 and 4 of the monthly building and construction sector survey ((Q3 and Q4)/2). The underlying survey questions are as follows:

The indicator for capacity utilization in manufacturing/industry is based on question 13 of the quarterly industry sector survey. The underlying survey question is as follows:

Value

A list with multiple time series objects for each country. If country is specified, a multiple time series object is returned. For each country, the following series are included:

popw

Population: 15 to 64 years (unit: 1000 persons, code: NPAN)

ur

Unemployment rate, total; Member States: definition EUROSTAT (unit: Percentage of civilian labor force, code: ZUTN)

etd

Employment, persons: total economy (National accounts) (unit: 1000 persons, code: NETN)

et

Employment, persons: all domestic industries (National accounts) (unit: 1000 persons, code: NETD)

eet

Employees, persons: all domestic industries (National accounts) (unit: 1000 persons, code: NWTD)

vaind

Gross value added at constant prices: manufacturing industry (unit: bn National currency, code: OVGM)

vaserv

Gross value added at constant prices: services (unit: bn National currency, code: OVG5)

vabuil

Gross value added at constant prices: building and construction (unit: bn National currency, code: OVG4)

pconsp

Price deflator private final consumption expenditure (unit: National currency reference year = 100, code: PCPH)

cpih

Harmonised consumer price index (All-items, 2015 = 100, code: ZCPIH)

cpin

National consumer price index (All-items, 2015 = 100, code: ZCPIN)

ngdp

Gross domestic product at current prices (unit: bn National currency, code: UVGD)

gdp

Gross domestic product at constant prices (unit: bn National currency, code: OVGD)

gdpdefl

Price deflator gross domestic product (unit: National currency reference year = 100, code: PVGD)

ahours

Average annual hours worked per person employed (unit: Hours, code: NLHA)

l

Total annual hours worked: total economy (unit: millions, code: NLHT)

wtotal

Compensation of employees: total economy (unit: bn National currency, code: UWCD)

nulc

Nominal unit labour costs: total economy (Ratio of compensation per employee to real GDP per person employed.) (unit: National currency reference year = 100, code: PLCD)

k

Net capital stock at constant prices: total economy (unit: bn National currency, code: OKND)

serv

Confidence indicator in the service industry

buil

Confidence indicator in the bulding and construction industry

indu

Capacity utilization in manufacturing/industry

Additionally, if cubs = TRUE, the capacity utilization economic sentiment indicator cubs will be returned.

Source

https://economy-finance.ec.europa.eu/economic-research-and-databases/economic-databases/ameco-database/download-annual-data-set-macro-economic-database-ameco_en

https://economy-finance.ec.europa.eu/economic-forecast-and-surveys/business-and-consumer-surveys_en


Capitalizes the first letter of a string.

Description

Capitalizes the first letter of a string.

Usage

firstLetterUp(x)

Arguments

x

A character.


Fit Method

Description

Defines the fit method.

Usage

fit(model, ...)

Arguments

model

Some model.

...

Some stuff passed on to methods.

Value

Depends on the model object, see documentation of specific methods.

See Also

Other fitting methods: fit.KuttnerModel(), fit.NAWRUmodel(), fit.TFPmodel()


Maximum likelihood estimation of a KuttnerModel

Description

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

Usage

## S3 method for class 'KuttnerModel'
fit(
  model,
  parRestr = initializeRestr(model),
  signalToNoise = NULL,
  control = NULL,
  ...
)

Arguments

model

An object of class KuttnerModel.

parRestr

A list of matrices containing the parameter restrictions for the cycle, trend, and the inflation equation. Each matrix contains the lower and upper bound of the involved parameters. NA implies that no restriction is present. Autoregressive parameters are automatically restricted to the stationary region unless box constraints are specified. By default, parRestr is intitialized by the function initializeRestr(model).

signalToNoise

(Optional) signal to noise ratio.

control

(Optional) A list of control arguments to be passed on to optim.

...

additional arguments to be passed to the methods functions.

Value

An object of class KuttnerFit containing the following components:

model

The input object of class KuttnerModel.

SSMfit

The estimation output from the funtcion fitSSM from KFAS.

SSMout

The filtering and smoothing output from the funtcion KFS from KFAS.

parameters

A data frame containing the estimated parameters, including standard errors, t-statistics, and p-values.

fit

A list of model fit criteria (see below).

call

Original call to the function.

The list component fit contains the following model fit criteria:

loglik

Log-likelihood function value.

AIC

Akaike information criterion.

BIC

Bayesian information criterion.

AIC

Hannan-Quinn information criterion.

RMSE

Root mean squared error of the inflation equation.

R2

R squared of the inflation equation.

LjungBox

Ljung-Box test output of the inflation equation.

See Also

Other fitting methods: fit.NAWRUmodel(), fit.TFPmodel(), fit()

Examples

# load data for the Netherlands
data("gap")
country <- "Netherlands"
tsList <- as.list(gap[[country]][, c("cpih", "gdp")])
tsList$infl <- diff(tsList$cpih)
model <- KuttnerModel(tsl = tsList, trend = "RW2", cycleLag = 1, cycle = "AR2", start = 1980)

# estimate Kutter's model
parRestr <- initializeRestr(model = model, type = "hp")

gapKuttner <- fit(model, parRestr, signalToNoise = 1 / 10)


Estimation of a NAWRUmodel

Description

Estimates a two-dimensional state-space model and performs filtering and smoothing to obtain the NAWRU using either maximum likelihood estimation or bayesian methods.

Usage

## S3 method for class 'NAWRUmodel'
fit(
  model,
  parRestr = initializeRestr(model = model),
  signalToNoise = NULL,
  method = "MLE",
  control = NULL,
  prior = initializePrior(model),
  R = 10000,
  burnin = ceiling(R/10),
  thin = 1,
  HPDIprob = 0.85,
  pointEstimate = "mean",
  MLEfit = NULL,
  ...
)

Arguments

model

An object of class NAWRUmodel.

parRestr

A list of matrices containing the parameter restrictions for the cycle, trend, and the Phillip's curve. Each matrix contains the lower and upper bound of the involved parameters. NA implies that no restriction is present. Autoregressive parameters are automatically restricted to the stationary region unless box constraints are specified. By default, parRestr is initialized by the function initializeRestr(model). Only used if method = "MLE".

signalToNoise

(Optional) signal to noise ratio. Only used if method = "MLE".

method

The estimation method. Options are maximum likelihood estimation "MLE" and bayesian estimation "bayesian". The default is method = "MLE".

control

(Optional) A list of control arguments to be passed on to optim.

prior

A list of matrices with parameters for the prior distribution and box constraints. By default, prior is initialized by initializePrior(model). See details. Only used if method = "bayesian".

R

An integer specifying the number of MCMC draws. The default is R = 10000. Only used if method = "bayesian".

burnin

An integer specifying the burn-in phase of the MCMC chain. The default is burnin = ceiling(R / 10). Only used if method = "bayesian".

thin

An integer specifying the thinning interval between consecutive draws. The default is thin = 1, implying that no draws are dopped. For thin = 2, every second draw is dropped and so on. Only used if method = "bayesian".

HPDIprob

A numeric in the interval (0,1) specifying the target probability of the highest posterior density intervals. The default is HPDIprob = 0.9. Only used if method = "bayesian".

pointEstimate

Posterior distribution's statistic of central tendency. Possible options are "mean" and "median". The default is pointEstimate = "mean". Only used if method = "bayesian".

MLEfit

(Optional) An object of class NAWRUfit which is used for initialization. Only used if method = "bayesian".

...

additional arguments to be passed to the methods functions.

Details

The list object prior contains three list elements cycle, trend, and pcInd. Each list element is a 4 x n matrix where n denotes the number of parameters involved in the respective equation. The upper two elements specify the distribution, the lower two parameters specify box constraints. NA denotes no constraints. Autoregressive parameters are automatically restricted to the stationary region unless box constraints are specified. For instance, prior$cycle[, 1] contains the mean, standard deviation, lower and upper bound for the first variable, in that respective order.

The respective prior distributions are defined through their mean and standard deviation.

The Gibbs sampling procedure is as follows. For each r = 1, ..., R

Value

For maximum likelihood estimation, an object of class NAWRUfit containing the following components:

model

The input object of class NAWRUmodel.

SSMfit

The estimation output from the function fitSSM from KFAS.

SSMout

The filtering and smoothing output from the function KFS from KFAS.

parameters

A data frame containing the estimated parameters, including standard errors, t-statistics, and p-values.

parRestr

A list of matrices containing the enforced parameter constraints.

fit

A list of model fit criteria (see below).

call

Original call to the function.

The list component fit contains the following model fit criteria:

loglik

Log-likelihood function values.

AIC

Akaike information criterion.

BIC

Bayesian information criterion.

AIC

Hannan-Quinn information criterion.

RMSE

root mean squared error of the Phillip's curve equation.

R2

R squared of the Phillip's curve equation.

LjungBox

Ljung-Box test output of the Phillip's curve equation.

signal-to-noise

Signal-to-noise ratio.

For bayesian estimation, an object of class NAWRUfit containing the following components:

model

The input object of class NAWRUmodel.

tsl

A list of time series containing the estimated states.

parameters

A data frame containing the estimated parameters, including standard errors, highest posterior density credible sets.

prior

A list of matrices containing the used prior distributions.

fit

A list of model fit criteria (see below).

call

Original call to the function.

The list component fit contains the following model fit criteria:

R2

R squared of the phillips curve equation,

signal-to-noise

Signal-to-noise ratio.

See Also

Other fitting methods: fit.KuttnerModel(), fit.TFPmodel(), fit()

Examples

# define nawru model for France
data("gap")
country <- "France"
tsList <- amecoData2input(gap[[country]])
model <- NAWRUmodel(tsl = tsList)
# estimate nawru model via MLE
parRestr <- initializeRestr(model = model, type = "hp")

f <- fit(model = model, parRestr = parRestr)

# initialize priors and estimate model via Bayesian methods
prior <- initializePrior(model = model)

f <- fit(model = model, method = "bayesian", prior = prior, R = 5000, thin = 2)


Estimation of a TFPmodel

Description

Estimates a two-dimensional state-space model and performs filtering and smoothing to obtain the TFP trend using either maximum likelihood estimation or bayesian methods.

Usage

## S3 method for class 'TFPmodel'
fit(
  model,
  parRestr = initializeRestr(model = model),
  signalToNoise = NULL,
  method = "MLE",
  control = NULL,
  prior = initializePrior(model),
  R = 10000,
  burnin = ceiling(R/10),
  thin = 1,
  HPDIprob = 0.85,
  pointEstimate = "mean",
  MLEfit = NULL,
  ...
)

Arguments

model

An object of class TFPmodel.

parRestr

A list of matrices containing the parameter restrictions for the cycle, trend, and the CUBS equation. Each matrix contains the lower and upper bound of the involved parameters. NA implies that no restriction is present. Autoregressive parameters are automatically restricted to the stationary region unless box constraints are specified. By default, parRestr is initialized by the function initializeRestr(model). Only used if method = "MLE".

signalToNoise

(Optional) signal to noise ratio. Only used if method = "MLE".

method

The estimation method. Options are maximum likelihood estimation "MLE" and bayesian estimation "bayesian". The default is method = "MLE".

control

(Optional) A list of control arguments to be passed on to optim.

prior

A list of matrices with parameters for the prior distribution and box constraints. By default, prior is initialized by initializePrior(model). See details. Only used if method = "bayesian".

R

An integer specifying the number of MCMC draws. The default is R = 10000. Only used if method = "bayesian".

burnin

An integer specifying the burn-in phase of the MCMC chain. The default is burnin = ceiling(R / 10). Only used if method = "bayesian".

thin

An integer specifying the thinning interval between consecutive draws. The default is thin = 1, implying that no draws are dopped. For thin = 2, every second draw is dropped and so on. Only used if method = "bayesian".

HPDIprob

A numeric in the interval (0,1) specifying the target probability of the highest posterior density intervals. The default is HPDIprob = 0.9. Only used if method = "bayesian".

pointEstimate

Posterior distribution's statistic of central tendency. Possible options are "mean" and "median". The default is pointEstimate = "mean". Only used if method = "bayesian".

MLEfit

(Optional) An object of class TFPfit which is used for initialization. Only used if method = "bayesian".

...

additional arguments to be passed to the methods functions.

Details

The list object prior contains three list elements cycle, trend, and cubs. Each list element is a 4 x n matrix where n denotes the number of parameters involved in the respective equation. The upper two elements specify the distribution, the lower two parameters specify box constraints. NA denotes no constraints. Autoregressive parameters are automatically restricted to the stationary region unless box constraints are specified. For instance, prior$cycle[, 1] contains the mean, standard deviation, lower and upper bound for the first variable, in that respective order.

The respective prior distributions are defined through their mean and standard deviation.

The Gibbs sampling procedure is as follows. For each r = 1, ..., R

Value

For maximum likelihood estimation, an object of class TFPit containing the following components:

model

The input object of class TFPmodel.

SSMfit

The estimation output from the funtcion fitSSM from KFAS.

SSMout

The filtering and smoothing output from the funtcion KFS from KFAS.

parameters

A data frame containing the estimated parameters, including standard errors, t-statistic, and p-values.

parRestr

A list of matrices containing the enforced parameter constraints.

fit

A list of model fit criteria (see below).

call

Original call to the function.

The list component fit contains the following model fit criteria:

loglik

Log-likelihood function values.

AIC

Akaike information criterion.

BIC

Bayesian information criterion.

AIC

Hannan-Quinn information criterion.

RMSE

root mean squared error of the CUBS equation.

R2

R squared of the CUBS equation.

LjungBox

Ljung-Box test output of the CUBS equation.

signal-to-noise

Signal-to-noise ratio.

For bayesian estimation, an object of class TFPfit containing the following components:

model

The input object of class TFPmodel.

tsl

A list of time series containing the estimated states.

parameters

A data frame containing the estimated parameters, including standard errors, highest posterior density credible sets.

prior

A list of matrices containing the used prior distributions.

fit

A list of model fit criteria (see below).

call

Original call to the function.

The list component fit contains the following model fit criteria:

R2

R squared of the CUBS equation.

signal-to-noise

Signal-to-noise ratio.

See Also

Other fitting methods: fit.KuttnerModel(), fit.NAWRUmodel(), fit()

Examples

# load data for Italy
data("gap")
country <- "Italy"
tsList <- amecoData2input(gap[[country]])
# define tfp model
model <- TFPmodel(tsl = tsList, cycle = "RAR2")
# initialize parameter restrictions and estimate model
parRestr <- initializeRestr(model = model, type = "hp")

f <- fit(model = model, parRestr = parRestr)

# Bayesian estimation
prior <- initializePrior(model = model)

f <- fit(model = model, method = "bayesian", prior = prior, R = 5000, thin = 2)


gap data set

Description

A dataset containing economic data on various countries from the 'AMECO' 2018 autumn vintage.

Usage

gap

Format

A list object with 53 country time series objects. Each time series object contains 14 variables:

popw

Population: 15 to 64 years (unit: 1000 persons, code: NPAN)

ur

Unemployment rate, total; Member States: definition EUROSTAT (unit: Percentage of civilian labor force, code: ZUTN)

etd

Employment, persons: total economy (National accounts) (unit: 1000 persons, code: NETN)

et

Employment, persons: all domestic industries (National accounts) (unit: 1000 persons, code: NETD)

eet

Employees, persons: all domestic industries (National accounts) (unit: 1000 persons, code: NWTD)

vaind

Gross value added at 2010 prices: manufacturing industry (unit: bn National currency, code: OVGM)

vaserv

Gross value added at 2010 prices: services (unit: bn National currency, code: OVG5)

vabuil

Gross value added at 2010 prices: building and construction (unit: bn National currency, code: OVG4)

pconsp

Price deflator private final consumption expenditure (unit: National currency 2010 = 100, code: PCPH)

cpih

Harmonised consumer price index (All-items, 2015 = 100, code: ZCPIH)

cpin

National consumer price index (All-items, 2015 = 100, code: ZCPIN)

ngdp

Gross domestic product at current prices (unit: bn National currency, code: UVGD)

gdp

Gross domestic product at 2010 reference levels (unit: bn National currency, code: OVGD)

gdpdefl

Price deflator gross domestic product (unit: National currency 2010 = 100, code: PVGD)

ahours

Average annual hours worked per person employed (unit: Hours, code: NLHA)

l

Total annual hours worked: total economy (unit: millions, code: NLHT)

wtotal

Compensation of employees: total economy (unit: bn National currency, code: UWCD)

nulc

Nominal unit labour costs: total economy (Ratio of compensation per employee to real GDP per person employed.) (unit: National currency 2010 = 100, code: PLCD)

k

Net capital stock at 2010 prices: total economy (unit: bn National currency, code: OKND)

serv

Confidence indicator in the service industry

buil

Confidence indicator in the bulding and construction industry

indu

Capacity utilization in manufacturing/industry

Source

https://economy-finance.ec.europa.eu/economic-research-and-databases/economic-databases/ameco-database_en


HP-filter output gap

Description

Computes a HP filtered output gap.

Usage

gapHP(x, lambda = NULL, end = NULL, start = NULL)

Arguments

x

A time series object containing gdp.

lambda

The smoothing parameter for the application of the HP filter. If not supplied, lambda = 6.25 for yearly data, lambda = 1600 for quarterly data, and lambda = 129600 for monthly data.

end

(optional) A two element vector containing a year and a period specifying the end point for the filter application.

start

(optional) A two element vector containing a year and a period specifying the start point for the filter application.

Value

Object of class gap, which is a list containing the two elements potential and gap and additionally the original time series.


Production function output gap

Description

Computes potential output and the output gap based on a production function methodology.

Usage

gapProd(
  tsl,
  NAWRUfit,
  TFPfit,
  alpha = 0.65,
  start = NULL,
  end = NULL,
  lambda = NULL
)

Arguments

tsl

A list of time series objects, see details.

NAWRUfit

An object of class NAWRUfit obtained via the function fit.

TFPfit

An object of class TFPfit obtained via the function fit.

alpha

A scalar between zero and one depicting the labor share. The default is alpha = 0.65.

start

(optional) A two element vector containing a year and a period specifying the start point for the estimation.

end

(optional) A two element vector containing a year and a period specifying the end point for the estimation.

lambda

The smoothing parameter for the application of the HP filter (see details). If not supplied, lambda = 6.25 for yearly data, lambda = 1600 for quarterly data, and lambda = 129600 for monthly data.

Details

The list of time series tsl needs to have the following components:

lfnd

Labor force non-domestic (unit: 1000 persons). (Set to zero if left unspecified).

parts

Participation rate.

ahours

Average hours worked (unit: hours).

gdp

Gross domestic product at constant prices (unit: bn National currency, code: OVGD).

k

Net capital stock at constant prices: total economy (unit: bn National currency, code: OKND).

popw

Population: 15 to 64 years (unit: 1000 persons, code: NPAN).

The trend of the list components parts, ahours and lfnd (if available) is computed using the Hodrick-Prescott filter with the smoothing constant lambda, unless the supplied time series list tsl contains their trend (for instance, denoted by partsTrend).

Value

Object of class gap, which is a list with the following components:

tsl

List of time series including potential output potential, the output gap gap, all HP-filtered trend series, and all original series.

NAWRUfit

Provided NAWRUfit object.

TFPfit

Provided TFPfit object.

call

Original call to the function.

Examples

# compute the output gap given the previously obtained nawru and trend tfp
data("gap")
country <- "Belgium"
tsList <- amecoData2input(gap[[country]])
modelNAWRU <- NAWRUmodel(tsl = tsList)
modelTFP <- TFPmodel(tsl = tsList, cycle = "RAR2")


fittedNAWRU <- fit(model = modelNAWRU)
fittedTFP <- fit(model = modelTFP)

gapProd(tsl = tsList, NAWRUfit = fittedNAWRU, TFPfit = fittedTFP)


Conducts a Geweke test for convergence of the draws.

Description

Conducts a Geweke test for convergence of the draws.

Usage

gewekeTest(x, frac1 = 0.1, frac2 = 0.5, alpha = 0.05)

Arguments

x

A R x n matrix with R draws of n variables.

frac1

The probability mass of the first interval, a scalar between zero and one.

frac2

The probability mass of the second interval, a scalar between zero and one.

alpha

The significance level used to compute the test decision, a scalar between zero and one.

Details

Under the H0 of convergence, the test statistic is standard normally distributed.

Naturally, frac1 + frac2 is between zero and one.

Value

A list with the following items

h

Test decision.

CD

Convergence Diagnostic (test statistic)

pvalue

The p-value.

alpha

The applied signifcicance level.

frac1

The fraction of data contained in the first interval.

frac2

The fraction of data contained in the second interval.


Growth rate

Description

Computes growth rates for time series.

Usage

growth(ts, k = 1)

Arguments

ts

A time series object.

k

An integer specifying the lag size in the growth computation. The default is k = 1.


model selection fit comparison helper function

Description

Defines and fits models given the input parameters

Usage

helper_fit_comparison(fit, E1name, E1Trendname, E1trans = identity, fitBayes)

Arguments

fit

Fitted object.

E1name

Name of first observation equation.

E1Trendname

Name of trend of first observation equation.

E1trans

Transformation function for the first observation equation..

fitBayes

Fitted Bayesian object.

Value

A data frame with information criteria, other goodness-of-fit measures, convergence status, trend volatility measures.


model comparison helper function

Description

Gets model attributes

Usage

helper_model_comparison(models)

Arguments

models

A list of models.

Value

A data frame with model attributes


model selection helper function

Description

Defines and fits models given the input parameters

Usage

helper_model_fit(FUNmodel, FUNfit, tsl, comb, poss, method, type, q, modelName)

Arguments

FUNmodel

The model fitting function.

tsl

A list of time series objects, see details.

comb

A nested list with one model specification per list entry.

poss

A list with the characteristics of possible models (see autoGapProd)

method

The estimation method. Options are maximum likelihood estimation "MLE" and bayesian estimation "bayesian". If method = c("MLE", "bayesian") the NAWRU is fitted by MLE and the TFP trend by Bayesian methods. The default is method = "MLE".

type

The variance restriction type. Possible options are "basic", "hp", see initializeRestr. The default is type = "hp".

q

Quantile for the Inverse Gamma distribution (only used if type = "hp"), see initializeRestr. The default is q = 0.01.

modelName

Name of the model, i.e., NAWRU or TFP.

Value

A nested list with the models and fitted objects.


HP filter

Description

Applies the Hodrick Prescott Filter.

Usage

hpfilter(x, lambda)

Arguments

x

A univariate time series object.

lambda

The smoothing parameter.

Value

A univariate time series object containing the trend of the original time series.

Examples

# get data for France
data("gap")
country <- "France"
tsList <- amecoData2input(gap[[country]], alpha = 0.65)
hp <- hpfilter(x = tsList$gdp, lambda = 6.25)

Indicators fo CUBS

Description

A dataset containing the service sector confidence indicator, the construction sector confidence indicator and the capacity utilization in manufacturing/industry.

Usage

indicator

Format

A list with 53 nested country lists with time series objects. Each country list contains 3 time series variables:

serv

Confidence indicator in the service industry.

buil

Confidence indicator in the bulding and construction industry.

indu

Capacity utilization in manufacturing/industry.

Details

A dataset containing the seasonally adjusted utilization indicators in the service industry, the building and construction industry, and capacity utilization in manufacturing/industry for all EU countries and some neighboring countries at different frequencies.

The confidence indicator in the service industry is composed of question 1, 2, and 3 of the monthly service sector survey ((Q1 + Q2 + Q3)/3). The underlying survey questions are as follows:

The confidence indicator in the building and construction industry is composed of question 3 and 4 of the monthly building and construction sector survey ((Q3 and Q4)/2). The underlying survey questions are as follows:

The indicator for capacity utilization in manufacturing/industry is based on question 13 of the quarterly industry sector survey. The underlying survey question is as follows:

Source

https://economy-finance.ec.europa.eu/economic-forecast-and-surveys/business-and-consumer-surveys_en


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

Description

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

Usage

inference(parOptim, hessian, loc)

Arguments

parOptim

The vector of optimized parameters, without transformations.

hessian

The hessian from the optimization.

loc

A 3 x n array where n is the number of optimized parameters. The array contains information on the estimated parameters's name (loc[1, ]), its location (loc[2, ]) and possible parameter constraints (loc[3, ]).


Initialization of exogenous variables

Description

Initializes the transformations applied to exogenous variables.

Usage

initializeExo(varNames, D = NULL, L = NULL)

Arguments

varNames

A (k x 1) character vector containing the names of the exogenous variables.

D

A (n x k) matrix containing the difference transformations, see details.

L

A (n x k) matrix containing the lag transformations, see details.

Details

For the matrices D and L, the rows denote different transformations to each of the variables in the columns. NA indicates no transformation.

Value

An array of size (n, k, 2). The [, , 1] specifies the difference order and [, , 2] the lag order.


Initialization of prior distributions

Description

Initializes the prior distributions for a model of class TFPmodel or NAWRUmodel.

Usage

initializePrior(model, MLE = !is.null(MLEfit), MLEfit = NULL)

Arguments

model

An object of class TFPmodel or NAWRUmodel.

MLE

(Optional) A logical indicating whether the MLE estimates should be used for the initialization. The default is MLE = FALSE if MLEfit is not provided and vice versa.

MLEfit

(Optional) An object of class TFPfit or NAWRUfit which is used if MLE = TRUE.

Value

A list of three matrices with parameters for the prior distribution and box constraints. Each list item refers to an equation, namely the cycle, trend, and second observation equation. Each list element is a 4 x n matrix where n denotes the number of parameters involved in the respective equation. The upper two elements specify the distribution, the lower two parameters specify box constraints. NA denotes no constraints. Autoregressive parameters are automatically restricted to the stationary region unless box constraints are specified. The respective prior distributions are defined through their mean and standard deviation. For instance, prior$cycle[, 1] contains the mean, standard deviation, lower and upper bound for the first variable, in that respective order.


Initialization of parameter restrictions

Description

Initializes parameter restrictions for objects of class NAWRUmodel, TFPmodel, or KuttnerModel.

Usage

initializeRestr(model, type = "basic", lambda = NULL, q = 0.01)

Arguments

model

An object of class NAWRUmodel, TFPmodel, or KuttnerModel.

type

The variance restriction type. Possible options are "basic", "hp", see details. The default is type = "basic".

lambda

The smoothing constant for the HP-filter if type = "hp".

q

Quantile for the Inverse Gamma distribution (only used if type = "hp"). The default is q = 0.01.

Details

For type = "hp", the HP filter is applied to the appropriately differences first observation series to obtain its trend and cycle. Subsequently, the specified trend and cycle models are fitted to obtain its innovation variance. Moreover, the second observation series (according to its specification) is fitted to obtain its innovation variance. Lastly, the obtained innovations variances are used to get lower and upper bounds. To that end, the q and 1-q quantiles of the inverse gamma distribution are used, with mean and standard deviation set to the estimated variances.

Value

A list of three matrices containing the parameter restrictions for the cycle, trend, and the second observation equation. Each matrix contains the lower and upper bound of the involved parameters. NA implies that no restriction is present.


KuttnerFit object check

Description

Tests whether the input object is a valid object of class KuttnerFit.

Usage

is.KuttnerFit(object, return.logical = FALSE)

Arguments

object

An object to be tested.

return.logical

If return.logical = FALSE (default), an error message is printed if the object is not of class KuttnerFit. If return.logical = TRUE, a logical value is returned.

Value

A logical value or nothing, depending on the value of return.logical.


KuttnerModel object check

Description

Tests whether the input object is a valid object of class KuttnerModel.

Usage

is.KuttnerModel(object, return.logical = FALSE)

Arguments

object

An object to be tested.

return.logical

If return.logical = FALSE (default), an error message is printed if the object is not of class KuttnerModel. If return.logical = TRUE, a logical value is returned.

Value

A logical value or nothing, depending on the value of return.logical.


NAWRUfit object check

Description

Tests whether the input object is a valid object of class NAWRUfit.

Usage

is.NAWRUfit(object, return.logical = FALSE)

Arguments

object

An object to be tested.

return.logical

If return.logical = FALSE (default), an error message is printed if the object is not of class NAWRUfit. If return.logical = TRUE, a logical value is returned.

Value

A logical value or nothing, depending on the value of return.logical.


NAWRUodel object check

Description

Tests whether the input object is a valid object of class NAWRUmodel.

Usage

is.NAWRUmodel(object, return.logical = FALSE)

Arguments

object

An object to be tested.

return.logical

If return.logical = FALSE (default), an error message is printed if the object is not of class NAWRUmodel. If return.logical = TRUE, a logical value is returned.

Value

A logical value or nothing, depending on the value of return.logical.

Examples

# load data for France
data("gap")
tsList <- amecoData2input(gap$France, alpha = 0.65)

# Traditional phillips curve
model <- NAWRUmodel(tsl = tsList, trend = "RW2", cycle = "AR2", type = "NKP", cycleLag = 0:1)
is.NAWRUmodel(model, return.logical = TRUE)
attr(model, "phillips curve")$cycleLag <- 0
is.NAWRUmodel(model, return.logical = TRUE)

TFPfit object check

Description

Tests whether the input object is a valid object of class TFPfit.

Usage

is.TFPfit(object, return.logical = FALSE)

Arguments

object

An object to be tested.

return.logical

If return.logical = FALSE (default), an error message is printed if the object is not of class TFPfit. If return.logical = TRUE, a logical value is returned.

Value

A logical value or nothing, depending on the value of return.logical.


TFPmodel object check

Description

Tests whether the input object is a valid object of class TFPmodel.

Usage

is.TFPmodel(object, return.logical = FALSE)

Arguments

object

An object to be tested.

return.logical

If return.logical = FALSE (default), an error message is printed if the object is not of class TFPmodel. If return.logical = TRUE, a logical value is returned.

Value

A logical value or nothing, depending on the value of return.logical.

Examples

# load data for Germany
data("gap")
data("indicator")
country <- "Germany"
tsList <- amecoData2input(gap[[country]], alpha = 0.65)

# compute cubs indicator
namesCubs <- c("indu", "serv", "buil")
namesVACubs <- paste0("va", namesCubs)
tscubs <- cubs(
  tsCU = gap[[country]][, namesCubs],
  tsVA = gap[[country]][, namesVACubs]
)
tsList <- c(tsList, tscubs)

# define tfp model
model <- TFPmodel(
  tsl = tsList, trend = "DT", cycle = "RAR2",
  cycleLag = 2, cubsErrorARMA = c(1, 0)
)
is.TFPmodel(model, return.logical = TRUE)
attr(model, "cubs")$cycleLag <- 1
is.TFPmodel(model, return.logical = TRUE)

gap object check

Description

Tests whether the input object is a valid object of class gap.

Usage

is.gap(object, return.logical = FALSE)

Arguments

object

An object to be tested.

return.logical

If return.logical = FALSE (default), an error message is printed if the object is not of class gap. If return.logical = TRUE, a logical value is returned.

Value

A logical value or nothing, depending on the value of return.logical.


Capitalizes the first letter of a string.

Description

Capitalizes the first letter of a string.

Usage

matmult3d(a, b)

Arguments

a

A matrix.


Computes MCMC summary statistics.

Description

Computes MCMC summary statistics.

Usage

mcmcSummary(x, HPDIprob, frac1 = 0.1, frac2 = 0.5)

Arguments

x

A R x n matrix with R draws of n variables.

HPDIprob

The probability mass of the HPDI, a scalar between zero and one.

frac1

The probability mass of the first interval used for the Geweke test, a scalar between zero and one.

frac2

The probability mass of the second interval used for the Geweke test, a scalar between zero and one.

Details

Naturally, frac1 + frac2 is between zero and one.

Value

A data frame with the following columns

Mean

The posterior mean.

Median

The posterior median.

SD

Standard deviation.

HPDI-LB

Highest posterior density credible interval lower bound

HPDI-UB

Highest posterior density credible interval upper bound

Naive SE

Naive Standard error of the mean (ignoring chain autocorrelation.

Time-series SE

Time-series standard error (based on spectral density at 0).

Geweke statistic

The Geweke test statistic.

frac1

The fraction of data contained in the first interval.

frac2

The fraction of data contained in the second interval.


Find suitable 2nd observation specification

Description

Finds the most suitable model for the second observation equation according to the BIC.

Usage

obs2Optim(
  x1,
  x2,
  xexo = NULL,
  errorARmax = 2,
  errorMAmax = 2,
  maxCycleLag = 2,
  maxAR = 2,
  nModels = 1
)

Arguments

x1

A time series, the second observation equation.

xexo

(Optional) A (multiple) time series with exogenous variables.

errorARmax

Integer, maximal AR order of the error process of the 2nd observation equation.

errorMAmax

Integer, maximal MA order of the error process of the 2nd observation equation.

maxCycleLag

Integer, maximal cycle lag included in the 2nd observation equation.

maxAR

Integer, maximal AR order of the time series x2 in the 2nd observation equation. 0 means that no lag is included.

nModels

Integer, maximum number of models chosen to be fitted.

Value

A list containing the chosen parameters: errorAR, errorMA, cycleLag, ar, exo.


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

Description

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

Usage

operTsLists(x, y, operator)

Arguments

x

A list.

y

A list.

operator

mathematical operator in quotation marks, e.g., "*".


Plots for a KuttnerFit object

Description

Plots potential growth and the output gap and gives diagnostic plots based on standardized residuals for objects of class KuttnerFit.

Usage

## S3 method for class 'KuttnerFit'
plot(
  x,
  alpha = 0.05,
  bounds = TRUE,
  path = NULL,
  combine = TRUE,
  prefix = NULL,
  device = "png",
  width = 10,
  height = 3,
  ...
)

Arguments

x

An object of class KuttnerFit.

alpha

The significance level for the trend (alpha in [0,1]). Only used if bounds = TRUE.

bounds

A logical indicating whether significance intervals should be plotted around gdp. The default is bounds = TRUE.

path

An optional file path. If specified, the plots will be saved using the format in device under the given path.

combine

A logical indicating whether the diagnostic plots should be combined or not, the default is TRUE.

prefix

An optional character string to be added to the names of the plots in case path is specified.

device

Device passed on to ggplot for plot saving. Options are "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf".

width

The plot width in case of printing.

height

The plot height in case of printing.

...

Ignored.

Value

No return value, plots are printed.


Plots for a NAWRUfit object

Description

Plots the NAWRU and the Phillip's curve and gives diagnostic plots based on standardized residuals for objects of class NAWRUfit.

Usage

## S3 method for class 'NAWRUfit'
plot(
  x,
  alpha = 0.05,
  bounds = TRUE,
  path = NULL,
  combine = TRUE,
  prefix = NULL,
  posterior = FALSE,
  device = "png",
  width = 10,
  height = 3,
  ...
)

Arguments

x

An object of class NAWRUfit.

alpha

The significance level for the NAWRU (alpha in [0,1]). Only used if bounds = TRUE.

bounds

A logical indicating whether significance intervals should be plotted around the nawru. The default is bounds = TRUE.

path

An optional file path. If specified, the plots will be saved using the format in device under the given path.

combine

A logical indicating whether the diagnostic plots should be combined or not, the default is TRUE.

prefix

An optional character string to be added to the names of the plots in case path is specified.

posterior

A logical indicating whether posterior diagnostics should be plotted. The default is FALSE. Only applied in the case of bayesian estimation.

device

Device passed on to ggplot for plot saving. Options are "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf".

width

The plot width in case of printing.

height

The plot height in case of printing.

...

Ignored.

Value

No return value, plots are printed.


Plots for a TFPfit object

Description

Plots the TFP trend and the CUBS equation and gives diagnostic plots based on standardized residuals for objects of class TFPfit.

Usage

## S3 method for class 'TFPfit'
plot(
  x,
  alpha = 0.05,
  bounds = TRUE,
  path = NULL,
  combine = TRUE,
  prefix = NULL,
  posterior = FALSE,
  device = "png",
  width = 10,
  height = 3,
  ...
)

Arguments

x

An object of class TFPfit.

alpha

The significance level for the TFP trend (alpha in [0,1]). Only used if bounds = TRUE.

bounds

A logical indicating whether significance intervals should be plotted around tfp growth. The default is bounds = TRUE.

path

An optional file path. If specified, the plots will be saved using the format in device under the given path.

combine

A logical indicating whether the diagnostic plots should be combined or not, the default is TRUE.

prefix

An optional character string to be added to the names of the plots in case path is specified.

posterior

A logical indicating whether posterior diagnostics should be plotted. The default is FALSE. Only applied in the case of bayesian estimation.

device

Device passed on to ggplot for plot saving. Options are "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf".

width

The plot width in case of printing.

height

The plot height in case of printing.

...

Ignored.

Value

No return value, plots are printed.


Plots for a gap object

Description

Plots potential output growth and the output gap based on an objects of class gap.

Usage

## S3 method for class 'gap'
plot(
  x,
  contribution = FALSE,
  path = NULL,
  combine = TRUE,
  prefix = NULL,
  device = "png",
  width = 10,
  height = 3,
  ...
)

Arguments

x

An object of class gap.

contribution

A boolean indicating whether the contributions to potential output growth and the output gap should be plotted (only applicable for production function type output gaps).

path

An optional file path. If specified, the plots will be saved using the format in device under the given path.

combine

A logical indicating whether the plots should be combined or not, the default is TRUE.

prefix

An optional character string to be added to the names of the plots in case path is specified.

device

Device passed on to ggplot for plot saving. Options are "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf".

width

The plot width in case of printing.

height

The plot height in case of printing.

...

Ignored.

Value

No return value, plots are printed.


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

Description

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

Usage

plotGap(
  tsl,
  legend,
  title,
  boundName,
  contribution,
  res = NULL,
  namesPrint,
  bounds,
  combine,
  path,
  device,
  width,
  height
)

Arguments

tsl

A list with two multiple time series objects for the first and second plot, respectively.

legend

A list with two character vectors. The first contains the legend names for the first plot and so on.

title

A list with the titles for the first three plots.

boundName

The legend name of the confidence bounds.

contribution

A boolean indicating whether the contributions to potential output growth and the output gap should be plotted (only applicable for production function type output gaps).

res

The residual series as time series. If res = NULL, all graphs related to the residual series will not be plotted.

namesPrint

A character vector containing two names for the first two plots. The remaining names are creates automatically if combine = FALSE.

bounds

A logical indicating whether significance intervals should be plotted around the nawru. The default is bounds = TRUE.

combine

A logical indicating whether the diagnostic plots should be combined or not, the default is TRUE.

path

An optional file path. If specified, the plots will be saved using the format in device under the given path.

device

Device passed on to ggplot for plot saving. Options are "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf".

width

The plot width in case of printing.

height

The plot height in case of printing.


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

Description

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

Usage

plotSSprediction(
  tsl,
  legend,
  title,
  n.ahead,
  boundName,
  res = NULL,
  namesPrint,
  bounds,
  combine,
  path,
  device,
  width,
  height
)

Arguments

tsl

A list with two multiple time series objects for the first and second plor, respectively.

legend

A list with two character vectors. The first contains the legend names for the first plot and so on.

title

A list with the titles for the first three plots.

n.ahead

Integer indicating the forecast horizon.

boundName

The legend name of the confidence bounds.

res

The residual series as time series. If res = NULL, all graphs realted to the residual series will not be plotted.

namesPrint

A character vector containing two names for the first two plots. The remaining names are creates automatically if combine = FALSE.

bounds

A logical indicating whether significance intervals should be plotted around the nawru. The default is bounds = TRUE.

combine

A logical indicating whether the diagnostic plots should be combined or not, the default is TRUE.

path

An optional file path. If specified, the plots will be saved using the format in device under the given path.

device

Device passed on to ggplot for plot saving. Options are "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf".

width

The plot width in case of printing.

height

The plot height in case of printing.


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

Description

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

Usage

plotSSresults(
  tsl,
  legend,
  title,
  boundName,
  res = NULL,
  namesPrint,
  bounds,
  combine,
  path,
  device,
  width,
  height
)

Arguments

tsl

A list with two multiple time series objects for the first and second plor, respectively.

legend

A list with two character vectors. The first contains the legend names for the first plot and so on.

title

A list with the titles for the first three plots.

boundName

The legend name of the confidence bounds.

res

The residual series as time series. If res = NULL, all graphs realted to the residual series will not be plotted.

namesPrint

A character vector containing two names for the first two plots. The remaining names are creates automatically if combine = FALSE.

bounds

A logical indicating whether significance intervals should be plotted around the nawru. The default is bounds = TRUE.

combine

A logical indicating whether the diagnostic plots should be combined or not, the default is TRUE.

path

An optional file path. If specified, the plots will be saved using the format in device under the given path.

device

Device passed on to ggplot for plot saving. Options are "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf".

width

The plot width in case of printing.

height

The plot height in case of printing.


Plots the diagnostic plots of the posterior distribution.

Description

Plots the diagnostic plots of the posterior distribution.

Usage

plot_gibbs_output(
  path = NULL,
  draws,
  parName,
  burnin,
  mu = NULL,
  prec = NULL,
  shape = NULL,
  scale = NULL,
  shape1 = NULL,
  shape2 = NULL,
  ub = NULL,
  lb = NULL,
  prefix = NULL,
  device,
  width,
  height
)

Arguments

path

An optional file path. If specified, the plots will be saved using the format in device under the given path.

draws

the number of draws.

parName

the name of the parameter.

burnin

length of thw burnin phase.

mu

mean for normal distribution

prec

precision for normal distribution

shape

shape for Gamma distribution

scale

scale for Gamma distribution

shape1

shape1 for Beta distribution

shape2

shape2 for Beta distribution

ub

upper bound

lb

lower bound

prefix

An optional character string to be added to the names of the plots in case path is specified.

device

Device passed on to ggplot for plot saving. Options are "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf".

width

The plot width in case of printing.

height

The plot height in case of printing.


Predictions

Description

Computes predictions for an object of class NAWRUfit, TFPfit, or KuttnerFit estimated via MLE or Bayesian methods (objects of class fit).

Usage

## S3 method for class 'fit'
predict(object, n.ahead = 10, exogenous = "mean", returnFit = TRUE, ...)

Arguments

object

An object of class NAWRUfit, TFPfit, or KuttnerFit (objects of class fit).

n.ahead

An integer specifying the prediction horizon.

exogenous

A character string specifying the computation of exogenous variables included in the model (if applicable). Valid options are exogenous = "mean" and exogenous = "last".

returnFit

A logical. If TRUE, an object of the same class as fit where the list entry tsl is replaced. If FALSE, only the new time series list is returned.

...

Ignored.

Value

The fitted object with an updated time series list tsl. If returnFit = FALSE, only the updated time series list is returned.


Predictions for Bayesian estimation

Description

Computes predictions for an object of class NAWRUfit, TFPfit estimated via Bayesian methods.

Usage

predictBayes(fit, n.ahead = 10, exogenous = "mean", returnFit = TRUE)

Arguments

n.ahead

An integer specifying the prediction horizon.

exogenous

A character string specifying the computation of exogenous variables included in the model (if applicable). Valid options are exogenous = "mean" and exogenous = "last".

returnFit

A logical. If TRUE, an object of the same class as fit where the list entry tsl is replaced. If FALSE, only the new time series list is returned.


Predictions for MLE

Description

Computes predictions for an object of class NAWRUfit, TFPfit, KuttnerFit estimated via MLE.

Usage

predictMLE(fit, n.ahead = 10, exogenous = "mean", returnFit = TRUE)

Arguments

n.ahead

An integer specifying the prediction horizon.

exogenous

A character string specifying the computation of exogenous variables included in the model (if applicable). Valid options are exogenous = "mean" and exogenous = "last".

returnFit

A logical. If TRUE, an object of the same class as fit where the list entry tsl is replaced. If FALSE, only the new time series list is returned.


Print KuttnerFit object

Description

Prints the model specifications and the estimation results of an object of class KuttnerFit.

Usage

## S3 method for class 'KuttnerFit'
print(x, ...)

Arguments

x

An object of class KuttnerFit.

...

Ignored.

Value

No return value, results are printed.


Print KuttnerModel object

Description

Prints the model specifications of an object of class KuttnerModel.

Usage

## S3 method for class 'KuttnerModel'
print(x, call = TRUE, check = TRUE, ...)

Arguments

x

An object of class KuttnerModel.

call

A logical. If TRUE, the call will be printed.

check

A logical. If TRUE, the model class will be checked.

...

Ignored.

Value

No return value, model information is printed.


Print NAWRUfit object

Description

Prints the model specifications and the estimation results of an object of class NAWRUfit.

Usage

## S3 method for class 'NAWRUfit'
print(x, ...)

Arguments

x

An object of class NAWRUfit.

...

Ignored.

Value

No return value, results are printed.


Print NAWRUmodel object

Description

Prints the model specifications of an object of class NAWRUmodel.

Usage

## S3 method for class 'NAWRUmodel'
print(x, call = TRUE, check = TRUE, ...)

Arguments

x

An object of class NAWRUmodel.

call

A logical. If TRUE, the call will be printed.

check

A logical. If TRUE, the model class will be checked.

...

Ignored.

Value

No return value, model information is printed.


Print TFPfit object

Description

Prints the model specifications and the estimation results of an object of class TFPfit.

Usage

## S3 method for class 'TFPfit'
print(x, ...)

Arguments

x

An object of class TFPfit.

...

Ignored.

Value

No return value, results are printed.


Print TFPmodel object

Description

Prints the model specifications of an object of class TFPmodel.

Usage

## S3 method for class 'TFPmodel'
print(x, call = TRUE, check = TRUE, ...)

Arguments

x

An object of class TFPmodel.

call

A logical. If TRUE, the call will be printed.

check

A logical. If TRUE, the model class will be checked.

...

Ignored.

Value

No return value, model information is printed.


Print gap object

Description

Prints the model specifications of an object of class gap.

Usage

## S3 method for class 'gap'
print(x, ...)

Arguments

x

An object of class gap.

...

Ignored.

Value

No return value, results are printed.


Trend anchor

Description

Computes the anchored trend given a fitted object of class NAWRUfit, TFPfit, or KuttnerFit.

Usage

trendAnchor(fit, anchor = NULL, h = NULL, returnFit = FALSE)

Arguments

fit

An object of class NAWRUfit, TFPfit, or KuttnerFit.

anchor

A numeric specifying the anchor value. If unspecified, anchor is taken from the object fit (if specified).

h

An integer specifying the anchor horizon in the frequency of the underlying model. If unspecified, h is taken from the object fit (if specified).

returnFit

A logical. If TRUE, an object of the same class as fit including the anchored trend is returned. If FALSE, only the anchored trend time series is returned.

Value

A fitted object if returnFit = TRUE or a time series with the anchored trend.

Examples

# define nawru model for France
data("gap")
tsList <- amecoData2input(gap$France)
model <- NAWRUmodel(tsl = tsList)

# estimate nawru model

f <- fit(model = model)

# compute anchored nawru
anchoredNawru <- trendAnchor(fit = f, anchor = 6.5, h = 10)


Find suitable trend specification

Description

Finds the most suitable trend model according to the BIC.

Usage

trendOptim(x, opt = c("RW1", "RW2", "DT"))

Arguments

x

A time series.

opt

A character vector with the trend models to be tested. The default is opt = c("RW1", "RW2", "DT").

Value

A character string with the chosen trend model.


Trend volatility measures

Description

Computes trend volatility measures.

Usage

trendVolaMeasures(tsOriginal, tsTrend, nDiff)

Arguments

tsOriginal

The original time series.

tsTrend

The trend time series.

nDiff

Integer indicating the order of differencing applied to the input series.

Value

A list containing the different measures.