Dear Statalistians,
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.
Thanks.
Xiaoyi
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/