Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

test


From   "Michael S. Hanson" <[email protected]>
To   [email protected]
Subject   st: Oddities with weekly data
Date   Sun, 14 May 2006 14:20:14 -0400

I have a student who is working with weekly data on equity returns. When he attempts to -tsset- his data based on his "time" variable, he gets the error:

repeated time values in sample
r(451);

Stata seems to have trouble with two cases, as illustrated in the listing below. First, most of his observations are Mondays, but in some cases the recorded data is on a Tuesday. (Presumably the market was closed; the dates do appear to coincide with US federal holidays, but I'm puzzled why there aren't many more of them in his sample.) Stata is apparently treating Monday as the end of the week, and so Tuesdays are assigned to the following week -- meaning both a duplicate week and a missing week. I'd prefer finding a way to convince Stata that a week is defined by any value in a Monday-Friday interval, but I'd settle for a quick way to recode all the Tuesdays as Mondays.

Second, in 1990, 1996 and 2001, the last Monday of the year is the 53rd. Stata (understandably) does not like this structure of the data. I'm at a loss of how to deal with this issue, however, as all the years in the sample (appear to) have 52 weeks -- or more -- so he cannot just shift a week from one year to another. (The data range from Feb 1998 to March 2006.) Surely some basic accounting has gone awry here? A reference was made to this problem earlier on Statalist (see <http://www.stata.com/statalist/archive/2003-05/msg00129.html>), but I cannot think of any concrete ways to address it.

Suggestions on ways to approach both aspects of this problem from within Stata would be appreciated; I'd rather not have to recode the data by hand if that is avoidable. I've asked the student to work with time series operators and estimators on these data ; hence the need to -tsset- them as weekly. Thanks!


. list date time dow if time == time[_n-1] | time == time[_n+1], sep(2)

+----------------------------------+
| date time dowretu~s |
|----------------------------------|
151. | 12/24/1990 1990w52 -.0016911 |
152. | 12/31/1990 1990w52 -.0243001 |
|----------------------------------|
159. | 2/19/1991 1991w8 -.0155532 |
160. | 2/25/1991 1991w8 .0070837 |
|----------------------------------|
173. | 5/28/1991 1991w22 .0382414 |
174. | 6/3/1991 1991w22 -.0169085 |
|----------------------------------|
187. | 9/3/1991 1991w36 -.0105596 |
188. | 9/9/1991 1991w36 -.0086506 |
|----------------------------------|
464. | 12/23/1996 1996w52 .01173 |
465. | 12/30/1996 1996w52 -.002567 |
|----------------------------------|
724. | 12/24/2001 2001w52 .0100782 |
725. | 12/31/2001 2001w52 .0120364 |
|----------------------------------|
728. | 1/22/2002 2002w4 .006958 |
729. | 1/28/2002 2002w4 .006804 |
|----------------------------------|
732. | 2/19/2002 2002w8 .0065532 |
733. | 2/25/2002 2002w8 .0394121 |
|----------------------------------|
746. | 5/28/2002 2002w22 -.0178751 |
747. | 6/3/2002 2002w22 -.0343955 |
|----------------------------------|
760. | 9/3/2002 2002w36 -.0276542 |
761. | 9/9/2002 2002w36 -.0136813 |
+----------------------------------+

-- Mike

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