Skip to content

Commit

Permalink
Remove factor ordering of impulses and responses
Browse files Browse the repository at this point in the history
  • Loading branch information
matdehaven committed May 6, 2024
1 parent 40dbae1 commit 7ff0535
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 46 deletions.
6 changes: 0 additions & 6 deletions R/fev.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ fev <- function(var, n_ahead = 20) {
}
response_names <- n

## Set as factors
impulse_names <-
factor(impulse_names, levels = impulse_names, ordered = TRUE)
response_names <-
factor(response_names, levels = response_names, ordered = TRUE)

## Calculate IRFs out to horizon (then adj to 3-dim matrix from DF)
if (inherits(var, "fevdvar")) {
irf <- vars::irf(var, n.ahead = n_ahead, as_matrix = TRUE)
Expand Down
6 changes: 0 additions & 6 deletions R/fevd.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ fevd.fevdvar <- function(
}
response_names <- n

## Set as factors
impulse_names <-
factor(impulse_names, levels = impulse_names, ordered = TRUE)
response_names <-
factor(response_names, levels = response_names, ordered = TRUE)

class(x) <- "svars"

fevd <- vars::fevd(x, n.ahead = n.ahead, ...)
Expand Down
7 changes: 0 additions & 7 deletions R/fevdfd.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ fevdfd.svars <- function(
impulse_names <- n
response_names <- n

## Set as factors
impulse_names <-
factor(impulse_names, levels = impulse_names, ordered = TRUE)
response_names <-
factor(response_names, levels = response_names, ordered = TRUE)

if (!is.numeric(freqs)) stop("Please provide numeric freqs.")
if (!all(freqs >= 0 & freqs <= 2 * pi)) {
stop("Please provide freqs between 0 and 2pi.")
Expand Down Expand Up @@ -135,7 +129,6 @@ fevdfd.fevdvar <- function(
fevdfd <- fevdfd(var, freqs, grid_size, fev, ...)

impulse_names <- var$impulse_names
impulse_names <- factor(impulse_names, levels = impulse_names, ordered = TRUE)

fevdfd[[1]]$impulse <- rep(impulse_names, each = grid_size * k)

Expand Down
12 changes: 0 additions & 12 deletions R/hd.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ hd.svars <- function(
impulse_names <- colnames(x$y)
response_names <- colnames(x$y)

## Set as factors
impulse_names <-
factor(impulse_names, levels = impulse_names, ordered = TRUE)
response_names <-
factor(response_names, levels = response_names, ordered = TRUE)

## Get historical decompositions
hidec <- lapply(1:k, function(i) {
hidec <- svars::hd(x, series = i)$hidec
Expand Down Expand Up @@ -87,12 +81,6 @@ hd.fevdvar <- function(
impulse_names <- x$impulse_names
response_names <- colnames(x$y)

## Set as factors
impulse_names <-
factor(impulse_names, levels = impulse_names, ordered = TRUE)
response_names <-
factor(response_names, levels = response_names, ordered = TRUE)

## Get historical decompositions
hidec <- lapply(1:k, function(i) {
hidec <- svars::hd(x, series = i)$hidec
Expand Down
8 changes: 0 additions & 8 deletions R/hs.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ hs.svars <- function(
## Set shock names
impulse_names <- colnames(x$y)

## Set as factors
impulse_names <-
factor(impulse_names, levels = impulse_names, ordered = TRUE)

## Get residuals and Sigma
residuals <- stats::resid(x$VAR)
sigma <- x$B
Expand Down Expand Up @@ -89,10 +85,6 @@ hs.fevdvar <- function(
## Set shock names
impulse_names <- x$impulse_names

## Set as factors
impulse_names <-
factor(impulse_names, levels = impulse_names, ordered = TRUE)

## Get residuals and Sigma
residuals <- stats::resid(x$VAR)
sigma <- x$B
Expand Down
5 changes: 0 additions & 5 deletions R/irf.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ irf.fevdvar <- function(
response_names <- colnames(x$y)
impulse_names <- x$impulse_names

## Set as factors
impulse_names <-
factor(impulse_names, levels = impulse_names, ordered = TRUE)
response_names <-
factor(response_names, levels = response_names, ordered = TRUE)

## Represent as state space var
ssv <- as_statespace_var(x$A_hat, x$B)
Expand Down
2 changes: 0 additions & 2 deletions R/irffd.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ irffd.fevdvar <- function(

response_names <- colnames(var$y)
impulse_names <- var$impulse_names
impulse_names <- factor(impulse_names, levels = impulse_names, ordered = TRUE)

df <- data.frame(
f = rep(irffd$freq_grid, times = k * k),
Expand Down Expand Up @@ -138,7 +137,6 @@ irffd.svars <- function(

response_names <- colnames(var$y)
impulse_names <- colnames(var$y)
impulse_names <- factor(impulse_names, levels = impulse_names, ordered = TRUE)

df <- data.frame(
f = rep(irffd$freq_grid, times = k * k),
Expand Down

0 comments on commit 7ff0535

Please sign in to comment.