# R 3.1.1 # selection of a VAR # given a data set called ## xy # and an estimated VAR model of order p denoted by ## mod n <- mod$obs; k <- mod$K; p <- mod$p; ## AIC n.m <- n - p aic <- (-2)*logLik(mod)/n.m + 2*p*(k^2)/n.m # alternatively # mod <- VAR(xy, type = "const", exogen = NULL , ic ="AIC") # Residuals, test with Ljung-Box for WN source("mq_res_R.txt") mq_res(resid(mod), 10, p) ## EXERCISE: # (1) Choose a VAR according to an information criterion. # (2) Test the residuals for white noise. Use mv Ljung-Box with correction # for df's. # for rxy pp <- 3 # change value mod <- VAR(rxy, type = "const", exogen = NULL , p=pp) n <- mod$obs; k <- mod$K; p <- mod$p; n.m <- n - p aic <- (-2)*logLik(mod)/n.m + 2*p*(k^2)/n.m aic mq_res(resid(mod), 10, pp)