Title
mm_polint() -- Polynomial interpolation and extrapolation
Syntax
real vector mm_polint(x, y, xnew [, degree])
where
x: real vector containing strictly monotone increasing or decreasing x-values
y: real vector containing associated y-values
xnew: real vector containing evaluation points
d: real scalar specifying degree of the polynomial (default: 1)
Description
mm_polint() evaluates the interpolating polynomial through d+1 (x,y)-points at the value xnew. x should be strictly monotone increasing or decreasing. The set of data points is chosen such that the x-values are centered around xnew. 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 if d is uneven. In this case (d+1)/2 points are on each side of xnew. If d is even and x is in ascending order, then d/2+1 points are below xnew and d/2 above. If x is in descending order d/2 points are below and d/2+1 above. Therefore, if d is even, the returned result depends on whether x is increasing or decreasing.
d is 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 the polint rountine given in Press et al. (1992:109-110).
Conformability
mm_polint(x, y, xnew, degree): x: n x 1 or 1 x n y: n x 1 or 1 x n xnew: m x 1 or 1 x m degree: 1 x 1 result: m x 1 or 1 x m.
Diagnostics
mm_polint() requires x be in ascending or descending order.
d must 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 code
mm_polint.mata
References
Press, 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/
Author
Ben Jann, ETH Zurich, jann@soz.gess.ethz.ch
Also see
Online: help for ipolate, mm_ipolate(), spline3(), [M-4] utility,