ploticus: proc curvefit

## proc curvefit | Welcome Gallery Handbook |
| Manual page for proc_curvefit(PL)

## DESCRIPTION

proc curvefit fits a curve to the data and renders the curve with a line.``

## FEATURES

Can compute moving average, linear regression, or bspline curve.`` Also, complete control over color, width, and dash style of line.``

## EXAMPLES

See the Gallery curvefit examples

## PREREQUISITES

A plotting area must be set up using proc areadef and proc getdata must be executed to access or define some data.`` The data may be presented in any order; proc curvefit will order it in X.``

## MODES

Like proc lineplot, data may be given for both X and Y or just for Y. In the latter case, sequential unit locations are used for the X component.``

## VARIABLES THAT ARE SET

REGRESSION_LINE

  If curvetype is `regression`, this variable will be set to display the formula for the regression line.``

CORRELATION

  If curvetype is `regression`, this variable will be set to display the Pearson correlation coefficient (r), which ranges from -1.0 to 1.0, where 1.0 is a strong correlation (positive slope), -1.0 is a strong correlation (negative slope), and 0 is no correlation.``

## MANDATORY ATTRIBUTE

The `yfield` attribute MUST be specified.``

## ATTRIBUTES

yfield dfield

  Data field to use for Y values.`` Example: `yfield: 1`

xfield dfield

  Data field to use for X values.`` If not given, sequential unit locations in X will be used.`` Example: `xfield: 4`

curvetype `movingavg` | `regression` | `bspline` | `avg`

  The type of curve fitting computation to perform.

  movingavg: For each point, it takes the average of the current point and n-1 points to the left (or as many points as are available).`` n is controlled by the `order` attribute.`` Often used in finance.``

  regression computes the linear regression for the set of points. The result will be a straight line expressing the relationship between X and Y. Often used with scatterplots.`` The variables REGRESSION_LINE and CORRELATION will be set (see VARIABLES above).`` New in version 1.40.``

  bspline draws a curve using the bspline algorithm. The `order` and `resolution` attributes control the appearance of the result. May be used to fit a curve to a histogram.``

  avg is similar to movingavg except that it also includes n-1 points to the right of the current point (or as many points as are available) in the average. Thus, for a point that is far from either edge, 2n-1 points will be averaged.`` New in version 1.40.``

  Example: `curvetype: movingavg`

order n

  For bspline curves, this is a value between 2 and 20; a lower value yields a more jagged curve, while a higher value gives a smoother curve.`` The number of data points must be at least this value for a bspline curve to be possible.``

  For movingavg curves, this defines the number of points to include in each average computation. For avg curves, 2n - 1 points will be considered, where n = the `order` value.``

  This attribute has no effect with regression curve.``

  Default order for either type of curve is 4.``

  Example: `order: 8`

resolution n

  Only relevant for bspline curves. For every input point, n result points will be generated.`` Default is 5.0.``

linedetails linedetails

  Rendering details for the curve.`` Example: `linedetails: color=red width=2.0 style=2`

calcrange min [max]

  Data within this range will be included in curve calculation.`` If only one value is given, it will be taken as the range minima and the maxima will be the plottable maxima.`` If not specified all data rows will be included.``

linerange min [max]

  Controls the X range (in scaled units) within which the curve will be rendered.`` Data points falling outside this range will not be rendered.`` If accumulation is being done, points outside the range will contribute to the accumulated total.`` If only one value is given, it will be taken as the range minima and the maxima will be the plottable maxima.`` If not specified all data rows will be plotted.``

  For regression curves, this attribute may be used to limit the X range of the regression line, or to create a regression line that extends beyond the X range of the data. In this case, min and max should both be given.``

  Example: `linerange: 1`

legendlabel text

  A label to be associated with the curve in the legend.`` proc legend must be executed later in order to render the legend.``

select conditional-expression

  Allows selected data points to be included in curve computation.`` New in version 1.40.``

showresults `yes` | `no`

  If `yes`, a listing of the points in the computed curve will be written to the diagnostic stream (-diag).``

statsonly `yes` | `no`

  For regression curves, this option may be used if it is desired to compute the REGRESSION_LINE and CORRELATION variables but display no curve.`` New in version 1.40.``
  data display engine
  Copyright Steve Grubb

Markup created by unroff 1.0, `` `` June 18, 2001.