Financial Time Series Toolbox    
fillts

Fill missing values in time series

Syntax

Arguments

oldfts
Financial time series object
fill_method
(Optional) To fill using an interpolation menthod, enter 'linear '(default), 'cubic', 'spline', 'nearest', or 'pchip'. To fill with a constant, enter that constant.
newdates
(Optional) Column vector of serial dates, a date string, or a column cell array of date strings. If oldfts contains time of day information, newdates must be accompanied by a time vector (newtimes). Otherwise, newdates is assumed to have times of '00:00'.
T1, T2, TS, TE
First time, second time, start time, end time
delta
Time interval in minutes to span between the start time and end time
sortmode
(Optional) Default = 0 (unsorted). 1 = sorted.

Description

newfts = fillts(oldfts, fill_method) replaces missing values (represented by NaN) in the financial time series object oldfts with real values, using either a constant or the interpolation process indicated by fill_method.

newfts = fillts(oldfts, fill_method, newdates) replaces all the missing values on the specified dates newdates added to the financial time series oldfts with new values. The values may be a single constant or values obtained through the interpolation process designated by fill_method. If any of the dates in newdates exists in oldfts, the existing one has precedence.

newfts = fillts(oldfts, fill_method, newdates, {'T1','T2',...}) additionally allows the designation of specific times of day for addition or replacement of data.

newfts = fillts(oldfts, fill_method, newdates, 'SPAN', {'TS','TE'}, delta) is similar to the previous format except that you designate only a start time and an end time. You follow these times with a spanning time interval, delta.

If you specify only one date for newdates, specifying a start and end time generates only times for that specific date.

newfts = fillts(... sortmode) additionally denotes whether you want the order of the dates in the output object to stay the same as in the input object or to be sorted chronologically.

sortmode = 0 (unsorted) appends any new dates to the end. The interpolation process that calculates the values for the new dates works on a sorted object. Upon completion, the existing dates are reordered as they were originally, and the new dates are appended to the end.

sortmode = 1 sorts the output. After interpolation, no reordering of the date sequence occurs.

Examples

Create a financial time series object with missing data in the fourth and fifth rows.

OpenFts looks like

Example1. Fill the missing data in OpenFts using cubic interpolation.

Example 2. Fill the missing data in OpenFts with a constant value.

Example 3. You can use fillts to identify a specific time on a specific day for the replacement of missing data. This example shows how to replace missing data at 12:00 on January 2 and 11:00 on January 3.

Example 4. Use a spanning time interval to add an additional day to OpenFts.

See Also

interp1 in the MATLAB documentation


  fieldnames filter