knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The BayesianDFM package provides relevant functions for running a Bayesian Dynamic Factor Model.
You can install the development version from GitHub with:
devtools::install_github("h4sci/packagr")
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.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.