IRIS Toolbox Reference Manual

## convert

Convert tseries object to a different frequency

#### Syntax

    Y = convert(X,NewFreq,...)
    Y = convert(X,NewFreq,Range,...)

#### Input arguments

- `X` [ tseries ] - Input tseries object that will be converted to a new frequency, `freq`, aggregating or intrapolating the data.

- `NewFreq` [ numeric | char ] - New frequency to which the input data will be converted: `1` or `'A'` for yearly, `2` or `'H'` for half-yearly, `4` or `'Q'` for quarterly, `6` or `'B'` for bi-monthly, and `12` or `'M'` for monthly.

- `Range` [ numeric ] - Date range on which the input data will be converted.

#### Output arguments

- `Y` [ tseries ] - Output tseries created by converting `X` to the new frequency.

#### Options

- `'ignoreNaN='` [ `true` | `false` ] - Exclude NaNs from agreggation.

- `'missing='` [ numeric | `NaN` | `'last'` ] - Replace missing observations with this value.

#### Options for high- to low-frequency conversion (aggregation)

- `'method='` [ function_handle | `'first'` | `'last'` | `@mean` ] - Method that will be used to aggregate the high frequency data.

- `'select='` [ numeric | `Inf` ] - Select only these high-frequency observations within each low-frequency period; Inf means all observations will be used.

#### Options for low- to high-frequency conversion (interpolation)

- `'method='` [ char | `'cubic'` | `'quadsum'` | `'quadavg'` ] - Interpolation method; any option available in the built-in `interp1` function can be used.

- `'position='` [ `'centre'` | `'start'` | `'end'` ] - Position of the low-frequency date grid.

#### Description

The function handle that you pass in through the 'method' option when you aggregate the data (convert higher frequency to lower frequency) should behave like the built-in functions `mean`, `sum` etc. In other words, it is expected to accept two input arguments:

- the data to be aggregated,
- the dimension along which the aggregation is calculated.

The function will be called with the second input argument set to 1, as the data are processed en block columnwise. If this call fails, `convert` will attempt to call the function with just one input argument, the data, but this is not a safe option under some circumstances since dimension mismatch may occur.

#### Example

IRIS Toolbox. Copyright © 2007—2013 Jaromir Benes.