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 />

Example 4: Surface <strong>Fitting</strong> using Thin-Plate Smoothing Splines<br />

The following example is taken from the <strong>SAS</strong> Sample Library <strong>and</strong> illustrates the use <strong>of</strong> TPSPLINE to fit a<br />

smooth surface to the sulphate data listed in Annex 1. The data represent the deposition <strong>of</strong> sulphate (SO4) at<br />

179 sites in 48 contiguous states <strong>of</strong> the United States in 1990. Each observation records the latitude <strong>and</strong><br />

longitude <strong>of</strong> the site as well as the SO4 deposition at the site measured in gram per square meter (g/m 2 ).<br />

(i) Open the file tpsplin1.sas.<br />

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

The DATA step (shown below) creates a data set pred containing values <strong>of</strong> latitude <strong>and</strong> longitude over<br />

a finely divided lattice. This data set will be <strong>of</strong>fered to TPSPLINE as a scoring data set upon which the<br />

estimated surface will be based.<br />

data pred;<br />

do latitude = 25 to 47 by 1;<br />

do longitude = 68 to 124 by 1;<br />

output;<br />

end;<br />

end;<br />

run;<br />

The TPSPLINE step specifies a range <strong>of</strong> values for the smoothing parameter.<br />

proc tpspline data=sasgraph.so4;<br />

ods output GCVFunction=gcv;<br />

model so4 = (latitude longitude) /lognlambda=(-6 to 1 by 0.1);<br />

score data=pred out=prediction1;<br />

run;<br />

The ods statement saves values <strong>of</strong> the generalised cross validation function, gcv, for the different<br />

values <strong>of</strong> λ (or more precisely lognlambda (=log10(n*λ))) in an output data set called gcv. A plot <strong>of</strong><br />

gcv against lognlambda is presented below.<br />

goptions reset=all;<br />

axis1 minor=none;<br />

axis2 minor=none;<br />

title 'GCV Function';<br />

proc gplot data=gcv;<br />

plot gcv*lognlambda/ cframe=white<br />

vaxis=axis1 haxis=axis2 ;<br />

format gcv lognlambda d5.2;<br />

symbol1 c=blue i=join v=none w=2;<br />

run;<br />

The gcv plot reveals a local minimum at around –2.56 <strong>and</strong> a global minimum around 0.277. The fitted<br />

estimates saved in the data set prediction1 are based upon the global minimum.<br />

It is instructive to compare the results with estimates based upon the local minimum.<br />

Information Systems Services Page 14 <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!