/* SAS code to analyze the simulated (X,Y) data */ /* using spline methods */ DATA simul101; INPUT x y; cards; 0.001558089 -0.0275143836 0.010322634 0.0229526318 0.019588978 -0.3722709192 0.031155383 0.1880417225 0.039470235 0.5193859924 0.050893798 0.7796095546 0.060638353 0.0593051071 0.069135384 0.0936865587 0.080085993 0.2476291088 0.089007610 0.5522626497 0.101559494 -0.5101544655 0.110109626 0.2336004762 0.119896825 -0.2678542314 0.131023801 -0.3003349994 0.140135316 -0.1070491861 0.150983426 -0.2024309069 0.160973021 0.0271555309 0.169130407 -0.0994631228 0.178894848 -0.0003285765 0.189534019 -0.0256543952 0.200940805 -0.4767423487 0.211494799 0.2234578740 0.219783391 0.3979888413 0.228767197 -0.0062301798 0.240561085 0.6034813908 0.248753854 -0.4942503149 0.259214863 0.0577412785 0.271478103 -0.1208651268 0.278881512 -0.1144111585 0.289886673 -0.2810700579 0.300750266 -0.2248318255 0.309392180 0.2577575878 0.321129634 -0.2378572677 0.331299495 0.6004522790 0.340849228 0.3863345242 0.349866368 -0.3703850295 0.361226189 0.2228777350 0.369436736 -0.3734564316 0.379745997 0.0550718031 0.390020864 0.2591149284 0.400963974 -0.1687577532 0.410485772 -0.0368406590 0.420337644 0.1820454416 0.429756893 0.1791184027 0.440182441 0.1117545342 0.448373990 -0.0819769959 0.460483300 -0.0739639812 0.470950110 0.4737979878 0.478325853 0.5882504618 0.488673514 0.2830632711 0.500790632 0.7019198536 0.508022021 0.1824885692 0.520765062 0.5185374045 0.528213971 0.0957980079 0.540013981 0.6263592467 0.551752422 0.2982131613 0.559646094 0.9436876159 0.568932914 0.9373470835 0.578102466 1.0841384725 0.590581958 0.6241861980 0.598400620 1.5410935978 0.609421001 1.1901278376 0.619972433 1.0486735539 0.631217363 1.2229511331 0.641028933 0.7224745841 0.651065216 0.9560462743 0.660087239 0.4226520368 0.669695550 0.4490069686 0.680770764 0.6661377243 0.688357314 0.7499764556 0.701834650 0.5534068305 0.708714986 0.8780812196 0.721462996 0.4670242659 0.730448625 0.2681330427 0.739198911 0.3717856451 0.751017579 -0.3764726204 0.761695412 0.1332268308 0.769737903 -0.2066037905 0.781159657 -0.0217042782 0.791944644 0.1767603500 0.801565753 0.0773652988 0.809738294 0.3143307304 0.820411478 -0.0482849804 0.828617004 -0.5898944139 0.840656162 0.2312857444 0.848257913 -0.2166203633 0.861841911 -0.2775760931 0.869121303 -0.4496475846 0.879634071 -0.4727862465 0.889817783 -0.5800511416 0.898431614 -0.8943201956 0.910619605 -1.2119374863 0.920058464 -0.7156604387 0.931489980 -0.3955172258 0.939380457 -0.5877231122 0.951675730 -0.7007006957 0.960087652 -0.4657755464 0.971649512 -0.3680593408 0.979598592 -0.2967003413 0.988638981 0.1141145235 0.998538892 -0.4674138702 ; run; /* SAS's nonparametric regression methods are not typically as easy */ /* to work with as those in R. The regression splines can be done, but */ /* it would require a lot of extra coding. */ /* We can implement the smoothing-spline methods with PROC GAM: */ /* The name(s) of any X variable(s) are placed in the parentheses after */ /* SPLINE in the MODEL statement: */ PROC GAM DATA = simul101; MODEL y = SPLINE(x) / METHOD=GCV; OUTPUT OUT=NEW; run; /* Sorting */ PROC SORT DATA = NEW; BY P_x; run; /* Plotting the data with the smoothing spline overlain: */ symbol1 v=circle l=32 c = black; symbol2 i = join v=none l=32 c = black; PROC GPLOT DATA=NEW; PLOT y*x P_y*P_x/ OVERLAY; RUN;