help mata mm_polint()-------------------------------------------------------------------------------

Title

mm_polint() -- Polynomial interpolation and extrapolation

Syntax

real vectormm_polint(x,y,xnew[,degree])where

x:real vectorcontaining strictly monotone increasing or decreasingx-values

y:real vectorcontaining associatedy-values

xnew:real vectorcontaining evaluation points

d:real scalarspecifying degree of the polynomial (default: 1)

Description

mm_polint()evaluates the interpolating polynomial throughd+1 (x,y)-points at the valuexnew.xshould be strictly monotone increasing or decreasing. The set of data points is chosen such that thex-values are centered aroundxnew. However, the set is bounded by 1 at the left and length(x) at the right. Furthermore, choosing a centered set of data points is only possible ifdis uneven. In this case (d+1)/2 points are on each side ofxnew. Ifdis even andxis in ascending order, thend/2+1 points are belowxnewandd/2 above. Ifxis in descending orderd/2 points are below andd/2+1 above. Therefore, ifdis even, the returned result depends on whetherxis increasing or decreasing.

dis the degree of the polynomial. The default is to use a polynomial of degree one, i.e. to compute the linear interpolation (d=1).

Remarks

mm_polint()is based on a translation into Mata of thepolintrountine given in Press et al. (1992:109-110).

Conformability

mm_polint(x,y,xnew,degree):x:n x1 or 1x ny:n x1 or 1x nxnew:m x1 or 1x mdegree: 1x1result:m x1 or 1x m.

Diagnostics

mm_polint()requiresxbe in ascending or descending order.

dmust be an integer equal to one or larger and must be smaller than the number of input data points (i.e.,d<length(x)).

Source codemm_polint.mata

ReferencesPress, William H., Saul A. Teukolsky, William T. Vetterling, Brian P. Flannery (1992). Numerical Recipes in C. The Art of Scientific Computing. Second Edition. Cambridge University Press. http://www.numerical-recipes.com/

AuthorBen Jann, ETH Zurich, jann@soz.gess.ethz.ch

Also seeOnline: help for

ipolate,mm_ipolate(),spline3(),[M-4] utility,