VAR (R包“vars”)的非连续滞后数

时间:2021-04-19 12:38:29

Is it possible (in package "vars" or maybe in some other R package?) to include non-consecutive lags into the var model, i.e., just lags 1 and 3.

是否有可能(在“vars”包中或者在其他R包中)将非连续的时滞包含到var模型中,例如。,仅仅落后1和3。

So far, it looks like when I set p = 3 under function VAR, it includes all consecutive lags between 1 and p (i.e., 1:3).

到目前为止,当我在函数VAR下设置p = 3时,它包括了1和p之间的所有连续滞后。1:3)。

1 个解决方案

#1


3  

You can use restrict from vars package for estimating a restricted VAR. This method requires estimate the model twice: 1) the unrestricted model with all the "consecutive lags" and 2) a restricted model with only the lags you want. This is so, becasue restrict function takes as input an object of class 'varest'. See my alternative:

这种方法需要对模型进行两次估计:1)具有所有“连续时滞”的无限制模型,2)只有所需时滞的受限模型。因此,限制函数将类varest的对象作为输入。看到我的选择:

> library(vars)
> data(Canada) # some data
> model <- VAR(Canada[,1:2], p=3) # The unrestricted VAR
> #Bcoef(model) The restriction matrix have to have the same dimension as dim(Bcoef(model))

# Building the restriction matrix
> Restrict <- matrix(c(1,1,0,0,1,1,1,
                       1,1,0,0,1,1,1), nrow=2, byrow=TRUE)

# Re-estimating the VAR with only lags 1 and 3 
> restrict(model, method = "man", resmat = Restrict)

VAR Estimation Results:
======================= 

Estimated coefficients for equation e: 
====================================== 
Call:
e = e.l1 + prod.l1 + e.l3 + prod.l3 + const 

      e.l1    prod.l1       e.l3    prod.l3      const 
 1.2029610  0.1885456 -0.2300286 -0.1299485  1.8382368 


Estimated coefficients for equation prod: 
========================================= 
Call:
prod = e.l1 + prod.l1 + e.l3 + prod.l3 + const 

       e.l1     prod.l1        e.l3     prod.l3       const 
 0.05511963  1.13333804 -0.03338699 -0.18646375  1.22037293 

See ?restrict for further details on this function.

查看?限制此函数的进一步详细信息。

#1


3  

You can use restrict from vars package for estimating a restricted VAR. This method requires estimate the model twice: 1) the unrestricted model with all the "consecutive lags" and 2) a restricted model with only the lags you want. This is so, becasue restrict function takes as input an object of class 'varest'. See my alternative:

这种方法需要对模型进行两次估计:1)具有所有“连续时滞”的无限制模型,2)只有所需时滞的受限模型。因此,限制函数将类varest的对象作为输入。看到我的选择:

> library(vars)
> data(Canada) # some data
> model <- VAR(Canada[,1:2], p=3) # The unrestricted VAR
> #Bcoef(model) The restriction matrix have to have the same dimension as dim(Bcoef(model))

# Building the restriction matrix
> Restrict <- matrix(c(1,1,0,0,1,1,1,
                       1,1,0,0,1,1,1), nrow=2, byrow=TRUE)

# Re-estimating the VAR with only lags 1 and 3 
> restrict(model, method = "man", resmat = Restrict)

VAR Estimation Results:
======================= 

Estimated coefficients for equation e: 
====================================== 
Call:
e = e.l1 + prod.l1 + e.l3 + prod.l3 + const 

      e.l1    prod.l1       e.l3    prod.l3      const 
 1.2029610  0.1885456 -0.2300286 -0.1299485  1.8382368 


Estimated coefficients for equation prod: 
========================================= 
Call:
prod = e.l1 + prod.l1 + e.l3 + prod.l3 + const 

       e.l1     prod.l1        e.l3     prod.l3       const 
 0.05511963  1.13333804 -0.03338699 -0.18646375  1.22037293 

See ?restrict for further details on this function.

查看?限制此函数的进一步详细信息。