swap_W_signs: Swap all signs in pointed columns a the W matrix of a...

Description Usage Arguments Details Value References See Also Examples

View source: R/GSMVARconstruction.R

Description

swap_W_signs swaps all signs in pointed columns a the W matrix of a structural GMVAR, StMVAR, or G-StMVAR model. Consequently, signs in the columns of the B-matrix are also swapped accordingly.

Usage

1
swap_W_signs(gsmvar, which_to_swap)

Arguments

gsmvar

an object of class 'gsmvar', typically created with fitGSMVAR or GSMVAR.

which_to_swap

a numeric vector of length at most d and elemnts in 1,..,d specifying the columns of W whose sign should be swapped.

Details

All signs in any column of W can be swapped without changing the implied reduced form model. Consequently, also the signs in the columns of the B-matrix are swapped. Note that the sign constraints imposed on W (or the B-matrix) are also swapped in the corresponding columns accordingly.

Also the order of the columns of W can be changed (without changing the implied reduced form model) as long as the order of lambda parameters is also changed accordingly. This can be done with the function reorder_W_columns.

Value

Returns an object of class 'gsmvar' defining a structural GMVAR, StMVAR, or G-StMVAR model with the modified structural parameters and constraints.

References

@keywords internal

See Also

fitGSMVAR, GSMVAR, GIRF, reorder_W_columns, gsmvar_to_sgsmvar, stmvar_to_gstmvar

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Structural GMVAR(2, 2), d=2 model identified with sign-constraints:
params22s <- c(0.36, 0.121, 0.484, 0.072, 0.223, 0.059, -0.151, 0.395,
  0.406, -0.005, 0.083, 0.299, 0.218, 0.02, -0.119, 0.722, 0.093, 0.032,
  0.044, 0.191, 0.057, 0.172, -0.46, 0.016, 3.518, 5.154, 0.58)
W_22 <- matrix(c(1, 1, -1, 1), nrow=2, byrow=FALSE)
mod22s <- GSMVAR(p=2, M=2, d=2, params=params22s, structural_pars=list(W=W_22))
mod22s

# The same reduced form model, with signs in the second column of W swapped:
swap_W_signs(mod22s, which_to_swap=2)

# The same reduced form model, with signs in both column of W swapped:
swap_W_signs(mod22s, which_to_swap=1:2)

#' # Structural G-StMVAR(2, 1, 1), d=2 model identified with sign-constraints:
mod22gss <- GSMVAR(p=2, M=c(1, 1), d=2, params=c(params22s, 10), model="G-StMVAR",
                   structural_pars=list(W=W_22))
mod22gss

# The same reduced form model, with signs in the first column of W swapped:
swap_W_signs(mod22gss, which_to_swap=1)

saviviro/gmvarkit documentation built on Nov. 27, 2021, 1:41 p.m.