tidyverts / tidyverts/fable

Impulse response function for nested VAR models

Open
#363 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
588
Forks
71
Avg merge
1h 58m
Merged PRs (30d)
1

Description

Hi there,

I would like to know whether it is possible --after fitting a VAR model across different keys in a tsibble--to display the impulse response functions for each of the keys?

Here's a small example

weather <- nycflights13::weather %>% 
  dplyr::select(origin, time_hour, temp, humid, precip)

weather_ts <- as_tsibble(weather, key = origin, index = time_hour)

weather_day <- weather_ts %>%
    group_by(origin) %>%
    index_by(day = as.Date(time_hour)) %>%
    summarise(
      mean_temp = mean(temp),
      mean_humid = mean(humid),
      mean_precip = mean(precip)
    ) %>%
    update_tsibble(index = day)

fit <- weather_day %>%
  model(
    VAR(vars(mean_precip, mean_humid) ~ AR(1)))
    
fit_coef <- fit %>% 
  tidy(.) 

The example shows lagged effects, e.g., from precip to humidity, for three airports (origin). Now it would be nice to have a way to create a IRF plot for the three keys and scale it to many more keys (although this would surely be messy at some point).

Thanks for suggestions,
Holger

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the grouped tsibble example using model(VAR(vars(mean_precip, mean_humid) ~ AR(1))) and its tidy(.) output. Investigate how impulse response functions could be represented and plotted for each origin key, then define an interface that scales beyond the three-airport example. Done means a documented, tested approach for producing IRF plots across nested VAR models.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.