Nick,
You are right, the stock's ID is no unambiguous identifier. But for each
single date, ID_now is unique. However, ID_nextperiod is not necessarily
unique as the following might happen (in case of a "merger" or an
"acquisition"):
Date ID_now ID_nextperiod Price_now
1 2 3 100
1 3 3 110
2 3 3 105
3 3 3 100
In this rare case, the resulting stock returns would be:
ID_now==2, return from Date==1 to Date==2 is 105/100-1=0.05
ID_now==3, return from Date==1 to Date==2 is 105/110-1=-0.0455
ID_now==3, return from Date==2 to Date==3 is 100/105-1=-0.0476
Therefore, what I presume I should do is creating an additional variable
called Price_nextperiod. After generating this variable, the dataset in
my initial example would look as follows:
Date ID_now ID_nextperiod Price_now
Price_nextperiod
1 1 1 100 110
2 1 1 110 105
3 1 1 105 100
4 1 1 100 .
3 2 2 22 27
4 2 2 27 .
1 3 3 20 25
2 3 2 25 22
1 4 5 60 65
2 5 5 65 67
3 5 5 67 .
...
Then the stock return may be calculated as
. PriceRet = Price_now / Price_nextperiod - 1
However, I do not know how to generate variable Price_nextperiod. Thanks
again for any suggestions.
Daniel
> It is not clear that these identifiers are
> really identifiers. Or, to put it another way,
> how can this problem be solved at all?
>
> As I understand it, you may need a new identifier
> based on a combination of now and the
> next period. So, any stock that is 3 now
> and 2 next period cannot be the same item
> as one that is 3 and 3, any more than a person
> who is male now and female next week can be the
> same person as someone with more stable gender.
> But does a combination of now and next uniquely
> identify stock?
>
> Nick
> [email protected]
>
> Daniel H�chle
>
> > I do have a panel of several thousand stocks. Each stock has an id
> > called ID_now. However, there is a problem: The stock's id may
change
> > over time. Therefore, I do have variable ID_nextperiod which
contains
> > the stock's id in the next period. The data looks like this:
> >
> > Date ID_now ID_nextperiod Price_now
> > 1 1 1 100
> > 2 1 1 110
> > 3 1 1 105
> > 4 1 1 100
> > 3 2 2 22
> > 4 2 2 27
> > 1 3 3 20
> > 2 3 2 25
> > 1 4 5 60
> > 2 5 5 65
> > 3 5 5 67
> > ...
> >
> > What I would like to do is calculating the discrete stock returns.
If
> > the stock's ID would not change over time this could be
> > achieved (after
> > tssetting the dataset) by simply typing
> >
> > . PriceRet = Price_now / L.Price_now - 1
> >
> > However, I do not have any idea how to calculate the discrete stock
> > returns in case of changing IDs. Any ideas would be appreciated.
*
* 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/