CALENDAR

Provides RATS with information it needs to handle dated time series and panel data sets. In most cases, the CALENDAR instruction specifies the frequency and the starting date of the data.

Wizard

The Calendar Wizard on the Data/Graphics menu provides a dialog box you can use to set the CALENDAR. If you use one of the Data Wizards, you won't have to do a separate Calendar Wizard, since the data wizard includes the choice of date scheme.

Common Frequencies

calendar(a)  year:1

Annual

calendar(q)  year:quarter

Quarterly

calendar(m)  year:month

Monthly

calendar(b)  year:month:day

Biweekly

calendar(w)  year:month:day

Weekly

calendar(d)  year:month:day

Daily (5/week)

calendar(7)  year:month:day

Daily (7/week)


For Annual (A), Quarterly (Q), Monthly (M), Bi-Weekly (B), Weekly (W), and Daily data (D=five day per week, 7= seven days per week). The parameter specifies the date of the first entry, in standard RATS date notation.

Other Date Schemes

calendar(ypp=years per period) year:1

For data with multiple years per period.


calendar(ppy=periods per year) year:period

For data with a fixed number of periods per year.


calendar(ppw=periods per week) year:month:day

calendar(ppd=periods per day,other options) year:month:day

Use PPW for data with a set number of periods per week (other than 5 or 7). Use PPD when you have multiple observations per day.


calendar(dpp=days per period) year:month:day

For data with a fixed number of days per period.


calendar(panelobs=numperiods,other options) startdate

For panel data. If desired, you can use any of the other options shown above
except PPD to specify the periodicity of the panel data.


calendar(julian=SERIES of julian dates for entries)

This is used for an irregular time series (for instance, daily data with skipped entries due to holidays) where information is available to map entries to dates. The dates are coded using a "Julian" (day count) mapping.


calendar(irregular)

For erratic time series—indicates that you have time series data, but without a specific date scheme. (This is mainly informational, as it has no really effect on how the program operates).


Other Options

RECALL=saved VECT[INTEGER] to be used for calendar scheme

SAVE=VECT[INTEGER] into which calendar scheme is saved

Note that SAVE does not change the working calendar scheme—this allows you to define a calendar scheme to be used for processing a data file which has no date information but which follows a different arrangement than the main workspace.

Description

CALENDAR is one of the most important instructions in RATS:


After setting a CALENDAR, you can refer to entry ranges using an easy-to-understand date notation, and your output will be labeled similarly. Note that you should never use a CALENDAR instruction with cross-sectional data. It will only confuse RATS.

Date Parameter Field

The date parameter sets the starting date for the CALENDAR. This will be the date associated with the first entry of your data series. Use the standard RATS date format notation, described on the next page.

Frequencies

The form of the CALENDAR instruction will vary depending on the desired frequency, as described in the following paragraphs. See the examples later in this section.


Annual, Quarterly, Monthly

Use the A, Q, or M options, respectively, to choose one of these frequencies.


Weekly and Biweekly Data

Use the W or B options for weekly or biweekly data. The date field should be the last day of the first period. For example, if the week ends Friday, give the date of the first Friday, not the first Monday. This affects how RATS transforms data between frequencies. If, for instance, you read daily data into a weekly work space with weeks ending on a Friday, the value for a given week will depend on the daily value for that Friday and (up to) six preceding days.


Daily Data (5, 7, or other number of periods per week)

Use the D option for a daily calendar with five days per week (Saturdays and Sundays are omitted), or the 7 option for a daily calendar with entries for all seven days.


For a less standard periods per week, use the PPW option. For example, if you have six day per week data starting on June 5, 2000, use:  


cal(ppw=6) 2000:6:5


Intraday Data

If you have a data set with a fixed number of time periods per day, use the PPD option to set the periods per day, combined with one of the other options (usually D or 7) to describe the day-to-day arrangement of the data set.


You can use any number of periods with PPD—you do not have to cover a full 24 hour period. For instance, data at five minute intervals from 9:05am to 3:00pm could be handled using PPD=72.


Other Periodic Schemes

Use the PPY (period per year) option for data with a set number of periods per year (other than monthly or quarterly, which you would handle with the M or Q options). Use DPP (days per period) for frequencies specified as a specific number of days.


Data Recorded Less Than Once a Year

For data which are equally spaced, but more than one year apart, use the YPP (years per period) option to set the number of years per period. The date parameter sets the starting year of the first observation.


Other Time Series Data

