Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fin-monthly

Special Monthly Series


Description

Functions and methods dealing with special monthly 'timeSeries' objects.

Usage

countMonthlyRecords(x)

rollMonthlyWindows(x, period = "12m", by = "1m") 
rollMonthlySeries(x, period = "12m", by = "1m", FUN, ...)

Arguments

x

a 'timeSeries' object.

period

a character string specifying the rollling period composed by the length of the period and its unit. As examples: "3m" represents quarterly shifts, and "6m", ]code"12m", and "24m" semi-annual, annual and bi-annual shifts. To determine the proper start of the series is in the responsibility of the user.

by

a character string specifying the rolling shift composed by the length of the shift and its unit. As examples: "1m" represents monthly shifts, "3m" represents quarterly shifts, and "6m" semi-annual shifts. To determine the proper start of the series is in the responsibility of the user.

FUN

the function for the statistic to be applied. For example in the case of aggregation usecolAvgs.

...

arguments passed to the function FUN.

Details

The function countMonthlyRecords computes a 'timeSeries' that holds the number of monthly counts of the records.

The function rollMonthlyWindows computes start and end dates for rolling time windows.

The function rollMonthlySeries computes a static over rolling periods defined by the function rollMonthlyWindows.

Value

The function countMonthlyRecords returns a 'timeSeries' object.

The function rollMonthlyWindows returns a list with two named 'tomeDate' entries: $from and to. An attribute "control" is added which keeps the start and end dates of the series.

The function rollMonthlySeries computes the statistics defined by the function FUN over a rolling window internally computed by the function rollMonthlyWindows. Note, the periods may be overlapping, may be dense, or even may have gaps.

Examples

## Load Microsoft Daily Data Set:
   x <- MSFT 
   
## Count Monthly Records -
   counts <- countMonthlyRecords(x)
   counts
   
## Quaterly Non-Overlapping Time Periods -
   windows <- rollMonthlyWindows(counts[-1, ], period = "3m", by = "3m") 
   windows
   
## Nicely Reprint Results as a data.frame -
   data.frame(cbind(FROM=format(windows$from), TO=format(windows$to)))
   
## Compute the average number of monthly trading days per quarter -  
   rollMonthlySeries(counts[-1, ], period = "3m", by = "3m", FUN=mean)

timeSeries

Financial Time Series Objects (Rmetrics)

v3062.100
GPL (>= 2)
Authors
Diethelm Wuertz [aut] (original code), Tobias Setz [cre], Yohan Chalabi [ctb], Martin Maechler [ctb] (<https://orcid.org/0000-0002-8685-9910>)
Initial release
2020-01-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.