From: Achim Zeileis <Achim.Zeileis_at_wu-wien.ac.at>

Date: Mon, 14 Dec 2009 14:55:36 +0100 (CET)

R-devel_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 14 Dec 2009 - 13:58:40 GMT

Date: Mon, 14 Dec 2009 14:55:36 +0100 (CET)

Hi,

I was pointed by a request on R-help to the following problem with ar.ols():

R> set.seed(1) R> x <- matrix(rnorm(4 * 2), ncol = 2) R> ar.ols(x, order.max = 1, aic = FALSE, demean = FALSE)Error in if ((dimension < 1) | (dimension > n)) stop("wrong embedding dimension") :

argument is of length zero

In addition: Warning message:

In log(det(varE[[m - order.min + 1L]])) : NaNs produced

This happens on my 32-bit Debian (i686-pc-linux-gnu), both in R-release and R-devel. The source is a numerical instability in the computations of the error variance and subsequent AIC.

YH <- A[[m - order.min + 1L]] %*% t(X) E <- (Y - YH) varE[[m - order.min + 1L]] <- E %*% t(E)/N [...] aic[m - order.min + 1L] <- n.used * log(det(varE[[m - order.min + 1L]])) + 2 * nser * (nser * m + intercept)

varE is the cross-product of the errors E and should be positive-definite but here det(varE[[1]]) is -6.920697e-17 (on my machine) and thus taking logs gives NaN yielding an aic of NaN for which the minimum cannot be determined.

Of course, it does not make much sense to fit such a VAR model but either a more meaningful error or a workaround would be useful. For example one could take

log(max(0, det(varE[[m - order.min + 1L]])))

to avoid the negative determinant problem.

Best,

Z

R-devel_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 14 Dec 2009 - 13:58:40 GMT

*
This archive was generated by hypermail 2.2.0
: Mon 14 Dec 2009 - 15:21:04 GMT
*