# Curve Fitting Using SigmaPlot

Does systolic blood pressure increase with age? If so, by how much? A sample of 27 individuals was randomly selected from a population with ages ranging from 20 to 70 years. The response variable is measured as the average systolic blood pressure at a fixed time during the day over a 1-week period.

One can either directly enter the data into the worksheet or import it from other files. For more information see “Importing Options in SigmaPlot” in Appendix A. The figure below shows that data obtained from the SigmaPlot notebook: “Age vs Blood Pressure.jnb”

Now, highlight all the data columns, and create a simple scatter plot.

(Choose the Simple Scatter icon on the 2D graph toolbar or use Graph >> Create Graph >> Scatter Plot )

Once you click on the Simple scatter plot, a dialog box appears on the screen (The wizard for creating the plot).

Next Step:

The plot appears on a separate graph page (Graph Page 1). The scatter plot shows the strength of the relationship between the two variables.

Note : You can further customize the plot by choosing the Graph Properties option after right clicking the graph or use Graph>> Graph Properties. Possible customization may include changing the color of data points, renaming X and Y axes titles, background color, technical axes, data point symbols, etc.

Right click one of the data points of the plot, and choose the “Fit Curve” command. This opens the Regression Wizard.

Select an equation from the Equation Category and Equation Name drop-down lists. You can view different equations by selecting different categories and names. The equation’s mathematical expression and shape appear to the left. If the equation you want to use isn’t on the list, you can create a new equation. For more information on creating a user defined equation see “Editing Code” in Appendix B.

When you proceed to the next step of the Regression Wizard, you need to choose the variable columns from the data sheet. You can select it either using drop down list (Variable Columns) or by highlighting the columns in the data sheet. The equation picture to the left prompts you for which variable to select.

Note that if you right clicked on a data point and selected Curve Fit then the variable selection is done for you. You can also modify other equation settings and options from this panel by clicking Options, which opens the Equations Options dialog box. For more information see “Equation Options” in Appendix C.

The next step of the Regression wizard displays the results of the fit in a dialog box.

The Numeric Output options dialog box allows you to specify the result columns that you want to be included in your data sheet.

The next step of the Regression Wizard adds the fitted curve to the plot.

The final step of regression wizard is to include the data of the curve in the data sheet.

After you complete the wizard, it adds the fitted curve to the existing graph and also generates a report page. The figure below shows the fitted curve.

Double click on Report 1* in the Notebook Manager. The figure below shows the report generated.

The figure below shows the modified datasheet (Double Click on Data 1* in the Notebook Manager to view the data sheet).

Suppose if you want to find the blood pressure for someone whose age is about 26, then you should choose the option Plot Equation by right clicking on one of the data points of the plot or use Graph >> Plot Equation.

Nonlinear curve fitting is an iterative process that may converge to find a best possible solution. It begins with a guess at the parameters, checks to see how well the equation fits, the continues to make better guesses until the differences between the residual sum of squares no longer decreases significantly. For complicated curve fitting problems, use SigmaPlot’s Dynamic Fit Wizard to find the best solution.

- The Dynamic Fit Wizard automates the search for initial parameter values that lead to convergence to the best possible solution.
- Like the Regression Wizard, the Dynamic Fit Wizard is a step-by-step guide through the curve fitting procedures, but with an additional panel in which you set the search options (in the figure below)

Please note that Dynamic Fit Wizard is especially useful for more difficult curve fitting problems with three or more parameters and possibly a large amount of variability in the data points. For linear regressions or less difficult problems, such as simple exponential two parameter fits, the Dynamic Fit Wizard is overkill and you should use the Regression Wizard.

#### Appendix A: Importing Options in SigmaPlot

**Importing Options:**

You can import data from other applications into an existing worksheet for graphing, worksheet display, or running regressions. When you import data, it appears at the position of the worksheet cursor.

- SAS Data Set (V6) (*.sd2)
- SAS Data Set (V8 and V9) (*.sas7bdat)
- SAS Export File (*.xpt)
- Minitab (v8 to v12) (*.mtw, *mpj)

**You can import the following file types into SigmaPlot worksheets:**

- SPSS (.sav)
- TableCurve 2D and 3D files
- Microsoft Excel files (.xls)
- Lotus 1-2-3 files (.wks, .wk*)
- Quattro/DOS files (.wk*)
- Plain Text files (.txt, .prn, .dat, .asc)
- Comma Delimited files (.csv)
- SigmaStat Worksheets
- SigmaScan, SigmaScanPro Worksheets and SigmaScan Image
- Mocha Worksheets
- Axon Text and Binary formats
- Paradox (.db)
- Symphony (.wkl, .wri, .wrk, .wks)
- SYSTAT (.sys, .syd)
- Microsoft Access (.mdb)

**To import data:**

Place the cursor to the worksheet cell where you want the imported data to start. From the menus select:

**File >> Import**

The Import File dialog box appears.

- Select the type of file you want to import from the Files of Type drop-down list.
- Change the drive and directory as desired, select the file you want to read, then click Import, or double-click the file name. Depending on the type of file, the data is either imported immediately, or another dialog box appears.

#### Appendix B: Editing Code

You can edit a regression equation or create a user defined equation by clicking the Edit Code button in the Regression Wizard or the Dynamic Fit Wizard. This opens the Functions dialog box. Creating a new equation requires entry of all the code necessary to perform a regression.

Note: Built-in equations will have the curve equation and initial parameters predefined. Also this dialog is expandable.Â You can stretch it both vertically and horizontally to view long equations or complex models with many equations.

#### Appendix C: Equation Options

If the curve fitter fails to find a good fit for the curve, you can try changing the equation options to see if you can improve the fit.

#### Appendix D: When to Use Curve Fitting

- Remove measurement noise
- Fill in missing data points, such as when one or more measurements are missing or improperly recorded
- Interpolate, which is estimating data between data points, such as if the time between measurements is not small enough
- Extrapolate, which is estimating data beyond data points, such as looking for data values before or after a measurement
- Differentiate digital data, such as finding the derivative of the data points by modeling the discrete data with a polynomial and differentiating the resulting polynomial equation
- Integrate digital data, such as finding the area under a curve when you have only the discrete points of the curve
- Obtain the trajectory of an object based on discrete measurements of its velocity, which is the first derivative or acceleration, which is the second derivative