# Thread: Gaps frequency and seasonlity

1. ## Gaps frequency and seasonlity

Hello,

I'm using data from 01Jan1990 until 31Dec2011 for trading volume in stock market.

For example, in data editor it goes like this:

time volume
24dec1990: 26358
25dec1990: . --> holidays
26dec1990: . --> holidays
27dec1990: 51190
28dec1990: 79502 --> Friday
31dec1990: 60582 --> Sunday

Basically, there are two problems:
- when it's holidays (like 25th and 26th of December) the trading volume has a missing value
- when it's weekend, the time and trading volume are just omitted

In stock market, this means that there was no trading in these days (holidays and weekends).

I would like to see the frequency of these no trading gaps in a table. For example, how many times there was one day of no trading, two days of no trading etc
What command shall I use?

Also, how can I include a dummy variable to account for this seasonality problem?

Thanks.

2. ## Re: Gaps frequency and seasonlity

Here's one very basic solution to the first question. It might need to be generalised if you have eg panel data:
Code:
``````. list, clean

date   volume
1.   24dec1990    26358
2.   25dec1990        .
3.   26dec1990        .
4.   27dec1990    51190
5.   28dec1990    79502
6.   31dec1990    60582

. drop if missing(volume)
(2 observations deleted)

. sort date

. gen gap=date - date[_n-1] - 1
(1 missing value generated)

. list, clean

date   volume   gap
1.   24dec1990    26358     .
2.   27dec1990    51190     2
3.   28dec1990    79502     0
4.   31dec1990    60582     2

. tab gap

gap |      Freq.     Percent        Cum.
------------+-----------------------------------
0 |          1       33.33       33.33
2 |          2       66.67      100.00
------------+-----------------------------------
Total |          3      100.00``````
I am not sure why you call this a "seasonality problem"; using a dummy variable doesn't make much sense to me but it might be that I don't understand what you're trying to do. If you're doing a time series analysis you may wish to exclude the non-trading days, create your own time scale, and use that for your -tsset- command (see eg here).

3. ## The Following User Says Thank You to bukharin For This Useful Post:

matina14 (08-20-2012)

4. ## Re: Gaps frequency and seasonlity

Thanks bukharin. Your suggestion works fine.

I'm examining the relationship between stock returns and trading volume. As suggested from the available literature they adjust their data for seasonality; they include dummy variables for:
- day of the week
- gap of nontrading days (which captures the effect of holidays and weekends)
- for each month
- for each year
Basically that's why I consider it as a seasonality problem

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts