[Rd] Bug in print.Arima and patch

From: Gavin Simpson <gavin.simpson_at_ucl.ac.uk>
Date: Fri, 05 Jun 2009 15:13:07 +0100


Dear List,

A posting to R-Help exposed this problem with the print method for objects of class Arima:

> set.seed(1)
> x <- arima.sim(n = 100, list(ar = 0.8897, ma = -0.2279))
> mod <- arima(x, order = c(1,0,1))
> coefs <- coef(mod)
> mod2 <- arima(x, order = c(1,0,1), fixed = coefs)
> mod2

Call:
arima(x = x, order = c(1, 0, 1), fixed = coefs)

Coefficients:
Error in se && nrow(x$var.coef) : invalid 'y' type in 'x && y'
> print(mod2, se = FALSE)

Call:
arima(x = x, order = c(1, 0, 1), fixed = coefs)

Coefficients:

      ar1 ma1 intercept
   0.9323 -0.2940 -0.0353

sigma^2 estimated as 0.8339: log likelihood = -133.55, aic = 269.11

The print methods raises an error in this case, where all coefficients are fixed, because x$var.coef is of length(0), which in turn results in NULL being used in the && comparison, resulting in the error.

A potential fix is to just include a check for length(x$var.coef) > 0 in the if statement. This fix, when applied to:

R version 2.10.0 Under development (unstable) (2009-06-05 r48712)

fixes this particular problem and passes make check-devel. A patch against r48712 is attached, and included here in-line:

[gavin_at_desktop build]$ svn diff ../src/library/stats/R/arima.R Index: ../src/library/stats/R/arima.R


HTH G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%


______________________________________________ R-devel_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Received on Fri 05 Jun 2009 - 14:26:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 05 Jun 2009 - 16:34:53 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive