Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
/ packagr Public archive

Sandbox to Create an R Package

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

h4sci/packagr

Repository files navigation

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)

About

Sandbox to Create an R Package

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages