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: could you please verify the correctness of the code?-tsfill function
From
stef salvez <[email protected]>
To
[email protected]
Subject
Re: st: could you please verify the correctness of the code?-tsfill function
Date
Wed, 6 Jun 2012 02:14:25 +0100
thank you Nick. I really appreciate your help and your patience.
Let me be more explicit this time
I have a panel data set of prices of goods that vary across time and countries.
As you can see from the table below
country dates price of good k
1 "23/11/08" 2
1 "28/12/08" 3
1 "25/01/09" 4
1 "22/02/09" 5
1 "29/03/09" 6
1 "26/04/09" 32
1 "24/05/09" 23
1 "28/06/09" 32
2 "26/10/08" 45
2 "23/11/08" 46
2 "21/12/08" 90
2 "18/01/09" 54
2 "15/02/09" 65
2 "16/03/09" 77
2 "12/04/09" 7
2 "10/05/09" 6
the start and end date of the time series for countries 1 and 2 are
different. For example, for country 1 the time series begins on
"23/11/08" while for country 2 the time series begins on
"26-10-2008”.
My data on prices are available every 28 days (or equivalently every 4
weeks). But in some cases I have jumps (35 days or 29 days instead of
28 days). For example from the above table we have such jumps: from
"28/12/08" to "28/12/08" , from 22/02/09" to
"29/03/09", etc
My goal is to have as much as possible the same sequence of dates
across countries which is a bit difficult because of the two
“problems” that I mentioned above. I want to have the same sequence of
dates across countries because eventually what I want to do is see how
the difference of prices for,say good k, between two countries
evolves over time. So I want to set up the following regression
ΔP_{ij,t}_{k}= constant +regressors +error term where ΔP_{ij,t } is
the difference of prices between countries i and j in period t for
good k. The ΔP_{t}_{k} is a vector of difference of prices for all
pairs of countries at time t for good k.
The whole point is to be able to run the above regression
My initial idea was to use -tsfill- in the code which i display below
( and which can be easily reproduced with copy paste in stata):
clear all
cd D:\
input id str8 (dates) variable
1 "23/11/08" 2
1 "28/12/08" 3
1 "25/01/09" 4
1 "22/02/09" 5
1 "29/03/09" 6
1 "26/04/09" 32
1 "24/05/09" 23
1 "28/06/09" 32
2 "26/10/08" 45
2 "23/11/08" 46
2 "21/12/08" 90
2 "18/01/09" 54
2 "15/02/09" 65
2 "16/03/09" 77
2 "12/04/09" 7
2 "10/05/09" 6
end
gen edate1 = date(dates, "DM20Y")
gen edate2= floor(edate1/28)
tsset id edate2
tsfill
But I do not know if this approach is correct or not in order to be
able to run the above regression. Apart from tsfill I have no other
idea how to run this regression. Any suggestions/codes are welcome.
thank you again
On 6/6/12, Nick Cox <[email protected]> wrote:
> Your code does not run without correction. Apart from
>
> cd J:\
>
> which will not work if such a drive does not exist, you need to change
> -identif2- to -id-. But you could have checked the code yourself
> before posting it. Otherwise I don't know how to respond to your
> "feeling that something may not be correct".
>
> I guess you got no answers first time you posted this because people
> could not work out what you were asking.
>
> Nick
>
> On Tue, Jun 5, 2012 at 8:45 PM, stef salvez <[email protected]>
> wrote:
>
>> I was wondering if someone could check the validity of the code. If I
>> violate any rules I would be grateful to you if you could inform me
>> about it
>>
>>
>> thanks
>>
>> On 6/5/12, stef salvez <[email protected]> wrote:
>>> ok
>>>
>>> On 6/5/12, stef salvez <[email protected]> wrote:
>>>> Dear all,
>>>>
>>>>
>>>> I have a panel data set. These data are available every 28 days (or 4
>>>> weeks). But in some case I have jumps (35 days instead of 28 days).
>>>> So I used tsfill in the code which i display below
>>>>
>>>>
>>>>
>>>> clear all
>>>> cd J:\
>>>> input id str8 (dates) var
>>>> 1 "23/11/08" 2
>>>> 1 "28/12/08" 3
>>>> 1 "25/01/09" 4
>>>> 1 "22/02/09" 5
>>>> 1 "29/03/09" 6
>>>> 1 "26/04/09" 32
>>>> 1 "24/05/09" 23
>>>> 1 "28/06/09" 32
>>>> 2 "23/11/08" 45
>>>> 2 "28/12/08" 46
>>>> 2 "25/01/09" 90
>>>> 2 "22/02/09" 54
>>>> 2 "29/03/09" 65
>>>> 2 "26/04/09" 77
>>>> 2 "24/05/09" 7
>>>> 2 "28/06/09" 6
>>>> end
>>>>
>>>>
>>>> gen edate1 = date(dates, "DM20Y")
>>>> gen edate2= floor(edate1/28)
>>>> tsset identif2 edate2
>>>> tsfill
>>>>
>>>> I get no warnign sign which seems to be ok. But when I look at the
>>>> data editor I have the feeling that something may not be correct:
>>>> So, I would like to ask if the above approach-code is correct
>>>>
>
> *
> * 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/
>
*
* 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/