apaCharts.Step(X, Y, StepPosition)
=apaCharts.Step(X, Y, StepPosition)Result
Creates input data for a step chart, to be plotted as an Excel XY chart with straight lines, e.g. for empirical distribution functions, state paths of regime models or rating histories. The output has the same layout as apaCharts.Scatter.XY: one block of rows per series, stacked vertically, with the x values in the first column and the y values of series j in column j + 1; all other cells contain #N/A.
Syntax
X: r x c matrix of x values: either one column, used for all series, or the same number of columns as Y
Y: r x c matrix of y values, each column a different data series
StepPosition: optional; position of the steps: 0 = post, y(i) holds from x(i) up to x(i+1); 1 = pre, y(i) holds from x(i-1) up to x(i); 2 = mid, the steps lie halfway between consecutive x values; default: 0
Algorithm
Each pair of consecutive observations is connected by a horizontal and a vertical line segment. With StepPosition = 0, the line runs from (x(i-1), y(i-1)) horizontally to (x(i), y(i-1)) and then vertically to (x(i), y(i)); with StepPosition = 1, it runs vertically to (x(i-1), y(i)) and then horizontally to (x(i), y(i)); with StepPosition = 2, the vertical segment is placed at the midpoint of x(i-1) and x(i). Each block has 2r - 1 rows for StepPosition 0 and 1, and 2r rows for StepPosition 2.
Remarks
The observations are used in the given order, so x should normally be sorted in ascending order. Points derived from a non-numeric x or y value are returned as #N/A.
