The TPSPLINE Procedure

Example 118.2 Spline Model with Higher-Order Penalty

(View the complete code for this example.)

This example continues the analysis of the data set Measure to illustrate how you can use PROC TPSPLINE to fit a spline model with a higher-order penalty term. Spline models with high-order penalty terms move low-order polynomial terms into the polynomial space. Hence, there is no penalty for these terms, and they can vary without constraint.

As shown in the previous analyses, the final model for the data set Measure must include quadratic terms for both and . This example fits the following model:

The model includes quadratic terms for both variables, although it differs from the usual linear model. The nonparametric term explains the variation of the data that is unaccounted for by a simple quadratic surface.

To modify the order of the derivative in the penalty term, specify the M=  option. The following statements specify the option M=3 in order to include the quadratic terms in the polynomial space:

data Measure;
   set Measure;
   x1sq = x1*x1;
   x2sq = x2*x2;
   x1x2 = x1*x2;
run;

proc tpspline data= Measure;
   model y = (x1 x2) / m=3;
   score data = pred out = predy;
run;

Output 118.2.1 displays the results from these statements.

Output 118.2.1: Output from PROC TPSPLINE with M=3

The TPSPLINE Procedure
Dependent Variable: y

Summary of Input Data Set
Number of Non-Missing Observations50
Number of Missing Observations0
Unique Smoothing Design Points25

Summary of Final Model
Number of Regression Variables0
Number of Smoothing Variables2
Order of Derivative in the Penalty3
Dimension of Polynomial Space6

Summary Statistics of Final Estimation
log10(n*Lambda)-3.7831
Smoothing Penalty2092.4495
Residual SS0.2731
Tr(I-A)29.1716
Model DF20.8284
Standard Deviation0.0968
GCV0.0160


The model contains six terms in the polynomial space is the number of columns in (). Compare Output 118.2.1 with Output 118.1.1: the value and the smoothing penalty differ significantly. In general, these terms are not directly comparable for different models. The final estimate based on this model is close to the estimate based on the model by using the default, M=2.

In the following statements, the REG procedure fits a quadratic surface model to the data set Measure:

proc reg data= Measure;
   model y = x1 x1sq x2 x2sq x1x2;
run;

The results are displayed in Output 118.2.2.

Output 118.2.2: Quadratic Surface Model: The REG Procedure

The REG Procedure
Model: MODEL1
Dependent Variable: y

Analysis of Variance
SourceDFSum of
Squares
Mean
Square
F ValuePr > F
Model5443.2050288.64100436.33<.0001
Error448.938740.20315  
Corrected Total49452.14376   

Root MSE0.45073R-Square0.9802
Dependent Mean15.08548Adj R-Sq0.9780
Coeff Var2.98781  

Parameter Estimates
VariableDFParameter
Estimate
Standard
Error
t ValuePr > |t|
Intercept114.908340.12519119.09<.0001
x110.012920.090150.140.8867
x1sq1-4.851940.15237-31.84<.0001
x210.026180.090150.290.7729
x2sq15.206240.1523734.17<.0001
x1x21-0.048140.12748-0.380.7076


The REG procedure produces slightly different results. To fit a similar model with PROC TPSPLINE, you can use a MODEL statement that specifies the degrees of freedom with the DF= option. You can also use a large value for the LOGNLAMBDA0=  option to force a parametric model fit.

Because there is one degree of freedom for each of the terms intercept, x1, x2, x1sq, x2sq, and x1x2, the DF=6 option is used as follows:

proc tpspline data=measure;
   model  y=(x1 x2) /m=3 df=6 lognlambda=(-4 to 1 by 0.5);
   score data = pred
          out = predy;
run;

The fit statistics are displayed in Output 118.2.3.

Output 118.2.3: Output from PROC TPSPLINE Using M=3 and DF=6

The TPSPLINE Procedure
Dependent Variable: y

Summary of Final Model
Number of Regression Variables0
Number of Smoothing Variables2
Order of Derivative in the Penalty3
Dimension of Polynomial Space6

GCV Function
log10(n*Lambda)GCV 
-4.0000000.016330*
-3.5000000.016889 
-3.0000000.027496 
-2.5000000.067672 
-2.0000000.139642 
-1.5000000.195727 
-1.0000000.219512 
-0.5000000.227306 
00.229740 
0.5000000.230504 
1.0000000.230745 

Note: * indicates minimum GCV value.


Summary Statistics of Final Estimation
log10(n*Lambda)2.3830
Smoothing Penalty0.0000
Residual SS8.9384
Tr(I-A)43.9997
Model DF6.0003
Standard Deviation0.4507
GCV0.2309


Output 118.2.4 shows the GCV values for the list of supplied values in addition to the fitted model with fixed degrees of freedom 6. The fitted model has a larger GCV value than all other examined models.

Output 118.2.4: Criterion Plot

Criterion Plot


The final estimate is based on 6.000330 degrees of freedom because there are already 6 degrees of freedom in the polynomial space and the search range for is not large enough (in this case, setting DF=6 is equivalent to setting ).

The standard deviation and RSS (Output 118.2.3) are close to the sum of squares for the error term and the root MSE from the linear regression model (Output 118.2.2), respectively.

For this model, the optimal is around –3.8, which produces a standard deviation estimate of 0.096765 (see Output 118.2.1) and a GCV value of 0.016051, while the model that specifies DF=6 results in a larger than 1 and a GCV value larger than 0.23074. The nonparametric model, based on the GCV, should provide better prediction, but the linear regression model can be more easily interpreted.