Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Problems with -ipolate-


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Problems with -ipolate-
Date   Mon, 5 Sep 2005 22:17:23 +0100

-ipolate- interpolates linearly within gaps. That 
is, it is assumed that the y variable varies linearly with 
the x variable within any gaps. This is best seen 
geometrically, as the last (x,y) pair before any gap 
and the first (x,y) pair after any gap are just joined 
by a straight line and intermediate results read 
off directly. 

In addition, a consequence of the assumption that 
y is piecewise linear in x is 
that repeated y's at any x are just averaged. 

Plotting your results will make it easier to 
see what is going on. 

The help file is somewhat elliptical here. 

Nick 
n.j.cox@durham.ac.uk 

Jann Ben

> Stata's -ipolate- command produces results I don't 
> understand. Here is an example:
> 
> 	. set seed 2346
> 	. sysuse auto
> 	. drop if rep78<. & uniform()<.8
> 	. ipolate rep78 mpg, g(rep78i)
> 	. sort mpg
> 	. list rep78 mpg rep78i, clean
> 	
> 	       rep78   mpg   rep78i
> 	  1.       .    14        .
> 	  2.       4    15      3.5
> 	  3.       3    15      3.5
> 	  4.       3    16        3
> 	  5.       2    17      3.5
> 	  6.       5    17      3.5
> 	  7.       3    18        3
> 	  8.       3    19        3
> 	  9.       3    19        3
> 	 10.       .    19        3
> 	 11.       3    21        3
> 	 12.       .    22      3.5
> 	 13.       4    23        4
> 	 14.       4    25        4
> 	 15.       4    25        4
> 	 16.       .    26      4.1
> 	 17.       .    26      4.1
> 	 18.       5    35        5
> 
> -help ipolate- states that rep78i should equal rep78 
> if rep78 is not missing ("ipolate creates newvar = yvar, 
> where yvar is not missing"). This is certainly not the case 
> in the above example. For some reason, "3.5" is stored 
> for cases 2, 3, 5, and 6. Can someone explain this to me?

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index