Timetk
Time series analysis in the `tidyverse`
Install / Use
/learn @business-science/TimetkREADME
timetk for R
<!-- badges: start --> <!-- badges: end -->Making time series analysis in R easier.
Mission: To make time series analysis in R easier, faster, and more enjoyable.
Installation
Download the development version with latest features:
remotes::install_github("business-science/timetk")
Or, download CRAN approved version:
install.packages("timetk")
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 (retired) | |----|----|----|----|----| | Structure | | | | | | Data Structure | tibble (tbl) | tsibble (tbl_ts) | tsibble (tbl_ts) | tibbletime (tbl_time) | | Visualization | | | | | | 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: |
</div>Getting Started
-
Full Time Series Machine Learning and Feature Engineering Tutorial
-
API Documentation for articles and a complete list of function references.
Summary
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
<a href="https://university.business-science.io/p/ds4b-203-r-high-performance-time-series-forecasting/" target="_blank"><img src="https://www.filepicker.io/api/file/bKyqVAi5Qi64sS05QYLk" alt="High-Performance Time Series Forecasting Course" width="100%" style="box-shadow: 0 0 5px 2px rgba(0, 0, 0, .5);"/></a>
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.
</p> <br> <p class="text-center" style="font-size:30px;"><a href="https://university.business-science.io/p/ds4b-203-r-high-performance-time-series-forecasting">Take the High-Performance Time Series Forecasting Course</a>
</p>Acknowledgements
The timetk package wouldn’t be possible without other amazing time
series packages.
stats- Basically everytimetkfunction that uses a period (frequency) argument owes it tots().plot_acf_diagnostics(): Leveragesstats::acf(),stats::pacf()&stats::ccf()plot_stl_diagnostics(): Leveragesstats::stl()
- lubridate:
timetkmakes heavy use offloor_date(),ceiling_date(), andduration()for “time-based phrases”.- Add and Subtract Time (
%+time%&%-time%):"2012-01-01" %+time% "1 month 4 days"useslubridateto intelligently offset the day
- Add and Subtract Time (
- 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 its predecessor is thetidyverts(fable,tsibble,feasts, andfabletools).- The
ts_impute_vec()function for low-level vectorized imputation using STL + Linear Interpolation usesna.interp()under the hood. - The
ts_clean_vec()function for low-level vectorized imputation using STL + Linear Interpolation usestsclean()under the hood. - Box Cox transformation
auto_lambda()usesBoxCox.Lambda().
- The
- tibbletime
(retired): While
timetkdoes not importtibbletime, it uses much of the innovative functionality to interpret time-based phrases:tk_make_timeseries()- Extendsseq.Date()andseq.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 basicallyrollify()usingslider(see below).
- slider: A powerful R package that
provides a
purrr-syntax for complex rolling (sliding) calculations.slidify()usesslider::pslideunder the hood.slidify_vec()usesslider::slide_vec()for simple vectorized rolls (slides).
- padr: Used for padding time series from low frequency to h
Related Skills
groundhog
398Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
isf-agent
a repo for an agent that helps researchers apply for isf funding
workshop-rules
Materials used to teach the summer camp <Data Science for Kids>
last30days-skill
13.4kAI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
