Skip to content

About

Experimental Packages to Estimate Local Projection IRFs

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

LocalProjections.jl

CI codecov.io Aqua QA SciML Code Style lifecycle

Estimate local projection impulse response functions using horizon-specific linear regressions.

Installation

using Pkg
Pkg.add(url="https://github.com/gragusa/LocalProjections.jl")

Example

using LocalProjections, DataFrames, CovarianceMatrices, Plots

# Generate sample data
n = 200
shock = randn(n)
y = cumsum(shock) + 0.5 * randn(n)  # y responds to cumulative shocks
df = DataFrame(y = y, shock = shock)

# Estimate local projections: y_{t+h} = α + β * shock_t + ε
# The coefficient β at each horizon h gives the impulse response
lp_result = lp(@formula(leads(y) ~ shock), df; horizon=20)

# Use HAC-robust standard errors (Newey-West); the default is HC1
lp_result = lp_result + vcov(Bartlett{NeweyWest}())

# Extract the impulse response function
irf = coefpath(lp_result; term=:shock)
se = stderror(lp_result; term=:shock)

# Plot IRF with 95% confidence bands
plot(lp_result; term=:shock, levels=[0.95])

License

MIT License - see LICENSE for details.

About

Experimental Packages to Estimate Local Projection IRFs

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages