Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
642 views
in Technique[技术] by (71.8m points)

How to test for autocorrelation after running a panel VAR in R?

I am wondering how to test for autocorrelation in the error terms after running a panel VAR in R (using the panelvar package).

In a glm, the procedure would be the following:

library(plm)

#load data
data("Grunfeld", package = "plm")

#estimate de model
g <- plm(inv ~ value + capital, data = Grunfeld, model="random")

#test for serial correlation
pdwtest(g)

With the panel VAR, one could estimate the model doing the following:

library(panelvar)

set.seed(12345)

x = rnorm(240)
z = x + rnorm(240)
y = rep(rnorm(15), each=16) + 2*x + 3*z + rnorm(240)
country = rep(c("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O"), each=16 )
year = rep(seq(1995, 2010), 15)

panel = cbind.data.frame(country,year,x,z,y)

model <- pvargmm(dependent_vars = c("y", "x", "z"),
                              lags = 1,
                              transformation = "fod",
                              data = panel,
                              panel_identifier=c("country", "year"),
                              steps = c("twostep"),
                              system_instruments = FALSE,
                              max_instr_dependent_vars = 99,
                              max_instr_predet_vars = 99,
                              min_instr_dependent_vars = 2L,
                              min_instr_predet_vars = 1L,
                              collapse = TRUE
)

However, I have no idea how to test for serial correlation afterwords. I tried the following:

pdwtest(model)

And the result was:

Error in UseMethod("pdwtest") : 
  no applicable method for 'pdwtest' applied to an object of class "pvargmm"

Any ideas?

question from:https://stackoverflow.com/questions/65910833/how-to-test-for-autocorrelation-after-running-a-panel-var-in-r

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...