## Option window()

The latest version of asrol accepts up to three arguments and is written in like this:

*window*(rangevar #from #up to)

The *rangevar* typically represents a time variable, such as a date, monthly date, or yearly date. Both `#from`

and `#upto`

are numeric values that determine the extent of the window from the current value of the *rangevar*. Negative values indicate a shift back by `#`

periods from the current observation, while positive values signify a move forward by `#`

periods from the current observations. `asrol`

treats the focal observation as part of the past. In the subsequent paragraphs, I will provide some examples to elucidate the `window()`

option more clearly.

### Example 1: Last 5 years, including the most recent one

If we aim to calculate the mean of the preceding 5 years, considering that we have a total of 5 observations for the years 2001, 2002, 2003, 2004, and 2005. For the year 2005, the window will consider the years [2001, 2002, 2003, 2004, and 2005] as the past 5 years. The `window`

argument in `asrol`

would be formulated as follows:

window(year -5 0)

The third argument of the *window()* option is 0 (zero), which means include observations up to the current one.

### Example 2: Back window of 5 periods and exclude the most recent one

If we aim to estimate a rolling window spanning 5 years, but intend to exclude the most recent observation, then the `window`

argument would be formulated as follows:

window(year -5 -1)

Drawing from the previous example, the window will confine the calculations to the years [2001, 2002, 2003, 2004], thereby excluding the focal year of 2005. As a result, only 4 observations will be included in the computation of the mean value.

### Example 3: Back window of 5-periods and one-year forward

In this case, the window option will be written as:

window(year -5 1)

### Example 4: Window definition based on t-number to t-another number

The aforementioned interpretation of the `window`

option might seem perplexing, especially when implementing a definition based on `t-#`

up to `t-#2`

. However, the following example should help alleviate any confusion.

Consider a stock momentum strategy that calculates cumulative returns over the previous 11 months, from month `t-12`

up to `t-2`

. Suppose we estimate this cumulative return at the end of December 2019. This strategy will include the months given in the square brackets in the calculations and exclude the ones that are outside the brackets:

[Dec-18, Jan-19, Feb-19, Mar-19, Apr-19, May-19, Jun-19, Jul-19, Aug-19, Sep-19, Oct-19], Nov-19, Dec-19.

From Dec-18 up to Dec-19, there are 13 months. To implement this using asrol, the window argument will be written as:

window(year -13 -2)

### Example 5: Window of +5 to +10

This window would include observations that are 5-periods into the future from the current observation, extending up to 10 periods into the future. Consequently, if the current observation is the year 2000, the window would include the subsequent years:

[2006, 2007, 2008, 2009, 2010].

The option *window()* will be typed as

window(year 5 10)

### Example 6: Window of 0 to +9 or -1 to +9

See this Statalist post for more details on this example. This window shall include current observation and other observations that are 9-periods into the future from the current observation . Therefore, if the current date is Oct 1st, the window would include the dates as follows:

[Oct1, Oct2, Oct3, Oct4, Oct5, Oct6, Oct7, Oct8, Oct9, Oct10].

The option *window()* will be typed as

window(date 0 9) OR window(date -1 9)

**Why do both the options yield same results?**

This is because `asrol`

treats the current observation as historical data. In other words, since this data has already been recorded, it is considered part of the history. Consequently, observations 0 and -1 are interpreted as the same, resulting in identical outcomes.