• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

lucabrugnolini/VectorAutoregressions.jl: Vector autoregressive model in Julia

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

lucabrugnolini/VectorAutoregressions.jl

开源软件地址:

https://github.com/lucabrugnolini/VectorAutoregressions.jl

开源编程语言:

Julia 100.0%

开源软件介绍:

VectorAutoregressions.jl

Vector autoregressive models for Julia

Stable Documenter Build Status Coverage Status codecov

Installation

Pkg.add("https://github.com/lucabrugnolini/VectorAutoregressions.jl")

Introduction

This package is a work in progress for the estimation and identification of Vector Autoregressive (VAR) models.

Status

  • VAR
    • VAR(1) form
    • Lag-length selection
      • AIC
      • AICC
      • BIC
      • HQC
    • VAR impulse response function (IRFs)
      • Identification
        • Reduce form
        • Cholesky
        • Long-run restrictions
        • Sign restrictions
        • Heteroskedasticity
        • External instruments (ex. high-frequency,narrative)
          • Wild bootstrap
      • Confidence bands
        • Asymptotic
        • Bootstrap
        • Bootstrap-after-bootstrap
    • Forecasting
      • BVAR
      • FAVAR
  • Local projection IRFs
    • Lag-length selection
    • Confidence bands
      • Standard
      • Bootstrap
    • Bayesian Local Projection

Example

## Example: fit a VAR(`p`) to the data and derive structural IRFs with asymptotic and bootstrap conf. bands.
using VectorAutoregressions
using DelimitedFiles: readdlm
using Plots
plotly()

# Read example data
path = joinpath(dirname(pathof(VectorAutoregressions)), "..") # set base path to load data
y = readdlm(joinpath(path,"test","cholvar_test_data.csv"), ',') #read example file with data

# Set VAR parameters
intercept = false #intercept in the estimation
p = 2 #select lag-length
H = 15 # IRFs horizon
nrep = 500 #bootstrap sample

# Fit VAR(2) to data
V = VAR(y,p,intercept)

# Estimate IRFs - Cholesky identification
mIRFa = IRFs_a(V,H,intercept) #asymptotic conf. bandf
mIRFb = IRFs_b(V,H,nrep,intercept) #bootstrap conf. bands

# Plot irf + asy ci
T,K = size(y)
pIRF_asy = plot(layout = grid(K,K));
[plot!(pIRF_asy, [mIRFa.CI.CIl[i,:] mIRFa.IRF[i,:] mIRFa.CI.CIh[i,:]], color = ["red" "red" "red"],
line = [:dash :solid :dash], legend = false, subplot = i) for i in 1:K^2]
gui(pIRF_asy)

# Plot irf + bootstraped ci
pIRF_boot = plot(layout = grid(K,K));
[plot!(pIRF_boot, [mIRFb.CI.CIl[i,:] mIRFb.IRF[i,:] mIRFb.CI.CIh[i,:]], color = ["blue" "blue" "blue"],
line = [:dash :solid :dash], legend = false, subplot = i) for i in 1:K^2]
gui(pIRF_boot)

More in details, y is a matrix with data, p is the lag-length of the VAR we fit to the data and i is a Boolean for including an intercept (default is true). VAR(y,p,intercept) returns a fitted VAR(p) model in V with the following structure:

struct VAR
  Y::Array # dep. variables
  X::Array # covariates
  β::Array # parameters
  ϵ::Array # residuals
  Σ::Array # VCV matrix
  p::Int64 # lag-length
  i::Bool # true or false for including an intercept (default is true)
end

You can access to each element writing V. and than the element you are interested in (for example for the covariates V.X).




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap