TimeSeries-class {MacrobondAPI}R Documentation

TimeSeries class

Description

A TimeSeries object represents a time series downloaded via the Macrobond API or a time series that is to be uploaded to the Macrobond in-house database.

A time series consists of a vector of values, a calendar and a set of metadata.

The vector of values consists of floating point values. A missing value is represented by a NaN. To test if a value is a NaN in R, you use the method is.nan(value). To represent a NaN you can use the constant NaN. NB! You must never use this constant to compare if a value is NaN; always use is.nan(value) to test if a value is NaN.

A missing value typically means that a value was expected, but it is missing for some reason. When you do a unified series request, you have the option of specifying what method, if any, that should be used to fill in missing values.

The calendar is exposed as lists of dates as well as a couple of methods to go between index in the list of values and a date. Each time series has a frequency and a start date. Daily series also have information about what weekdays that are covered. In addition to this, certain dates can be skipped. This is mostly used for daily series when there is a holiday or other day when the market is closed. It is not common, but you may find skipped dates in series of other frequencies too. For instance, some Chinese monthly data is not reported for February and this month is then skipped.

Objects from the Class

Time series objects are created by the following methods: FetchOneTimeSeries FetchTimeSeries CreateTimeSeriesObject CreateTimeSeriesObjectWithForecastFlags UploadOneOrMoreTimeSeries TimeSeriesWithRevisions

Extends

Class "Entity", directly.

Methods

getName

signature(object = "Entity"): Get the name of the time series. This will always be the name used in the request.

getPrimaryName

signature(object = "Entity"): Get the primary name of the time series. This can differ from the name used in the request when that name is a alias or relative reference.

getTitle

signature(series = "Entity"): Get the title of the time series.

getIsError

signature(series = "Entity"): TRUE if there was an error downloading this time series. In that case the getErrorMessage method will return an error message.

getErrorMessage

signature(series = "Entity"): Get an error message text if getIsError is TRUE.

getMetadata

signature(series = "Entity"): Get a Metadata object for this time series.

getValues

signature(series = "TimeSeries"): Get a vector of all the values of the time series.

getDatesAtStartOfPeriod

signature(series = "TimeSeries"): Get a vector containg the Date at the start of each period.

getDatesAtEndOfPeriod

signature(series = "TimeSeries"): Get a vector containg the Date at the end of each period.

getForecastFlags

signature(series = "TimeSeries"): Get a vector with a logical for each value that tells if the value is a forecast or not.

getStartDate

signature(object = "TimeSeries"): Get the start date of the time series.

getEndDate

signature(object = "TimeSeries"): Get the end date of the time series.

getFrequency

signature(object = "TimeSeries"): Get the frequency of the time series as one of the values in TimeSeriesFrequency.

getWeekdays

signature(object = "TimeSeries"): Get a bit set of what weekdays that are used for daily timeseries. The bits are defined for Monday-Sunday in the list TimeSeriesWeekdays.

getValueAtDate

signature(series = "TimeSeries", date = "Date"): Get the value at or preceding a specific date.

getIndexAtDate

signature(series = "TimeSeries", date = "Date"): Get the index in the value and date vectors at or preceding a specific date.

getTypicalObservationCountPerYear

signature(series = "TimeSeries"): The typical number of observations per year based on the frequency of the series.

getConcepts

signature(object = "Entity"): Get a list "concepts" for which this series is defined or NULL if not defined. This method is a convenience method for retrieving the value of the RegionKey metadata attribute. See also GetConceptDescription and SearchByConcept.

getRevisionTimesFromNthRelease

signature(series = "TimeSeries"): Get a vector of POSIXlt for when the value was revised. This only works for series retrieved from getNthRelease.

show

signature(object = "TimeSeries"): Show a summary of the time series.

plot.TimeSeries

signature(x = "TimeSeries"): Show a simple plot of the time series. Additional parameters will be passed on to the link[graphics]{plot} function.

See Also

FetchOneTimeSeries, FetchTimeSeries, CreateTimeSeriesObject, CreateTimeSeriesObjectWithForecastFlags, UploadOneOrMoreTimeSeries

Examples

seriesGdp <- FetchOneTimeSeries("usgdp")
show(seriesGdp)

[Package MacrobondAPI version 1.1-5 Index]