knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

BayesianDFM

The BayesianDFM package provides relevant functions for running a Bayesian Dynamic Factor Model.

Installation

You can install the development version from GitHub with:

devtools::install_github("h4sci/packagr")

Functions

The following functions are contained in the package:

bvar_jeff comp_f_state draw_lam draw_sig get_ic get_nowcast multimove_gibbs prepare_data *run_model

For further information about the functions, check out the function descriptions.

Example

This is a basic example which shows you how to solve a common problem:

Load and prepare the input data

load("data_UK.Rda")

target <- c("UKGDPM.YQ") # Define target variable

# De-mean & standardize data
Xmat <- prepare_data(flows = data$flows,
                     stocks = data$stocks,
                     inventory,
                     target = target)

yt <- as.matrix(t(Xmat))

Make a in-sample evaluation of the optimal number of factors

IC <- get_ic(Xmat) # Check information criteria

Define the parameters for the model

k <- 2 # number of states (number of factors)

q <- 1 # lag length for state equation
m <- k*q

n <- dim(yt)[1] # Number of variables
Tt <- dim(yt)[2] # Number of high-frequency periods
Ttq <- Tt-q
const <- 0 # choose constant in the state equation (we choose no constant)

Having all the parameters, run the model

out <- run_model(yt,k,q,m,n,Tt,Ttq,const,target)


h4sci/packagr documentation built on Jan. 7, 2021, 10:40 p.m.