``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71``` ```* (Q) In a Non linear interpolation, how can I use the variance of the residuals as the loss function. *(A) This is using example from page 98 of SPSS regression models 9.0. * However the loss function is the variance of the residuals. * This is NOT TRIVIAL because only transformations may be used to calculate the loss functions. In addition, LAG cannot be used after the MODEL command. * Raynald Levesque rlevesque@videotron.ca 2002/02/03. * Visit my SPSS pages http://pages.infinit.net/rlevesqu/index.htm. DATA LIST LIST /pop. BEGIN DATA 3.895 5.267 7.182 9.566 12.834 16.985 23.069 31.278 38.416 49.924 62.692 75.734 91.812 109.806 122.775 131.669 150.697 178.464 END DATA. COMPUTE decade=\$CASENUM-1. COMPUTE yr=1790+decade*10. FORMATS decade yr(F8.0). LIST. SET MPRINT=no. *//////////////////////. DEFINE !leave (!POS=!TOKENS(1) /!POS=!TOKENS(1)) !DO !cnt=1 !TO 17 DO IF idx=!cnt. LEAVE !CONCAT(v,!cnt). END IF. !DOEND !ENDDEFINE. *//////////////////////. SET MPRINT=yes. COMPUTE idx=\$CASENUM. * NonLinear Regression. MODEL PROGRAM A=3.9 B=-0.29 C=200 . COMPUTE pred_ = C/(1+EXP(A+ B * decade)). COMPUTE resid_ = pop - PRED_. * The next 3 lines copy all the resid_ values into the LAST case. VECTOR v(18F8.0). COMPUTE v(idx)=resid_. !leave. * Calculate variance of resid_. COMPUTE sigma2=SD(v1 TO v18)**2. * Keep only the value calculated in the LAST case. IF idx<18 sigma2=0. * sigma2 is the LOSS function. CNLR pop /OUTFILE='C:\\temp\\SPSSFNLR.TMP' /PRED pred_ /LOSS sigma2 /BOUNDS C >= 150 /CRITERIA ITER 20 STEPLIMIT 2 ISTEP 1E+20 . ```
Related pages

...