Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: help on linear interpolation

From   "Nick Cox" <>
To   <>
Subject   st: RE: help on linear interpolation
Date   Fri, 20 Jan 2006 00:57:52 -0000

help ipolate


xiao yi
> I need help on a linear interpolation problem. Each
> firm has a piecewise linear supply schedule specifying
> the price and quantity they would like to offer. The
> supply schedule looks like this:
> Price        Quantity
>   p1             q1
>   p2             q2
>   p3             q3
>   p4             q4
> The (p,q) are aranged in an ascending order. The
> supply schedule can have as many as 20 (p,q) pairs.
> For a market equilibrium price a, I need to find the
> corresponding q(a). Mathematically, the q(a) would be:
> if a<p1, then q(a)=0
> if p1<a<p2, then q(a)=q1+{(q2-q1)*(a-p1)/(p2-p1)}
> similarly,
> if p2<a<p3, then q(a)=q2+{(q3-q2)*(a-p2)/(p3-p2)}
> and so on.
> if a>p4, then q(a)=q4 (suppose p4 is the max(p))
> Because I have hands of firms and several years of
> data, I would like to program this. Can anyone on the
> list give me a hand on the step of linear
> interpolation? The rest can be done using do-loops.

*   For searches and help try:

© Copyright 1996–2022 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index