Giter Club home page Giter Club logo

tvargirf's Introduction

tvarGIRF

Travis-CI Build Status Coverage Status Lifecycle: maturing

tvarGIRF is an R package that calculates generalised impulse response functions to reduced form shocks for threshold vector autoregressions estimated using the tsDyn package.

Please note: this package is something I put together quickly for an uncompleted project because the only other implementation of GIRFs in R that existed at the time looks like it implements the bootstrap incorrectly to me. According to the tsDyn wiki, GIRFs are now included in the tsDyn package, so you might have better luck with those.

Installation

Install the lastest released version of the package using the R remotes package:

library(remotes)
install_github("angusmoore/tvarGIRF", ref = "v0.1.4")

You can also install the latest development version:

library(remotes)
install_github("angusmoore/tvarGIRF")

Usage

The library extends the R tsDyn package. The following example illustrates how to create a simple GIRF for a threshold VAR using the zeroyld dataset provided with the tsDyn package.

GIRF is given a reduced form shock - in the example below a shock to only the second variable c(0,1). If you want to use orthoganlised shocks, you should calculate the orthogonalisation yourself and supply the reduced form shock that corresponds to your chosen structural shock. It is up to you to identify shocks; tvarGIRF won't do it for you.

library(tsDyn)
library(tvarGIRF)

# Estimate an example TVAR using the zeroyld dataset included in the tsDyn package
data(zeroyld)
exampleTVAR <- TVAR(zeroyld, lag=2, nthresh=1, thDelay=1, mTh=1, plot=FALSE)

# Calculate GIRFs for a reduced form shock to the second variable (long.run)
girfs <- GIRF(exampleTVAR, c(0,1))

The result contains the generalised impulse responses for each variable in the TVAR to the supplied shock. (NB: Since we have not identified shocks, these GIRFs are not very meaningful; this example is designed only to illustrate how to use the library.)

Package documentation

Documentation for this package can be found here.

tvargirf's People

Contributors

angusmoore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tvargirf's Issues

some bugs of GIRF

Hi~Moore,I have a bug when I run the following code related to GIRF:

code.txt
data1.xlsx

the bugs demostrate that "Error in if (round(z2[i - thDelay], round_digits) <= Thresh[1]) { :
missing value where TRUE/FALSE needed"

And I have tied to figure out the problem but ended up with failure.
Could you please give me some help ? Thanks for your kind consideration.

tvarGIRF with external variable threshold in TVAR

I want to estimate a TVAR with a threshold external to the model.
I cannot get the state-dependent GIRFs and the relative confidence interval. Specifically, I would like to get confidence bound from the empirical distribution of simulated GIRFs, assuming normality.

I run the below code:

data(zeroyld)
x=rnorm(482)
xx=as.vector(x)
xx=as.vector(x,mode="any")
t5<-TVAR(zeroyld, lag=3, nthresh=1, thDelay=1, thVar=xx, gamma=0.248, trim=0.1, mTh=2, plot=FALSE)
library(tvarGIRF)

c1=GIRF(t5, c(0,1),restrict.to=1)

I get an error: c1=GIRF(t5, c(0,1),restrict.to=1)
Error: Simulations of models with external transition variables (argument thVar in TVAR) not supported

So i detach the package tvarGIRF and I calculate the GIRF with GIRF {tsDyn}.
detach("package:tvarGIRF", unload = TRUE)

c2<-GIRF(t5)
A<-plot(c2,
plot_type = c( "line"),
n.ahead = c(1, 5, 10),
var = unique(c2$var)[1],
n_simu = c(50))

This command works but I can not obtain the state-dependent GIRF and the relative confidence intervals.

Thank you in advance,
Antonino

what is the meaning of the red color and underline?

Hi~Moore.Thank you for your related work on GIRF of TVAR. I have some question about the result. And I would appreciate it if you could reply.
After I run the following code
library(tsDyn)
library(tvarGIRF)
data(zeroyld)
exampleTVAR <- TVAR(zeroyld, lag=2, nthresh=1, thDelay=1, mTh=1, plot=FALSE)
girf_full <- GIRF(exampleTVAR4, c(0,1), horizon =10, H = 10, R = 50,restrict.to =NA )
girf_full[["responses"]]

the results show:

short.run long.run

1 -0.00493 0.996
2 0.0380 0.954
3 0.0105 0.888
4 0.0381 0.849
5 0.0828 0.831
6 0.110 0.799
7 0.126 0.795
8 0.105 0.729
9 0.131 0.671
10 0.142 0.643

The color of number " -0.00493" is red. And there are some underlines in the last number of "-0.00493"、“0.0380”、“0.0380”、“0.0380”、“0.0828”. What is the meaning of the red color and these underlines? Does these indicate the negtive number and redundant fractional parts ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.