Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: cubic spline interpolation in panel data
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
RE: st: cubic spline interpolation in panel data
Date
Tue, 5 Apr 2011 20:42:28 +0100
Privately, I asked for a copy of Ben's data.
I found that -csipolate- (well, Mata's inbuilt functions, but who am I to point a finger of blame) is falling over when asked to interpolate singleton missing values.
That is, there is just one observation; and the variable in question is missing in that observation.
As in this case there is nothing to interpolate with, the problem is utterly futile, modulo some possible amusement value to postmodernists, but it can be trapped easily, and I will update -csipolate- accordingly.
Nick
[email protected]
Ben Ammar
Hi Nick,
thanks for your answer. You're right, the statistical approach of interpolating the data isn't the best choice but unfortunately the data is only available on a quarterly basis.
I just used the command that you mentioned as follows:
-by group: csipolate price date, gen(price2)-
I generated missing values between the quarterly dates through -tsfill-
and everything also works fine -ipolate- and -cipolate-.
But with -csipolate- I receive this:
spline3(): 3201 x[0,0] found where vector required
csipolate(): - function returned error
<istmt>: - function returned error
I have no idea why that happens. The help-menu does not indicate any further information for the -csipolate- command. Am I missing additional information?
Regards Ben
-------- Original-Nachricht --------
> Datum: Mon, 4 Apr 2011 16:08:15 +0100
> Von: Nick Cox <[email protected]>
> An: [email protected]
> Betreff: Re: st: cubic spline interpolation in panel data
> I think there are two distinct issues here.
>
> First, -csipolate- (SSC) is a wrapper for a relative of the Mata
> function you mention, so that is a positive for you.
>
> It's a cousin of -cipolate- (SSC), which you mention, but without
> giving its source. It would be more accurate to say that it supports
> -by:- than it knows about panel data as such, but the distinction
> should not bite you.
>
> Second, what you mean by interpolation? If you have prices that are
> averaged in some way over quarters, no interpolation process will put
> back detail that has been lost. If you have prices that are measured
> once a quarter, say 1 Jan 2011, 1 Apr 2011, etc., then clearly you can
> apply interpolation, although its appropriateness for price variation
> seems moot to me.
>
> On Mon, Apr 4, 2011 at 3:57 PM, Ben Ammar <[email protected]> wrote:
> > Hi everyone,
> >
> > I was wondering if there's any possibility to use spline3() with Mata if
> the dataset is in panel form (400000 observations, 40 years)?
> > Currently I have quartely dates with prices but I would like to
> interpolate those prices on a monthly basis.
> > -ipolate- works fine but I'm trying to smooth the data as much as
> possible.
> > I also installed -cipolate- but I just read it's not a spline function.
> > Does anyone have an idea how to use the spline3() with panel data
> (-reshape- the dataset came to my mind, but I don't think that is would help
> somehow + I'm using Stata IC, which could be tight due to 40 years of
> observations)or perhaps does someone have another way to approach the interpolation
> on a monthly basis?
> >
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/