s-news
[Top] [All Lists]

Re: NAs in S-Plus

To: "Steffen Klug" <klugste@web.de>
Subject: Re: NAs in S-Plus
From: "Padhye, Nikhil S" <Nikhil.S.Padhye@uth.tmc.edu>
Date: Wed, 22 Nov 2006 12:04:22 -0600
Cc: <s-news@lists.biostat.wustl.edu>
References: <45646FA8.5030906@web.de>
Thread-index: AccOTRidtTnDM6LyQ8GR6ianM7BC5AAC81gU
Thread-topic: [S] NAs in S-Plus
Steffen,

Linear interpolation is available through the function approx, or you could use 
the function spline for cubic spline interpolation. Neither of these functions 
accepts NAs, so you will need to preprocess. Assuming that your time stamps are 
in a vector t0 and data in vector y0, consider something like:

t1 <- t0[!is.na(y0)]  ##removes times at which data is not available

y1 <- y0[!is.na(y0)]

z <- approx(t1, y1, t0, method="linear") ##estimates values of y at all 
original time stamps

## if you want just a fixed number of output points, say 50, on a uniform grid 
between min(x) and max(x),

## use approx(t1, y1, n=50, method="linear")

## to extract the time and data vectors from list z, use t2 <- z$x and y2 <- z$y

Hope that is of use.

Nikhil

____________________________________________

N. S. Padhye, Ph.D.

Assistant Professor, Biostatistician

University of Texas Health Science Center at Houston

http://www.uth.tmc.edu

 

Dear List

I'm absolutely new in this field.
Can anybody help me, how I can fill the NAs of a time series with
plausible values with easy methods of s-plus?

I'm very glad about your answer.

Yours sincerely
Steffen
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news



<Prev in Thread] Current Thread [Next in Thread>
  • NAs in S-Plus, Steffen Klug
    • Re: NAs in S-Plus, Padhye, Nikhil S <=