From ripley at stats.ox.ac.uk  Sun Apr 18 18:01:53 2004
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Sun Apr 18 18:01:59 2004
Subject: [Rd] arima
In-Reply-To: <40826818.11930.3636C8@localhost>
Message-ID: <Pine.LNX.4.44.0404181648350.22842-100000@gannet.stats>

On Sun, 18 Apr 2004 kjetil@entelnet.bo wrote:

> I got problems using an objects returned from arima
> (in KalmanSmooth(my.ts, ModArima$model), because
> my.ts showed up to have storage mode "integer" (is.integer(my.ts was
> TRUE). 
> 
> Should storage.mode() of a ts be allowed to be integer, 

We had a debate about that a while back. Seems the majority opinion is
that a ts can have any atomic mode (numeric, integer, complex, logical,
character), but that most of the analysis code assumes a ts object is
numeric.  So arima() contains

    x <- as.ts(x)
    if(!is.numeric(x))
        stop("`x' must be numeric")
    storage.mode(x) <- "double"  # a precaution
!


> should ts() someplace say storage.mode(ts.out) <- "double", or
> maybe inside arima()
> storage.mode(x) <- "double"
> storage.mode(xreg) <- "double"
> ?

Yes, sort of (xreg=NULL cannot have storage mode "double"), and those
coercions _are_ already inside arima.


I think the issue is that you need to be more careful using KalmanSmooth:  
my.ts would not have been returned by arima(). The Kalman* functions are
internal workhorses and there is a `Warning' about precisely this on their
help page.  I suggest you write a tsSmooth method and use that rather than
calling KalmanSmooth directly.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] arima
Prof Brian Ripley