On Tue, 21 Sep 1999, Michael HART wrote:
> I have a list of measurements taken at 1 second samples in a vector (y).
> All I want to do is generate a regression through them, and obtain the
> residuals in another vector. I am currently using the 'line'
function from
> the eda package to do this (ie :
>
> z <- line(time,y)
> rsd <- residuals(z)
>
> )
> but this method does not handle NA values in the data. I would like to try
> to use the lm functions but cannot figure out how to do this simple
> regression with it (how do I set up the model parameter etc).
fit <- lm(y ~ time, na.action=na.omit)
rsd <- residuals(fit)
But watch out, as the residuals for the input NAs (which are NAs) are
omitted. Which they are is handled in attribute na.action of fit$model.
> Also can anyone let me know how the ts package handles NA values.
It depends on the function (and that is an aspect that is incomplete as
yet). Many of the functions can use na.omit.ts or na.contiguous, that keeps
a longs contiguous block of non-NAs. You will need to read the help page
for each. Eventually there will be an arima function that handles NAs
internally.
--
Brian D. Ripley, ripley at 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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._