TimeSeriesResample

TimeSeriesResample[tseries]

uniformly resamples tseries according to its minimum time increment.

TimeSeriesResample[tseries,rspec]

resamples tseries according to rspec.

Details and Options

  • TimeSeriesResample is often used to convert irregular time series to regular ones. It can also be used to align time series.
  • The time series tseries can be a list of values {x1,x2,}, a list of time-value pairs {{t1,x1},{t2,x2},}, a TimeSeries, an EventSeries, or TemporalData.
  • Some basic settings for rspec include:
  • dtuse uniform times with spacing dt
    {t_(0),t_(1),dt}use times t0 to t1 with spacing dt
    {{t1,t2,}}use explicit times {t1,t2,}
    dayspecuse day specification
  • Possible dayspec types are: "Weekday", "Weekend", Monday through Sunday, "BeginningOfMonth", "EndOfMonth", "BusinessDay" and "Holiday".
  • If dt is set to Automatic, the minimum time increment in tseries is used.
  • The following settings for rspec are useful if tseries contains multiple paths:
  • "Union"use all times present in tseries
    "Intersection"use times common to all paths
    {"Times",p}use times from path p
  • If times are not given, then tseries is assumed to be regular with unit spacing.
  • TimeSeriesResample takes the following option:
  • ResamplingMethodAutomaticthe method to use for resampling paths
    CalendarType"Gregorian"the calendar system to interpret the dates
    HolidayCalendar{"UnitedStates","Default"}the holiday calendar schedule for business days
    TimeZoneAutomaticthe time zone specification for dates

Examples

open allclose all

Basic Examples  (3)

Resample a time series:

Resampling with spacing smaller than the minimum time increment will add time stamps:

Resampling with spacing larger than the minimum time increment:

Resample time series with dates:

Select business days:

Select weekends:

Select Wednesdays:

Resample an irregular data:

Resample with step of 2:

The resampled time series is now regularly sampled:

Scope  (13)

Basic Uses  (3)

Downsample a time series:

Resample at a granularity of 0.25:

Sample multiple paths at the same time:

Resample at a granularity of 0.1:

Fill in missing values:

Resample at a daily resolution, interpolating holidays and weekends:

Alternatively, insert Missing:

Data Types  (6)

Resample a time series in the form of a vector:

Upsample by a factor of 2:

Downsample by a factor of 2:

A time series given as time-value pairs:

Upsample by a factor of 2:

Downsample by a factor of 2:

Resample a TimeSeries:

Upsample by a factor of 2:

Downsample by a factor of 2:

Resample an EventSeries:

By default, an event series is not interpolated:

Setting the ResamplingMethod overrides this:

A single path given as TemporalData:

Upsample by a factor of 2:

Downsample by a factor of 2:

Multiple paths given as TemporalData:

Upsample by a factor of 2:

Downsample by a factor of 2:

Sampling  (4)

Resample according to the smallest time increment:

The original data is irregular:

Resampling gives regular data with the same minimum time increment:

Specify a sampling increment of 3:

Larger values give coarser sampling:

Use a sampling increment based in calendar time:

Resample multiple paths:

Use the union of times:

The intersection:

Use times from the first path:

Options  (6)

ResamplingMethod  (3)

Resample irregular data using linear interpolation:

By default, the method setting for the data is used:

Setting ResamplingMethod to None gives missing values for irregular data:

Use a constant value:

CalendarType  (1)

The time series of stock prices:

Resample using Islamic calendar:

HolidayCalendar  (1)

The time series of stock prices:

Resample according to business days in United States:

Resample according to business days at New York Stock Exchange:

Find the one business day NYSE was closed:

The holiday observed by NYSE:

TimeZone  (1)

The time series of stock prices:

The time series are not regularly sampled:

Resample according to the NYSE business day in the time zone of New York City:

Applications  (5)

This time series contains the number of steps taken daily by a person during a period of five months:

Analyze the number of steps depending on a day of the week:

Financial information is generated only for business days:

The automatically created time series is not regularly sampled:

Resample according to "BusinessDay" to create a uniformly sampled time series:

The paths are the same:

Consider some financial data:

The data is generated only for business days. There are no changes on the remaining days; hence, we can resample by day by keeping the value from the left:

The plot is flat over the weekends and holidays:

Use AirPressureData to examine pressure changes due to Hurricane Sandy at Long Island MacArthur Airport:

The data is not regularly sampled:

To analyze the rate of change, data needs to be resampled into a regularly sampled time series:

Plotting each observation disjointly shows the rate of change of the pressure, with larger spacing indicating faster changes:

Analyze the monthly temperatures in Champaign during 2014:

The raw data comes in one-day increments:

Resample by a month:

Basic descriptive statistics:

Compare to the original data:

Possible Issues  (1)

The original time stamps may not be preserved after resampling:

Note that the time series is not regularly sampled:

Resample according to MinimumTimeIncrement:

New times:

Introduced in 2014
 (10.0)
 |
Updated in 2019
 (12.0)