CRAN\_Status\_Badge R-CMD-check codecov

Time series analysis in the tidyverse


Download the development version with latest features:


Or, download CRAN approved version:


Package Functionality

There are many R packages for working with Time Series data. Hereโ€™s how timetk compares to the โ€œtidyโ€ time series R packages for data visualization, wrangling, and feature engineeering (those that leverage data frames or tibbles).

Task timetk tsibble feasts tibbletime
Data Structure tibble (tbl) tsibble (tbl_ts) tsibble (tbl_ts) tibbletime (tbl_time)
Interactive Plots (plotly) โœ… :x: :x: :x:
Static Plots (ggplot) โœ… :x: โœ… :x:
Time Series โœ… :x: โœ… :x:
Correlation, Seasonality โœ… :x: โœ… :x:
Data Wrangling
Time-Based Summarization โœ… :x: :x: โœ…
Time-Based Filtering โœ… :x: :x: โœ…
Padding Gaps โœ… โœ… :x: :x:
Low to High Frequency โœ… :x: :x: :x:
Imputation โœ… โœ… :x: :x:
Sliding / Rolling โœ… โœ… :x: โœ…
Machine Learning
Time Series Machine Learning โœ… :x: :x: :x:
Anomaly Detection โœ… :x: :x: :x:
Clustering โœ… :x: :x: :x:
Feature Engineering (recipes)
Date Feature Engineering โœ… :x: :x: :x:
Holiday Feature Engineering โœ… :x: :x: :x:
Fourier Series โœ… :x: :x: :x:
Smoothing & Rolling โœ… :x: :x: :x:
Padding โœ… :x: :x: :x:
Imputation โœ… :x: :x: :x:
Cross Validation (rsample)
Time Series Cross Validation โœ… :x: :x: :x:
Time Series CV Plan Visualization โœ… :x: :x: :x:
More Awesomeness
Making Time Series (Intelligently) โœ… โœ… :x: โœ…
Handling Holidays & Weekends โœ… :x: :x: :x:
Class Conversion โœ… โœ… :x: :x:
Automatic Frequency & Trend โœ… :x: :x: :x:

Getting Started


Timetk is an amazing package that is part of the modeltime ecosystem for time series analysis and forecasting. The forecasting system is extensive, and it can take a long time to learn:

  • Many algorithms
  • Ensembling and Resampling
  • Machine Learning
  • Deep Learning
  • Scalable Modeling: 10,000+ time series

Your probably thinking how am I ever going to learn time series forecasting. Hereโ€™s the solution that will save you years of struggling.

Take the High-Performance Forecasting Course

Become the forecasting expert for your organization

High-Performance Time Series Forecasting Course

High-Performance Time Series Course

Time Series is Changing

Time series is changing. Businesses now need 10,000+ time series forecasts every day. This is what I call a High-Performance Time Series Forecasting System (HPTSF) - Accurate, Robust, and Scalable Forecasting.

High-Performance Forecasting Systems will save companies by improving accuracy and scalability. Imagine what will happen to your career if you can provide your organization a โ€œHigh-Performance Time Series Forecasting Systemโ€ (HPTSF System).

How to Learn High-Performance Time Series Forecasting

I teach how to build a HPTFS System in my High-Performance Time Series Forecasting Course. You will learn:

  • Time Series Machine Learning (cutting-edge) with Modeltime - 30+ Models (Prophet, ARIMA, XGBoost, Random Forest, & many more)
  • Deep Learning with GluonTS (Competition Winners)
  • Time Series Preprocessing, Noise Reduction, & Anomaly Detection
  • Feature engineering using lagged variables & external regressors
  • Hyperparameter Tuning
  • Time series cross-validation
  • Ensembling Multiple Machine Learning & Univariate Modeling Techniques (Competition Winner)
  • Scalable Forecasting - Forecast 1000+ time series in parallel
  • and more.

Become the Time Series Expert for your organization.

Take the High-Performance Time Series Forecasting Course


The timetk package wouldnโ€™t be possible without other amazing time series packages.

  • stats - Basically every timetk function that uses a period (frequency) argument owes it to ts().
    • plot_acf_diagnostics(): Leverages stats::acf(), stats::pacf() & stats::ccf()
    • plot_stl_diagnostics(): Leverages stats::stl()
  • lubridate: timetk makes heavy use of floor_date(), ceiling_date(), and duration() for โ€œtime-based phrasesโ€.
    • Add and Subtract Time (%+time% & %-time%): "2012-01-01" %+time% "1 month 4 days" uses lubridate to intelligently offset the day
  • xts: Used to calculate periodicity and fast lag automation.
  • forecast (retired): Possibly my favorite R package of all time. Itโ€™s based on ts, and itโ€™s predecessor is the tidyverts (fable, tsibble, feasts, and fabletools).
    • The ts_impute_vec() function for low-level vectorized imputation using STL + Linear Interpolation uses na.interp() under the hood.
    • The ts_clean_vec() function for low-level vectorized imputation using STL + Linear Interpolation uses tsclean() under the hood.
    • Box Cox transformation auto_lambda() uses BoxCox.Lambda().
  • tibbletime (retired): While timetk does not import tibbletime, it uses much of the innovative functionality to interpret time-based phrases:
    • tk_make_timeseries() - Extends seq.Date() and seq.POSIXt() using a simple phase like โ€œ2012-02โ€ to populate the entire time series from start to finish in February 2012.
    • filter_by_time(), between_time() - Uses innovative endpoint detection from phrases like โ€œ2012โ€
    • slidify() is basically rollify() using slider (see below).
  • slider: A powerful R package that provides a purrr-syntax for complex rolling (sliding) calculations.
    • slidify() uses slider::pslide under the hood.
    • slidify_vec() uses slider::slide_vec() for simple vectorized rolls (slides).
  • padr: Used for padding time series from low frequency to high frequency and filling in gaps.
    • The pad_by_time() function is a wrapper for padr::pad().
    • See the step_ts_pad() to apply padding as a preprocessing recipe!
  • TSstudio: This is the best interactive time series visualization tool out there. It leverages the ts system, which is the same system the forecast R package uses. A ton of inspiration for visuals came from using TSstudio.


Time series analysis in the `tidyverse`

Timetk Info

โญ Stars 463
๐Ÿ”— Homepage business-science.github.io
๐Ÿ”— Source Code github.com
๐Ÿ•’ Last Update 4 months ago
๐Ÿ•’ Created 5 years ago
๐Ÿž Open Issues 10
โž— Star-Issue Ratio 46
๐Ÿ˜Ž Author business-science