[R] Replacing NAs with interpolated values

Philippe Grosjean phgrosje at ulb.ac.be
Wed Sep 5 18:28:20 CEST 2001


You don't tell us what kind of data it represents. Are they independent
data? If yes, you cannot interpolate. Are they autocorrelated, i.e., is it a
time or space or space/time series? If yes, some interpolation is possible,
taking advantage of autocorrelation. See ?interp or ?spline for instance.
However, interpolation is somewhat efficient for sparse gaps only. You have
a very big gap in a small serie and I am afraid it is not possible to
"reconstruct" so many missing values! A multivariate method exists that
could help perhaps. It is called ZET-method. The principle is the following.
If your data have some correlation with other parameters that are measured
along the whole serie, including missing values, the algorithm seek for
correlations between the serie to interpolate and those other variables.
Then it uses information on the other series to predict missing values. This
is actually the most powerful method to reconstruct series with missing
values like this. It is not implemented in R (as far as I know?), but it
will be in a few months when package 'PASSTEC' will be done. In the
meantime, you can consult the following reference:

Zagoruiko, N.G. & V.N. Yolkina, 1982. Inference on data tables with missing
values. Handbook of statistics, 2:493-500. North Holland Publishing Company.

A temporary version of 'PASSTEC' (in French, sorry) is available at
http://www.sciviews.org/_passtec. It's manual summarizes briefly the
ZET-method pp. 68-69.

Best Regards,

Philippe Grosjean


...........]<(({?<...............<?}))><...............................
 ) ) ) ) )	 __               	 __
( ( ( ( ( 	|__)              	|  _
 ) ) ) ) )	|   hilippe       	|__)rosjean
( ( ( ( ( 	Marine Biol. Lab., ULB, Belgium
 ) ) ) ) )	                  	 __
( ( ( ( ( 	|\  /|            	|__)
 ) ) ) ) )	| \/ |ariculture &	|__)iostatistics
( ( ( ( (
 ) ) ) ) )	e-mail: phgrosje at ulb.ac.be or phgrosjean at sciviews.org
( ( ( ( ( 	SciViews project coordinator (http://www.sciviews.org)
 ) ) ) ) )      tel: 00-32-2-650.29.70 (lab), 00-32-2-673.31.33 (home)
( ( ( ( (
 ) ) ) ) )      "I'm 100% confident that p is between 0 and 1"
( ( ( ( (                                  L. Gonick & W. Smith (1993)
 ) ) ) ) )
.......................................................................


>Hi there,

>I've got this vector:

>-84  -87  -90  -90  -89  -86 NA NA NA NA NA NA NA NA NA NA NA NA  -96
>-99 -100  -99  -96 -92  -89  -87  -87  -88  -90  -92  -94  -95  -96
>-97  -97  -97  -96  -95

>Is there a function in R which replaces the NAs with "interpolated"
>values between -86 and -96?

>Thanks, Sven

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list