------------------------------------------------------------------------------- help forcipolate-------------------------------------------------------------------------------

Cubicly interpolate values

cipolateyvarxvar[ifexp] [inrange],generate(newvar)

by...:may be used withcipolate; see help by.

Description

cipolatecreatesnewvarby averaging non-missing values ofyvarand cubicly interpolating missing values ofyvar, givenxvar. That is, provided thatxvaris not missing,1. When

yvaris not missing,newvaris the mean ofyvarover observations with the same value ofxvar. If a value ofxvaris unique, then each mean is just the same as the value ofyvarat that point.2. When

yvaris missing,newvaris filled in with cubicly interpolated values ofyvar.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

yvaris missing.cipolatewill 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.

Options

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

Examples

. cipolate y x, gen(yprime)

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

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

ReferencesHamming, 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 seeManual:

[D] ipolateOn-line: help for ipolate