<html> <head> <!-- This file has been generated by unroff 1.0, 03/11/09 12:56:13. --> <!-- Do not edit! --> <STYLE TYPE="text/css"> <!-- A:link{text-decoration:none} A:visited{text-decoration:none} A:active{text-decoration:none} OL,UL,P,BODY,TD,TR,TH,FORM { font-family: arial,helvetica,sans-serif;; font-size:small; color: #333333; } H1 { font-size: x-large; font-family: arial,helvetica,sans-serif; } H2 { font-size: large; font-family: arial,helvetica,sans-serif; } H3 { font-size: medium; font-family: arial,helvetica,sans-serif; } H4 { font-size: small; font-family: arial,helvetica,sans-serif; } --> </STYLE> <title>ploticus: proc curvefit</title> <body bgcolor=D0D0EE vlink=0000FF> <br> <br> <center> <table cellpadding=2 bgcolor=FFFFFF width=550><tr> <td> <table cellpadding=2 width=550><tr> <td><br><h2>proc curvefit</h2></td> <td align=right> <small> <a href="../doc/welcome.html"><img src="../doc/ploticus.gif" border=0></a><br> Version 2.41 Mar2009 </small><br><a href="../doc/scripthome.html">Scripts</a> <td></tr></table> </td></tr> <td> <br> <br> <title>Manual page for proc_curvefit(PL)</title> </head> <body> <center> <img src="../gallery/curvefit3.gif"> </center> <p> <b>proc curvefit</b> uses the <a href="dataformat.html#currentds"> current data set </a> to compute a curve which it then renders in the <a href="areadef.html"> current plotting area.<tt> </tt> </a> Available curve types are: moving average, average, linear regression, bspline, and interpolated curves.<tt> </tt> Typical uses are to clarify overall trends in the data, or for smoothing.<tt> </tt> (If you just want to draw a line connecting your data points, without any smoothing, use <a href="lineplot.html"> proc lineplot.) </a> The data do not have to be in X order.. they will be sorted on X as part of the process (except with the interpolated curve type). See also the <a href="../gallery/gall.curvefit.html"> gallery curvefit examples.<tt> </tt> </a> <p> Limitations: The maximum number of input points for a bspline curve is 100. The default maxiumum number of input points for all other curve types is 1000.. to raise this limit use the proc curvefit attribute <tt>maxinpoints</tt>.<tt> </tt> Generated curve points are placed into the plotting vector; its size can be controlled using command line argument <tt>-maxvect</tt>.<tt> </tt> <br><br><br> <h2>Attributes</h2> The <tt>yfield</tt> attribute MUST be specified.<tt> </tt> <p> <b>yfield</b> <a href="attributetypes.html#dfield"> dfield </a> <dl> <dt> <dd> Data field to use for Y values. Example: <tt>yfield: 1</tt> <br><br> </dl> <p> <b>xfield</b> <a href="attributetypes.html#dfield"> dfield </a> <dl> <dt> <dd> Data field to use for X values.<tt> </tt> If not given, sequential unit locations in X will be used.<tt> </tt> Example: <tt>xfield: 4</tt> <br><br> </dl> <p> <b>curvetype</b> <tt>movingavg</tt> | <tt>regression</tt> | <tt>bspline</tt> | <tt>avg</tt> | <tt>interpolated</tt> <dl> <dt> <dd> The type of curve fitting computation to perform. <dt> <dd> <b>movingavg</b> - for each point, it takes the average of the current point and <i>n</i>-1 points to the left (or as many points as are available).<tt> </tt> <i>n</i> is controlled by the <tt>order</tt> attribute.<tt> </tt> Often used in finance.<tt> </tt> <dt> <dd> <b>regression</b> - 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.<tt> </tt> The variables REGRESSION_LINE and CORRELATION will be set (see VARIABLES above).<tt> </tt> <dt> <dd> <b>bspline</b> - draws a curve using the bspline algorithm. The <tt>order</tt> and <tt>resolution</tt> attributes control the appearance of the result. May be used to fit a curve to a histogram.<tt> </tt> <dt> <dd> <b>avg</b> - similar to movingavg except that it also includes <i>n</i>-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, 2<i>n</i>-1 points will be averaged.<tt> </tt> <dt> <dd> <b>interpolated</b> - a spline interpolation between the given data points, ie. the curve will pass through all input data points (this type is new in version 2.20, code contibuted by Oliver Koch) <dt> <dd> Example: <tt>curvetype: movingavg</tt> <br><br> </dl> <p> <b>maxinpoints</b> n <dl> <dt> <dd> Maximum number of input points for curve types other than bspline. Default is 1000. (ver 2.30+) <br><br><br> </dl> <h2>Details of curve appearance</h2> <p> <b>order</b> <i>n</i> <dl> <dt> <dd> 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.<tt> </tt> The number of data points must be at least this value for a bspline curve to be possible.<tt> </tt> <dt> <dd> For movingavg curves, this defines the number of points to include in each average computation. For avg curves, 2<i>n</i> - 1 points will be considered, where <i>n</i> = the <tt>order</tt> value.<tt> </tt> <dt> <dd> This attribute has no effect with regression or interpolated curve.<tt> </tt> <dt> <dd> Default order for either type of curve is 4.<tt> </tt> <dt> <dd> Example: <tt>order: 8</tt> <br><br> </dl> <p> <b>resolution</b> <i>n</i> <dl> <dt> <dd> Only relevant for bspline curves. For every input point, <i>n</i> result points will be generated.<tt> </tt> Default is 5.0.<tt> </tt> <br><br> </dl> <p> <b>linedetails</b> <a href="linedetails.html"> linedetails </a> <dl> <dt> <dd> Appearance details for the curve.<tt> </tt> Note that dash patterns may not be effective with generated curves (other than regression curves) because of point density.<tt> </tt> <br> Example: <tt>linedetails: color=red width=2.0 </tt> <br><br> </dl> <p> <b>xsort</b> <tt>yes | no</tt> <dl> <dt> <dd> Whether or not to sort the input data on <tt>xfield</tt> before generating curves of the <tt>interpolated</tt> type.<tt> </tt> Default is <tt>no</tt>.<tt> </tt> <br><br><br> </dl> <h2>Range control & selecting data rows</h2> <p> <b>select</b> <a href="select.html"> select expression </a> <dl> <dt> <dd> Allows selected data points to be included in curve computation.<tt> </tt> <br> Example: <tt>select: @@3 > 0</tt> <br><br> </dl> <p> <b>calcrange</b> <i>min</i> [<i>max</i>] <dl> <dt> <dd> Data within this X range will be included in curve calculation.<tt> </tt> If only one value is given, it will be taken as the range minima and the maxima will be the plottable maxima.<tt> </tt> If not specified all data rows will be included.<tt> </tt> <br><br> </dl> <p> <b>linerange</b> <i>min</i> [<i>max</i>] <dl> <dt> <dd> Controls the X range (in scaled units) within which the curve will be rendered.<tt> </tt> Data points falling outside this range will not be rendered.<tt> </tt> If accumulation is being done, points outside the range will contribute to the accumulated total.<tt> </tt> If only one value is given, it will be taken as the range minima and the maxima will be the plottable maxima.<tt> </tt> If not specified all data rows will be plotted.<tt> </tt> <dt> <dd> 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, <i>min</i> and <i>max</i> should both be given.<tt> </tt> <dt> <dd> Example: <tt>linerange: 1</tt> <br><br> </dl> <p> <b>clip</b> <tt>yes | no</tt> <dl> <dt> <dd> Default is <tt>no</tt>. If set to <tt>yes</tt>, generated curve will be clipped to the plotting area in Y. (Regression curves are always clipped.) (2.30+) <br><br><br> </dl> <h2>Legend</h2> <p> <b>legendlabel</b> <a href="attributetypes.html#text"> text </a> <dl> <dt> <dd> A label to be associated with the curve in the legend.<tt> </tt> <b>proc legend</b> must be executed later in order to render the legend.<tt> </tt> The <tt>\n</tt> construct can be used to force a line break or the label can be wordwrapped using proc legend wraplen attribute (2.32+).<tt> </tt> If <a href="getdata.html"> proc getdata field names </a> are being used, the special symbol <tt>#usefname</tt> causes the field name of <tt>yfield</tt> to be automatically used as the legend label (2.04+).<tt> </tt> <br> Example: <tt>legendlabel: Northeast region</tt> <br> Example: <tt>legendlabel: #usefname</tt> <br><br><br> </dl> <h2>Accessing the coordinates of the generated curve</h2> <p> <b>showresults</b> <tt>yes</tt> | <tt>no</tt> <dl> <dt> <dd> If <tt>yes</tt>, a listing of the points in the computed curve will be written to the diagnostic stream (-diag).<tt> </tt> <br><br> </dl> <p> <b>statsonly</b> <tt>yes</tt> | <tt>no</tt> <dl> <dt> <dd> If <tt>yes</tt>, don't draw the result curve. This is for situations where the user only wants the computed curve values (<tt>showresults</tt>) or the REGRESSION_LINE and CORRELATION variables to be set.<tt> </tt> <br><br><br> </dl> <h2>Variables that are set by proc curvefit</h2> <p> <b>REGRESSION_LINE</b> <dl> <dt> <dd> If curvetype is <tt>regression</tt>, this variable will be set to display the formula for the regression line.<tt> </tt> </dl> <p> <b>CORRELATION</b> <dl> <dt> <dd> If curvetype is <tt>regression</tt>, 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.<tt> </tt> </dl> <p> <b>XFINAL</b> and <b>YFINAL</b> <dl> <dt> <dd> are set to the final location (in scaled space) of the end of the drawn curve.<tt> </tt> <br> <br> </td></tr> <td align=right> <a href="../doc/welcome.html"> <img src="../doc/ploticus.gif" border=0></a><br><small>data display engine <br> <a href="../doc/Copyright.html">Copyright Steve Grubb</a> <br> <br> <center> <img src="../gallery/all.gif"> </center> </td></tr> </table> <br> <center> <table><tr><td> Ploticus is hosted at http://ploticus.sourceforge.net</td><td> </td><td> <a href="http://sourceforge.net/projects/ploticus"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=38453&type=12" width="120" height="30" border="0" alt="Get ploticus data display engine at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a> </td></tr></table> </center> </dl> <p><hr> Markup created by <em>unroff</em> 1.0, <tt> </tt> <tt> </tt>March 11, 2009. </body> </html>