主要内容

填充

Fill missing values in time series

填充is not recommended. Usetimetableinstead. For more information, see将财务时间序列对象转换为时间表.

描述

example

newfts= fillts(oldfts,fillmethod)replaces missing values (represented byNaN) in the financial time series objectoldftswith real values, using either a constant or the interpolation process indicated byfillmethod.

example

newfts= fillts(oldfts,fillmethod,newdates)替换指定日期上的所有缺失值newdates添加到财务时间序列oldftswith new values. The values can be a single constant or values obtained through the interpolation process designated byfillmethod. If any of the dates innewdatesexists inoldfts,现有的优先事项。

example

newfts= fillts(oldfts,fillmethod,newdates,newtimes)另外,允许指定一天中的特定时间来添加或更换数据。

example

newfts= fillts(___,delta,sortmode)添加一个时间间隔,deltasortmodedenotes 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.

例子

collapse all

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

    dates = ['01-Jan-2001';'01-Jan-2001';'02-Jan-2001';...'02-Jan-2001';'03-Jan-2001';'03-Jan-2001'];时间= ['11:00';'12:00';'11:00';'12:00';'11:00';'12:00'];dates_times = cellstr([dates, repmat(' ',size(dates,1),1),...时间]);optfts = fints(dates_times,[(1:3)'; nan; nan; nan; 6],{'Data1'},1,...金融开放时间ries')

    开放式looks like this:

    警告:不建议使用菲特。改用时间表。有关更多信息,请参见将财务时间序列对象(金额)转换为时间表。>在Fints(第169行)中= DESC:开放财务时间序列freq:Daily(1){'dates:(6)'} {'times:(6)'} {'data1:(6)'} {'} {'01-Jan-2001'} {'11:00'} {[1]} {'''} {'} {'12:00'} {[2]} {'02 -Jan-2001'} {'11:00'} {[3]} {'''} {'12:00'} {[nan]} {'03 -Jan-2001'} {'11:00'} {[nan]} {[nan]} {'{'12:00'} {[6]}
  2. Fill the missing data in开放式使用立方插值。

    FilledFts = fillts(OpenFts,'立方体')
    警告:不建议使用菲特。改用时间表。有关更多信息,请参见将财务时间序列对象(金额)转换为时间表。> In fints/fillts (line 217) FilledFts = desc: Filled Open Financial Time Series freq: Unknown (0) {'dates: (6)'} {'times: (6)'} {'Data1: (6)'} {'01-Jan-2001'} {'11:00' } {[ 1]} {' " '} {'12:00' } {[ 2]} {'02-Jan-2001'} {'11:00' } {[ 3]} {' " '} {'12:00' } {[ 3.0663]} {'03-Jan-2001'} {'11:00' } {[ 5.8411]} {' " '} {'12:00' } {[ 6]}
  1. Create a financial time series object with missing data in the fourth and fifth rows.

    dates = ['01-Jan-2001';'01-Jan-2001';'02-Jan-2001';...'02-Jan-2001';'03-Jan-2001';'03-Jan-2001'];时间= ['11:00';'12:00';'11:00';'12:00';'11:00';'12:00'];dates_times = cellstr([dates, repmat(' ',size(dates,1),1),...时间]);optfts = fints(dates_times,[(1:3)'; nan; nan; nan; 6],{'Data1'},1,...金融开放时间ries')

    开放式looks like this:

    警告:不建议使用菲特。改用时间表。有关更多信息,请参见将财务时间序列对象(金额)转换为时间表。>在Fints(第169行)中= DESC:开放财务时间序列freq:Daily(1){'dates:(6)'} {'times:(6)'} {'data1:(6)'} {'} {'01-Jan-2001'} {'11:00'} {[1]} {'''} {'} {'12:00'} {[2]} {'02 -Jan-2001'} {'11:00'} {[3]} {'''} {'12:00'} {[nan]} {'03 -Jan-2001'} {'11:00'} {[nan]} {[nan]} {'{'12:00'} {[6]}
  2. 利用填充确定在特定日期的特定时间以替换丢失的数据。此示例显示了1月2日和11:00在1月3日的12:00替换丢失的数据。

    FilltimeFts = fillts(OpenFts,'c',...{'02-Jan-2001';'03-Jan-2001'},{'12:00';'11:00'},0)
    警告:不建议使用菲特。改用时间表。有关更多信息,请参见将财务时间序列对象(金额)转换为时间表。>在Fints/Fillts中(第217行)filltimefts = DESC:填充的打开财务时间序列freq:unknown(0){'dates:(6)'} {'times:(6)'} {'data1:(6)'} {'01 -Jan-2001'} {'11:00'} {[1]} {'''} {'} {'12:00'} {[2]} {'02 -Jan-2001'}11:00'} {[3]} {'''} {'12:00'} {[3.0663]} {'03 -Jan-2001'} {'11:00'} {[5.8411]} {'“'} {'12:00'} {[6]}
  1. Create a financial time series object with missing data in the fourth and fifth rows.

    dates = ['01-Jan-2001';'01-Jan-2001';'02-Jan-2001';...'02-Jan-2001';'03-Jan-2001';'03-Jan-2001'];时间= ['11:00';'12:00';'11:00';'12:00';'11:00';'12:00'];dates_times = cellstr([dates, repmat(' ',size(dates,1),1),...时间]);optfts = fints(dates_times,[(1:3)'; nan; nan; nan; 6],{'Data1'},1,...金融开放时间ries')

    开放式looks like this:

    警告:不建议使用菲特。改用时间表。有关更多信息,请参见将财务时间序列对象(金额)转换为时间表。>在Fints(第169行)中= DESC:开放财务时间序列freq:Daily(1){'dates:(6)'} {'times:(6)'} {'data1:(6)'} {'} {'01-Jan-2001'} {'11:00'} {[1]} {'''} {'} {'12:00'} {[2]} {'02 -Jan-2001'} {'11:00'} {[3]} {'''} {'12:00'} {[nan]} {'03 -Jan-2001'} {'11:00'} {[nan]} {[nan]} {'{'12:00'} {[6]}
  2. 使用跨度时间间隔来增加一天开放式.

    SpanFts = fillts(OpenFts,'c','04-Jan-2001','跨度',...{'11:00';'12:00'},60,0)
    警告:不建议使用菲特。改用时间表。有关更多信息,请参见将财务时间序列对象(金额)转换为时间表。>在Fints/Fillts(第217行)中spanfts = desc:填充的“打开财务时间序列freq:unknown(0)”(0){'dates:(8)'} {'times:(8)'} {'data1:(8)'(8)''} {'01 -Jan-2001'} {'11:00'} {[1]} {'''} {'} {'12:00'} {[2]} {'02 -Jan-2001'}11:00'} {[3]} {'''} {'12:00'} {[3.0663]} {'03 -Jan-2001'} {'11:00'} {[5.8411]} {'“'} {'12:00'} {[6]} {'04 -Jan-2001'} {'11:00'} {[9.8404]} {'9.9994]}

Input Arguments

collapse all

Financial time series object, specified as a弗林特目的。

Data Types:object

有效填充方法(插值方法),指定为字符向量。

  • 'linear'— linear

  • 'linearExtrap'— linear with extrapolation

  • '立方体'- 立方

  • 'cubicExtrap'- 外推

  • “样条”- 样条

  • “ SplineExtrap”- 二线带外推

  • “最近”— nearest

  • “最近的Extrap”- 推断最近

  • 'pchip'- Pchip

  • 'pchipExtrap'- Pchipwith extrapolation

(Seeinterp1for a discussion of extrapolation.)

要填充常数,请输入该常数。

A zero-order hold ('零') fills a missing value with the value immediately preceding it. If the first value in the time series is missing, it remains aNaN.

Data Types:char

日期, specified as a column vector of serial date numbers, a date character vector, or a column cell array of date character vector. Ifoldftscontains time of day information,newdatesmust be accompanied by a time vector (newtimes). Otherwise,newdatesis assumed to have times of'00:00'.

如果仅指定一个日期newdates, specifying a start and end time generates only times for that specific date.

Data Types:double|细胞|char

时代, specified as a date character vector or a column cell array of date character vector. Ifoldftscontains time of day information,newdatesmust be accompanied by a time vector (newtimes). Otherwise,newdatesis assumed to have times of'00:00'.

如果仅指定一个日期newdates, specifying a start and end time generates only times for that specific date.

Data Types:char|细胞

Time interval in minutes, specified as a positive integer.delta是开始时间和结束时间之间的跨度。

Data Types:double

排序模式,指定为一个整数0is unsorted and1is sorted.

  • 0— Unsorted, appends any new dates to the end. The interpolation and zero-order processes that calculate the values for the new dates work on a sorted object. Upon completion, the existing dates are reordered as they were originally, and the new dates are appended to the end.

  • 1— Sorts the output. After interpolation, no reordering of the date sequence occurs.

Data Types:double

Output Arguments

collapse all

Financial time series object, specified as a弗林特目的。

Data Types:object

Version History

在R2006a之前引入