If you specify the PROJSTUDENT= option in the OUTPUT statement, PROC NLIN saves incorrect standardized projected residuals in the output data set.
In addition, if you specify the PLOTS= DIAGNOSTICS option in the PROC NLIN statement and ODS Graphics is enabled, the standardized projected residuals that are used in the FitDiagnosticsPanel plot are not correct.
In particular, the σ2 estimate that is used in computing standardized projected residuals, denoted by ẽp , in the above two cases is incorrect.
You can circumvent this issue by specifying two separate PROC NLIN steps.
In the first PROC NLIN step, specify the NLINMEASURES option in the PROC NLIN statement and save all other output statistics or plots except for the standardized projected residuals. The NLINMEASURES option produces the Global Nonlinearity Measures output table. The value for the Projected Residual Variance measure reported in this table is the correct σ2 to use in the denominator for computing the standardized projected residual.
In the second PROC NLIN step, specify the value for the Projected Residual Variance from the first step in the SIGSQ = option in the PROC NLIN statement. The standardized projected residuals obtained in the second PROC NLIN step are correct. Save only the standardized projected residuals in the second step since the SIGSQ = option can have an impact on other output statistics.
The following example demonstrates the syntax for the steps described above:
data contrived;
input x1 x2 y;
datalines;
-4.0 -2.5 -10.0
-3.0 -2.0 -5.0
-2.0 -1.5 -2.0
-1.0 -1.0 -1.0
0.0 0.0 1.5
1.0 1.0 4.0
2.0 1.5 5.0
3.0 2.0 6.0
4.0 2.5 7.0
-3.5 -2.2 -7.1
-3.5 -1.7 -5.1
3.5 0.7 6.1
2.5 1.2 7.5
;
/*Step 1: Run PROC NLIN to compute the Projected Residual Variance */
proc nlin data=contrived nlinmeasures ;
parms alpha=2.0 gamma=0.0;
model y=alpha*x1 + exp(gamma*x2);
output out=b1 student=rstudent lcl=lcl ucl=ucl ;
run;
Note that the Global Nonlinearity Measures output shows that the Projected Residual Variance is equal to 1.4551:
/* Step 2: Specify the variance in the SIGSQ= option */
proc nlin data=contrived sigsq=1.4551 ;
parms alpha=2.0 gamma=0.0;
model y=alpha*x1 + exp(gamma*x2);
output out=b2 projstudent=projstudent ;
run;
The output data set B2 created in the second PROC NLIN step contains the correct standardized projected residuals.
As an alternative to hardcoding the SIGSQ value above, you can save the Projected Residual Variance in a macro variable. Here is an example:
/* Save the NonLinearityMeasure table in a data set*/
ods output nonlinearitymeasures=measure;
proc nlin data=contrived nlinmeasures ;
parms alpha=2.0 gamma=0.0;
model y=alpha*x1 + exp(gamma*x2);
output out=b1 student=rstudent lcl=lcl ucl=ucl;
run;
/*Save the value of the Projected Residual Variance to a macro variable named &sig2p */
data null ;
set measure(where=(Label1='Projected Residual Variance'));
call symput('sig2p', nValue1);
run;
/*Use the macro variable as the argument to the SIGSQ= option*/
proc nlin data=contrived sigsq=&sig2p ;
parms alpha=2.0 gamma=0.0;
model y=alpha*x1 + exp(gamma*x2);
output out=b2 projr=projstudent = projstu ;
run;
Reference: Cook and Tsai (1985) Residuals in Nonlinear Regression. Biometrika, 72, 23-29.