23.07.2013 Views

Fitting Curves and Surfaces Using SAS Software - ISS - University of ...

Fitting Curves and Surfaces Using SAS Software - ISS - University of ...

Fitting Curves and Surfaces Using SAS Software - ISS - University of ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Fitting</strong> <strong>Curves</strong> <strong>and</strong> <strong>Surfaces</strong> <strong>Using</strong> <strong>SAS</strong> <strong>S<strong>of</strong>tware</strong><br />

Version 1.1 (February 2007)<br />

Inverse quadratic polynomial Y= 1/( β0 + β1/X + β2X)<br />

Both REG <strong>and</strong> NLIN are useful when you know the functional form <strong>of</strong> the model you want to fit. However,<br />

when you have no prior knowledge about the model, or when you know that the data cannot be represented<br />

by a model with a fixed number <strong>of</strong> parameters, two other procedures can be used – LOESS <strong>and</strong> TPSPLINE.<br />

PROC LOESS uses a non-parametric method called Loess Smoothing for estimating regression surfaces.<br />

This approach makes no assumptions about the parametric form <strong>of</strong> the regression surface <strong>and</strong> as a result<br />

<strong>of</strong>fers greater flexibility for model fitting. In particular, the LOESS procedure is suitable when there are outliers<br />

in the data <strong>and</strong> a robust fitting method is necessary.<br />

The TPSPLINE procedure uses a method called penalised least squares to fit non-parametric <strong>and</strong> semiparametric<br />

models. TPSPLINE uses thin-plate smoothing splines to approximate smooth multivariate functions<br />

observed with noise. The degree <strong>of</strong> smoothing can be controlled using the generalised cross validation<br />

function (GCV).<br />

The GAM procedure fits Generalised Additive Models as defined by Hastie <strong>and</strong> Tibshirani (1990). These<br />

models are extensions <strong>of</strong> the generalised linear model, allowing functions to take the place <strong>of</strong> individual<br />

explanatory variables in the model.<br />

A full description <strong>of</strong> these procedures is beyond the scope <strong>of</strong> this text. The user is referred to the <strong>SAS</strong>/STAT<br />

User Guide (available within the online Help system within <strong>SAS</strong>) for details. The examples below illustrate their<br />

use on the sample data sets described in the Annex.<br />

3.1 Parametric Modelling using REG <strong>and</strong> NLIN<br />

Example 2: A Comparison <strong>of</strong> REG, NLIN <strong>and</strong> I=SPLINE<br />

PROC REG <strong>and</strong> PROC NLIN are the main procedures for curve fitting when a functional form for a suitable<br />

curve can be found. This example shows how to use both REG <strong>and</strong> NLIN <strong>and</strong> compares a variety <strong>of</strong> curves<br />

fitted to the same data.<br />

(i) Open the file curve.sas. The program, shown below, creates a small data set used for the example.<br />

data curve1;<br />

input x y @@;<br />

xsq=x*x;<br />

datalines;<br />

0.3 0.2 0.5 0.33 1.0 0.5 1.5 0.6 2.0 0.67 2.5 0.72 3.0 0.75 4.0 0.8<br />

5.0 0.85 6.0 0.87 7.0 0.89 8.0 0.9 9.0 0.91 12.0 0.92 13.0 . 14.0 . 15.0 .<br />

;<br />

run;<br />

(ii) Submit the program by pressing F8.<br />

The last three observations are included with missing values for Y. It will be instructive to see how well<br />

each model performs in estimating values <strong>of</strong> Y for these observations.<br />

A very simple approach would be to use the SYMBOL statement to fit a simple polynomial to the data.<br />

(iii) Open the file splineq.sas. This program uses I=RQ to fit a quadratic to the data.<br />

(iv) Submit the program by pressing F8. The results should correspond to the display shown below.<br />

Information Systems Services Page 6 <strong>of</strong> 22<br />

Version 1.1 (Feb 2007) tut125.doc

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!