hello, I have been trying to use the predict function in the vars package to forecast from a seasonal VAR model. The following code sample illustrates what I am trying to do and the error that I get when trying to do it. I run the following code, that results in the following error: data(Canada) endoC <- Canada[1:72,1:3] exoC <- Canada[1:72,4] var.2c <- VAR(endoC, p = 2, season=12,exogen=exoC,type = "const") exoC_2 <- as.matrix(Canada[73:84,4]) predict(var.2c, n.ahead = 12,dumvar=exoC_2) Error: Error in as.matrix(cycle, nrow = season, ncol = season - 1) : unused argument(s) (nrow = 12, ncol = 11) from what I can guess, the predict.varest function is using as.matrix() and passing nrow and ncol, as.matrix() does not take those two parameters but matrix() does. Does anyone have a suggestion of how to get around it? Is there a way I can get to the predict.varest() function and alter it myself? Thanks, Spencer [[alternative HTML version deleted]]
Leeds, Mark (IED)
2007-Aug-30 21:50 UTC
[R] possible bug in vars package (predict.varest) ???
yes, you can just pulldown the tar.gz file and tar -xvf it and that will give you many directories one of which will contain the source. I've done that with the vars package in the past ( bernhard's code is very nice to read ) and I would just send you the code to predict.varest but I don't think predict was there when I pulled down the code. I think it's a fairly new function. -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of sj Sent: Thursday, August 30, 2007 5:44 PM To: r-help Subject: [R] possible bug in vars package (predict.varest) ??? hello, I have been trying to use the predict function in the vars package to forecast from a seasonal VAR model. The following code sample illustrates what I am trying to do and the error that I get when trying to do it. I run the following code, that results in the following error: data(Canada) endoC <- Canada[1:72,1:3] exoC <- Canada[1:72,4] var.2c <- VAR(endoC, p = 2, season=12,exogen=exoC,type = "const") exoC_2 <- as.matrix(Canada[73:84,4]) predict(var.2c, n.ahead = 12,dumvar=exoC_2) Error: Error in as.matrix(cycle, nrow = season, ncol = season - 1) : unused argument(s) (nrow = 12, ncol = 11) from what I can guess, the predict.varest function is using as.matrix() and passing nrow and ncol, as.matrix() does not take those two parameters but matrix() does. Does anyone have a suggestion of how to get around it? Is there a way I can get to the predict.varest() function and alter it myself? Thanks, Spencer [[alternative HTML version deleted]] ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -------------------------------------------------------- This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
Pfaff, Bernhard Dr.
2007-Aug-31 08:51 UTC
[R] possible bug in vars package (predict.varest) ???
Hello Spencer, which version of vars are you using? This has been fixed a while ago (see ChangeLog). Incidentally, the data in Canada is quarterly data, as stated in ?Canada. Aside of this, your code snippet works fine. Best, Bernhard ps: There is no need to download the tarball as suggested by Mark, instead you can do: vars:::predict.varest>hello, > >I have been trying to use the predict function in the vars package to >forecast from a seasonal VAR model. The following code sample >illustrates >what I am trying to do and the error that I get when trying to do it. > >I run the following code, that results in the following error: > >data(Canada) > >endoC <- Canada[1:72,1:3] >exoC <- Canada[1:72,4] >var.2c <- VAR(endoC, p = 2, season=12,exogen=exoC,type = "const") >exoC_2 <- as.matrix(Canada[73:84,4]) > >predict(var.2c, n.ahead = 12,dumvar=exoC_2) > >Error: > >Error in as.matrix(cycle, nrow = season, ncol = season - 1) : > unused argument(s) (nrow = 12, ncol = 11) > >from what I can guess, the predict.varest function is using >as.matrix() and >passing nrow and ncol, as.matrix() does not take those two >parameters but >matrix() does. > >Does anyone have a suggestion of how to get around it? Is >there a way I can >get to the predict.varest() function and alter it myself? > >Thanks, > >Spencer > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. >***************************************************************** Confidentiality Note: The information contained in this mess...{{dropped}}