-
Notifications
You must be signed in to change notification settings - Fork 20
- Are generalized impulse functions (GIRF) available in tsDyn?
- Can tsDyn estimate a TVEM with more than two variables?
- What does the warning the thDelay values do not correspond to the univariate implementation in tsdyn mean?
- How to conduct hypothesis tests on the parameters for SETAR/LSTAR?
- Why can't I estimate two VAR to get the same results as a TVAR?
- What if I want instead a threshold model including only an external variable, not lags as in SETAR?
No, tsDyn does NOT provide generalised impulse response functions, although it does provide standard impulse response functions (IRF) for the linear VAR/VECM only, building on the functions from package vars/urca, see [irf()] (http://finzi.psych.upenn.edu/R/library/tsDyn/html/irf.html).
However, this has been long discussed on the mailing list ( [see post] (http://groups.google.com/group/tsdyn/t/5c517a94a3a3ab0c)), and there exists now a external user-written code: https://github.com/MatthieuStigler/tsDyn_GIRF/blob/master/README.md
Yes, on the next version coming very soon, GIRF are available. See function GIRF()
, and the details
No, the function TVECM is restricted to two variables only. This is due to the fact that with already two variables, a two-dimensional grid search is done over the threshold and cointegrating values. If there were more than two variables, the search would have to be done over more cointegrating values, which would increase too much the dimension of the grid. People interested in using more than two variables should look at the work of [Seo (2011)] Seo, as well as [El Shagi (2011)] Shagi
3. What does the warning the thDelay values do not correspond to the univariate implementation in tsdyn mean?
When the package was initially written, notation for univariate models was:
Note that the left-hand-side variable is t+s, while the left-hand-side has time t. In that notation, using a lag 1 in a threshold auto-regression corresponds to setting a value of thDelay= 0
.
In the multivariate models on the other side, the notation uses t on the LHS and t-1 on the RHS. In that case, a lag 1 in a multivariate threshold auto-regression is obtained with: thDelay= 1
.
This is what the message the thDelay values do not correspond to the univariate implementation in tsdyn reminds.
For both models, you can simply use the linearHypothesis from package car. Note however that for SETAR, you cannot do any test on the threshold parameters.
set <- setar(log10(lynx), m=1)
lst <- lstar(log10(lynx), m=1, trace = FALSE)
library(car)
coef(set)
## const.L phiL.1 const.H phiH.1 th
## 0.7569446 0.7173426 1.6513041 0.4901176 2.8369567
H_set <- c(0,1,0,-1,0)
linearHypothesis(set, H_set)
## Linear hypothesis test
##
## Hypothesis:
## phiL.1 - phiH.1 = 0
##
## Model 1: restricted model
## Model 2: set
##
## Df Chisq Pr(>Chisq)
## 1
## 2 1 1.0849 0.2976
coef(lst)
## const.L phiL.1 const.H phiH.1 gamma th
## 0.2884595 0.9280287 -0.6726318 0.1331190 100.0031347 3.2356515
H_lst <- c(0,1,0,-1,0,0)
linearHypothesis(lst, H_lst)
## Linear hypothesis test
##
## Hypothesis:
## phiL.1 - phiH.1 = 0
##
## Model 1: restricted model
## Model 2: lst
##
## Df Chisq Pr(>Chisq)
## 1
## 2 1 3.66 0.05573 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Is it possible, with a given threshold, to split yourself the sample, estimate a VAR on the two sub-samples, and get the same result as TVAR? Actually, no... the fact is that if you split the sample, you will feed the VAR()/LineVar() the data, and they will create the lags. However, they will take as lags only values from the same regime (t-1 among regime 1) while the TVAR takes t-1 among the whole sample.
In other words, a TVAR estimates:
While a two-sample approach estimates something like:
This implies that the idea of running regime-specific IRF is actually not feasible.
If you want to re-estimate a regime, you need to retrieve the data from the TVAR, and feed it directly with the right lags into the lm() function:
library(tsDyn)
data(zeroyld)
model_TVAR = TVAR(zeroyld, lag=1, gamma = 6, plot=FALSE, trace=FALSE)
## Retrieve data matrix with lags:
dataTVAR <- as.data.frame(model_TVAR$model)
dataTVAR$regime <-regime(model_TVAR)
## reconstruct?
dataReg_Reg2 = subset(dataTVAR, regime!=1, 1:2)
VAR_reg2_FALSE <- lineVar(dataReg_Reg2, lag = 1)
dtTVAR <- as.matrix(dataTVAR)
VAR_reg2_TRUE <- lm(dtTVAR[,1:2]~dtTVAR[,3:5]-1)
## Compre which is right?
coef(model_TVAR)$Bdown
## Intercept short.run -1 long.run -1
## Equation short.run -0.0448517 1.0515522 -0.03920948
## Equation long.run -0.1492237 0.1492248 0.87862856
coef(VAR_reg2_FALSE)
## Intercept short.run -1 long.run -1
## Equation short.run 0.2084998 0.95361865 0.02560659
## Equation long.run 0.2497991 0.02542565 0.94217990
t(coef(VAR_reg2_TRUE))
## dtTVAR[, 3:5]L Intercept dtTVAR[, 3:5]L short.run -1
## short.run -0.0448517 1.0515522
## long.run -0.1492237 0.1492248
## dtTVAR[, 3:5]L long.run -1
## short.run -0.03920948
## long.run 0.87862856
6. What if I want instead a threshold model including only an external variable, not lags as in SETAR?
Model where we look at the effect of external variables (instead of lags as in the SETAR) are referred to as threshold regression, segmented regression, or piecewise regression. They are not available in package tsDyn
, but a separate package in development offers some of these functionalities: seglm
https://github.com/MatthieuStigler/seglm