Use JULIAN=SERIES with Julian dates if you have irregular data where the dates are known. Otherwise, use CALENDAR(IRREGULAR) for any time series data which does not fit into any of the above. Note, in particular, the requirement in all of the above for fixed numbers of periods or period lengths. The only point of CAL(IRREGULAR) is to inform RATS that the data set does have time series properties. In all other ways, there is no difference between CALENDAR(IRREGULAR) and omitting CALENDAR entirely.


Panel Data

Include the option PANELOBS=periods per individual together with other options to describe the date scheme in the time direction. periods per individual is the number of time periods for each individual in a data set. The setting of the time series scheme is optional and has no effect on your ability to use the special panel data features of RATS. Note that you cannot use PANELOBS with the PPD option.

Examples

Monthly starting 1950, January


cal(m) 1950:1



Five-day a week daily data starting on June 9, 2014


cal(d) 2014:6:9



Weekly panel data with 52 observations per individual, each starting at Jan 5, 1990:


cal(panelobs=52,w) 1990:1:5


Holidays and Related Matters

RATS expects business day data to have five periods per week (except, perhaps, for the first and last weeks). What do you do if you have a data set which has no observations for holidays? There are four ways to deal with this:


  1. You can use a business day CALENDAR, and either insert missing values in the data file for the missing observations or, if your file includes dates, let the DATA instruction take care of “padding” the data set by inserting missing values for any days that aren’t included in the source file. This is the best choice when using regression techniques where missing values can simply be dropped from the sample. However, if the insertion of missing values poses a problem for the types of analysis you wish to do, use one of the approaches.
  2. You can use the JULIAN option to map entries to coded date values. This will give you a data file without gaps, so (for instance) Monday will be the day after Thursday if the Friday is missing.
  3. You can treat it as IRREGULAR data. Use this if you want a continuous stream of data with no gaps (for example, for recursive models such as ARCH and GARCH which can’t handle missing values).
  4. The final option is to read in the data with gaps as in (1), but use SAMPLE(SMPL=series) instructions to produce “compressed” versions of the series, with the gaps removed. You can use the full series where possible, and use the compressed versions as needed for the kinds of analysis discussed in (1) above.

Converting Frequencies

RATS will not allow you to work with two frequencies of data simultaneously, meaning that only one CALENDAR can be in effect at a time. However, the DATA instruction can translate data automatically from other frequencies to the current CALENDAR frequency. Thus, if you have a mixture of  monthly and quarterly data, you can work with it all at either quarterly or monthly frequencies.


DATA itself does not use any sophisticated techniques for producing a higher frequency version of a series. For instance, in translating quarterly data from a file into monthly series, it merely copies the quarterly value to each of the corresponding months. You can then use the @DISAGGREGATE procedure to do more complex interpolations and distributions on the expanded data.

Saving/Recalling Calendars

It’s sometimes necessary to switch to a different frequency temporarily, or to switch out of time-dated data to simple sequence data. You can save the current calendar setting, then recall it later on using the function %CALENDAR() and the RECALL option on the CALENDAR instruction. The following saves the initial quarterly calendar setting in SAVECAL, switches to IRREGULAR, then switches back later.


calendar(q) 1954:1

...

compute savecal=%calendar()

calendar(irregular)

...

calendar(recall=savecal)


You can also save a calendar scheme without resetting the workspace date scheme by using the SAVE option. For instance, the following sets up a quarterly workspace starting in 1954:1, then reads a data file which has monthly data from 1948:1, compacting by quarterly averages. Since the data file is free format, there is no identifying date information on it, thus the need for the CALENDAR option on the DATA instruction.


cal(q) 1954:1

cal(m,save=mdata) 1948:1

data(format=free,compact=average,calendar=mdata) 1954:1 2016:4 ffunds


Deprecated CALENDAR formats

The following older formats for specifying the CALENDAR instruction are still supported, but we recommend using the new formats for any new tasks. Note that most of these use multiple parameters (separated by at least one blank space), rather than date format notation, to supply the starting date.


CALENDAR year   period  peryear        

for annual, semi-annual, monthly or quarterly data or any other frequency with a fixed number of entries per year


CALENDAR(daily or sevenday)   year   month   day

       for daily data with five  days per week or seven days per week


CALENDAR(entriesperweek=perweekyear   month   day

       for data with the indicated number of entries per week


CALENDAR(weekly orbiweekly) year   month   day

       for weekly or biweekly data


CALENDAR(days=period) year   month   day

       for data every period days


CALENDAR(yearsperentry=yearsyear

       for data spaced years years apart

CALENDAR(perday=numper, other options)year   month   day

for intraday data