Skip to contents

collapse provides a flexible and powerful set of functions and classes to work with time-dependent data:

  • findex_by/iby creates an 'indexed_frame': a flexible structure that can be imposed upon any data-frame like object and facilitates indexed (time-aware) computations on time series and panel data. Indexed frames are composed of 'indexed_series', which can also be created from vector and matrix-based objects using the reindex function. Further functions findex/ix, unindex, is_irregular and to_plm help operate these classes, check for irregularity, and ensure plm compatibility. Methods are defined for various time series, data transformation and data manipulation functions in collapse.

  • timeid efficiently converts numeric time sequences, such as 'Date' or 'POSIXct' vectors, to a time-factor / integer id, where a unit-step represents the greatest common divisor of the underlying sequence.

  • flag, and the lag- and lead- operators L and F are S3 generics to efficiently compute sequences of lags and leads on regular or irregular / unbalanced time series and panel data.

  • Similarly, fdiff, fgrowth, and the operators D, Dlog and G are S3 generics to efficiently compute sequences of suitably lagged / leaded and iterated differences, log-differences and growth rates. fdiff/D/Dlog can also compute quasi-differences of the form \(x_t - \rho x_{t-1}\).

  • fcumsum is an S3 generic to efficiently compute cumulative sums on time series and panel data. In contrast to cumsum, it can handle missing values and supports both grouped and indexed / ordered computations.

  • psmat is an S3 generic to efficiently convert panel-vectors / 'indexed_series' and data frames / 'indexed_frame's to panel series matrices and 3D arrays, respectively (where time, individuals and variables receive different dimensions, allowing for fast indexation, visualization, and computations).

  • psacf, pspacf and psccf are S3 generics to compute estimates of the auto-, partial auto- and cross- correlation or covariance functions for panel-vectors / 'indexed_series', and multivariate versions for data frames / 'indexed_frame's.

Table of Functions

S3 Generic Methods Description
findex_by/iby, findex/ix, reindex, unindex, is_irregular, to_plmFor vectors, matrices and data frames / lists.Fast and flexible time series and panel data classes 'indexed_series' and 'indexed_frame'.
timeidFor time sequences represented by integer or double vectors / objects.Generate integer time-id/factor
flag/L/Fdefault, matrix, data.frame, pseries, pdata.frame, grouped_dfCompute (sequences of) lags and leads
fdiff/D/Dlogdefault, matrix, data.frame, pseries, pdata.frame, grouped_dfCompute (sequences of lagged / leaded and iterated) (quasi-)differences or log-differences
fgrowth/Gdefault, matrix, data.frame, pseries, pdata.frame, grouped_dfCompute (sequences of lagged / leaded and iterated) growth rates (exact, via log-differencing, or compounded)
fcumsumdefault, matrix, data.frame, pseries, pdata.frame, grouped_dfCompute cumulative sums
psmatdefault, pseries, data.frame, pdata.frameConvert panel data to matrix / array
psacfdefault, pseries, data.frame, pdata.frameCompute ACF on panel data
pspacfdefault, pseries, data.frame, pdata.frameCompute PACF on panel data
psccfdefault, pseries, data.frame, pdata.frameCompute CCF on panel data