help for cipolate

Cubicly interpolate values

cipolate yvar xvar [if exp] [in range] , generate(newvar)

by ... : may be used with cipolate; see help by.


cipolate creates newvar by averaging non-missing values of yvar and cubicly interpolating missing values of yvar, given xvar. That is, provided that xvar is not missing,

1. When yvar is not missing, newvar is the mean of yvar over observations with the same value of xvar. If a value of xvar is unique, then each mean is just the same as the value of yvar at that point.

2. When yvar is missing, newvar is filled in with cubicly interpolated values of yvar.

Interpolated values are based on exact fitting of a cubic curve to two data points before and two data points after each observation for which yvar is missing. cipolate will thus produce missing values whenever fewer than two data points are present on either side. Note that this is not a spline method.

Extrapolation is not provided, mainly because of reservations about the general (and even particular) wisdom of extrapolating cubics into the unknown. Some users may wish to extrapolate any remaining missing values linearly using ipolate.


generate() is not optional; it specifies the name of the new variable to be created.


. cipolate y x, gen(yprime)

. by panel : cipolate response year, gen(iresponse)


Nicholas J. Cox, Durham University, U.K. n.j.cox@durham.ac.uk


Hamming, R.W. 1973. Numerical methods for scientists and engineers. New York: McGraw-Hill. See pp.235-236.

Morton, B.R. 1964. Numerical approximation. London: Routledge and Kegan Paul. See p.38.

Press, W.H., S.A. Teukolsky, W.T. Vetterling, B.P. Flannery. 1992. Numerical recipes in C: the art of scientific computing. Cambridge: Cambridge University Press. See pp.108-110.

Also see

Manual: [D] ipolate

On-line: help for ipolate