Keep Track of Dates in Terms of Months

Keep track of dates in terms of fractional calendar months per Damien Laker "Time Calculations for Annualizing Returns: the Need for Standardization", The Journal of Performance Measurement, 2008. Model dates as of close of business. Perform date arithmetic in units of "months" and "years". Allow "infinite" dates to model "ultimate" time.




o	A new cut.mondate method
    -   Fashioned after a combination of cut.default and cut.Date
    -   Adheres to the "end-of-business-day" spirit of "mondate", but
        can be overridden with "right = FALSE"
    -   A-la cut.default, cut intervals are represented by 
        as left-open / right-closed
        *   include-lowest = TRUE by default. This ensures that the
            minimum value of the mondate is included in the first
            level. The first interval, therefore, is also left-closed.
            This is probably an issue only when breaks is a scalar.
    -   A-la cut.Date, allows the capability of an integer step when 
        breaks is "days", "weeks", "months", "quarters", or "years".
    -   Result has an optional "breaks" attribute = a mondate whose
        pairwise values determine a covering of the vector
        being cut. Most helpful when breaks = 
        "days", "weeks", "months", "quarters", or "years".
        Such "breaks" are suitable be use by 'hist'.
        Attribute is attached to the result by setting argument
        attr.breaks = TRUE (FALSE by default).
o   New 'as.difftime' function to enable units 'months' and 'years'
    -   Now the difference between two mondate objects will be a 
        difftime object with units = timeunits of the first 
o   New + and - methods for mondate,difftime signatures to simplify
    adding and subtracting when the desired units (e.g.,"days") 
    is not "months" or "years".
    -   Example: mondate("2013-01-01")+difftime(1, units = "days")
o   New 'add' and 'subtract' functions to return a date on the 
    same day of the month (subject to restrictions on the number 
    of days in a month), purposely violating the mondate 
    paradigm of measuring time in fractions of a month.
    Furthermore, the argument 'forcelastday' (default = FALSE)
    will guarantee that the result will be on the last day 
    of the month if the input 'mondate' value is.
    -   Examples: 
        *   add(mondate.ymd(2013, 1:12, 15), 1) will always
            result in a date on the 15th of the month.
        *   add(mondate.ymd(2013, 1:12, 15), 1, "days") yields
            mondates corresponding to the 16th of each month.
o   A new "formatFUN" slot of the 'mondate' class
    -   The purpose of this slot is to allow for the user to define
        a special formatting function for converting mondate's to
        character. For example, there is no format string that 
        will format dates in terms of calendar quarter, but this
        can now be accomplished by specifying 'formatFUN' when
        the mondate is created.
    -   A function that will represent mondate's in YYYYQ* format,
        for * = 1-4, is exported in mondate's namespace under the
        name 'YearQuartersFormat'.
    -   The default value of formatFUN is NULL, in which case
        mondate uses the previous behavior -- i.e., formatting
        as a date according to the displayFormat of the mondate.
o   A new "quarters" S3 method 
    -   Returns the "Q1 - Q3" representation of the calendar quarter 
        of the mondate. Same behavior as the quarters.Date method.
o   A new "quarter" S4 generic with methods for mondate, Date, POSIXt
    -   Returns the numeric value of the calendar quarter.

Bug Fixes o The default values for displayFormat (especially) and timeunits were not being set correctly on package load. As a result, the default displayFormat was always the international date standard even when the user's locale was in the United States. These values are now being determined at the time a mondate instance is created.


Changes o year(), month(), day() functions have methods for Date and POSIXt objects. o New "factor" signature for 'mondate' method converts factor to character then applies the "character" signature method. o ymd() function retains names of argument if available


Changes o Replaced S4 methods cbind and rbind with functions cbindmondate and rbindmondate. This removed the two Internal calls in the package. As a result, the functionality is slightly changed: - Whereas mondate's and non-mondate's could previously be c/r-binded together with the result being a mondate, such a "mixed combination" now results in a data.frame. If necessary, non-mondates should be coerced to mondates ahead of time. - When all the arguments are mondates, the result is a mondate as before. - The user will no longer see the message about the c/r-bind generics being created when the package is loaded. - Base c/r-bind with mondate arguments act on the Data slot of the mondates.

o	The as.numeric method now assignes the names attribute of the mondate, if it exists. Before, only the dimnames attribute was assigned.


Bug Fixes

================ NEW FEATURES o New 'as.mondate' function for coercing R objects to a mondate

Changes o Reverted any S4 method better implemented as S3 to an S3 version. In particular, 'format' and 'unique' enable 'aggregate' to work with a mondate object specified in 'by' argument o Removed deprecated 'displayFormat' argument from as.character.mondate method o Clarified some of the documentation

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.10.02 by Dan Murphy, 6 months ago,

Browse source code at

Authors: Dan Murphy

Documentation:   PDF Manual  

Task views: Time Series Analysis

MPL-2.0 | file LICENSE license

Depends on utils, methods

Suggests zoo

Suggested by MRMR, raw, zoo.

See at CRAN