Bookmark and Share

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: Re: Fill Missing values at the End


From   Sadia Khalid <[email protected]>
To   [email protected]
Subject   Re: st: Re: Fill Missing values at the End
Date   Wed, 8 Jan 2014 21:10:54 +0500

Thanks

Nick Cox.
I have posted the almost same thing becuase of the fear that i have
not explained the question welll in the first posts. sorrry for this.
i have applied the code but not getting the required results.
Regards
Sadia Khaild

On 8 January 2014 20:37, Nick Cox <[email protected]> wrote:
> This appears to be the third posting of this question. (In fact, as I
> wrote this, yet another posting appeared.)
>
> Please see the Statalist FAQ at
>
> http://www.stata.com/support/faqs/resources/statalist-faq/#noanswer
>
> to see that is one more than allowed.
>
> You also sent me personal mail.
>
> Again, not to do that is explained in the FAQ
>
> http://www.stata.com/support/faqs/resources/statalist-faq/#private
>
> Repeating a question (or minor variants of it) again and again is
> _not_ likely to get more attention for your question than you would
> otherwise get. In fact, it draws attention to yourself as someone who
> (apparently) didn't read the FAQ carefully and/or doesn't respect the
> list. No one is obliged to answer anything on Statalist. If you want a
> tame consultant, hire one and pay accordingly.
>
> In this case David Ashcraft posted a suggestion
>
> http://www.stata.com/statalist/archive/2014-01/msg00206.html
>
> to which you replied
>
> http://www.stata.com/statalist/archive/2014-01/msg00207.html
>
> I don't understand the reply, but I don't think it explained why
> David's suggestion didn't work.
>
> In any case, your recipe is to use the last known value and the value
> 4 years before that and extrapolate forward, or to use the first known
> value and the value 4 years after that and extrapolate backward. You
> don't need new code to do that. It is an application of -ipolate-.
>
> 1. Clone your variable.
>
> 2. Replace the 4th, 3rd, 2nd last known values with missing.
>
> 3. Replace the 2nd, 3rd, 4th known values with missing.
>
> 4. Use -ipolate-.
>
> gen y2 = y
> gen ismissing = missing(y)
> bysort ismissing name (year) : replace y2 = . if inlist(_n, 2, 3, 4,
> _N-3, _N-2, _N-1)
> drop ismissing
> bysort name (year): ipolate y2 year, gen(y3) epolate
>
> You want to use
>
> gen y_new = cond(missing(y), y3, y)
>
> I addressed the restriction only to apply when there are 5 or fewer
> values missing in an earlier reply, so I won't repeat that here.
>
> http://www.stata.com/statalist/archive/2014-01/msg00187.html
>
> Nick
> [email protected]
>
>
> On 8 January 2014 15:05, Sadia Khalid <[email protected]> wrote:
>
>> I have working on Panel data. For some of the individuals end values
>> are missing. I have to fill these values by first calculating the
>> growth of the known five values.
>>
>> Like for the individual Aqueela values for the year 1996 – 2000 are
>> missing. I will first calculate the growth rate of values from
>> 1991-1995. the formula for calculating the growth rate is
>> =((41.6/39.9)^(1/(5-1))-1). The growth rate is 1.05%.
>> now the value in 1996 = value in 1995*(1+growth rate).
>>
>> And value in 1997= value in 1996 * (1+growth rate).
>>
>> And so on.
>>
>> For the second individual starting values are missing from 1996-2000
>> First I will have to find the r=growth rate of values from 1991-1995.
>> Than the value in 1996 =value in 1995*(1+ growth rate) and
>> value in 1997 =value in 1996/(1+ growth rate) and so on.
>>
>>
>> for the last indiviual values are missing from 1995-2000
>> if for any indiviual more than 5 values are missing do not fill that.
>> any code for this
>>
>> what i have
>>
>> what i have
>> year name y
>> 1990 Aqueela 50.1
>> 1991 Aqueela 39.9
>> 1992 Aqueela 93.4
>> 1993 Aqueela 53.4
>> 1994 Aqueela 5.9
>> 1995 Aqueela 41.6
>> 1996 Aqueela
>> 1997 Aqueela
>> 1998 Aqueela
>> 1999 Aqueela
>> 2000 Aqueela
>> 1990 Abida 57.0
>> 1991 Abida 44.3
>> 1992 Abida 41.3
>> 1993 Abida 92.3
>> 1994 Abida 42.2
>> 1995 Abida 56.0
>> 1996 Abida
>> 1997 Abida
>> 1998 Abida
>> 1999 Abida
>> 2000 Abida
>> 1990 Zubaida 68.5
>> 1991 Zubaida 51.0
>> 1992 Zubaida 41.7
>> 1993 Zubaida 91.5
>> 1994 Zubaida 40.7
>> 1995 Zubaida
>> 1996 Zubaida
>> 1997 Zubaida
>> 1998 Zubaida
>> 1999 Zubaida
>> 2000 Zubaida
>>
>> and what i want
>>
>> year name y
>> 1990 Aqueela 50.1
>> 1991 Aqueela 39.9
>> 1992 Aqueela 93.4
>> 1993 Aqueela 53.4
>> 1994 Aqueela 5.9
>> 1995 Aqueela 41.6
>> 1996 Aqueela 96.6
>> 1997 Aqueela 113.0
>> 1998 Aqueela 132.0
>> 1999 Aqueela 154.4
>> 2000 Aqueela 180.4
>> 1990 Abida 57.0
>> 1991 Abida 44.3
>> 1992 Abida 41.3
>> 1993 Abida 92.3
>> 1994 Abida 42.2
>> 1995 Abida 82.7
>> 1996 Abida 96.6
>> 1997 Abida 113.0
>> 1998 Abida 132.0
>> 1999 Abida 154.4
>> 2000 Abida 180.4
>> 1990 Zubaida 68.5
>> 1991 Zubaida 51.0
>> 1992 Zubaida 41.7
>> 1993 Zubaida 91.5
>> 1994 Zubaida 40.7
>> 1995 Zubaida
>> 1996 Zubaida
>> 1997 Zubaida
>> 1998 Zubaida
>> 1999 Zubaida
>> 2000 Zubaida
>>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index