help mata mm_ipolate()
-------------------------------------------------------------------------------

Title

mm_ipolate() -- Linear interpolation

Syntax

real colvector mm_ipolate(x, y, xnew)

real colvector mm_ipolate(x, y, xnew, outer)

where

x: real colvector x y: real colvector y x: real colvector xnew outer: real scalar outer

Description

mm_ipolate() assumes y to be piecewise linear in x and returns the linear interpolation of y at the values in xnew. Averages of y are used where x values are tied.

outer!=0 specifies that the (average) y value corresponding to min(x) (max(x)) be returned for xnew values below (above) the support of x. The default is to return missing for xnew values that are outside the support of x.

Remarks

Simple example:

: x = (1 \ 2)

: y = (10 \ 20)

: mm_ipolate(x, y, 1.2) 12

Conformability

mm_ipolate(x, y, xnew, outer) x: n x 1 y: n x 1 xnew: r x 1 outer: 1 x 1 result: r x 1.

Diagnostics

mm_ipolate() does not take any special action to treat missing values.

Source code

mm_ipolate.mata

Author

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

Also see