Statalist The Stata Listserver


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

st: RE: RE: help on linear interpolation


From   "Ben Jann" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: help on linear interpolation
Date   Fri, 20 Jan 2006 21:52:26 +0100

Note that there is also an -ipolate()- Mata function. It 
is part of the -moremata- package:

 . ssc install moremata

ben

> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Nick Cox
> Sent: Friday, January 20, 2006 1:58 AM
> To: [email protected]
> Subject: st: RE: help on linear interpolation
> 
> help ipolate
> 
> Nick
> [email protected]
> 
> 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:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   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/



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