A more difficult type of parametric models is the nonlinear regression model. Here we cannot find just one nice and easy algorithm to solve all problems, as in the linear case. We consider the general parametric model
![]() |
![]() |
![]() |
|
![]() |
![]() |
![]() |
|
![]() |
![]() |
![]() |
We will face the general curvilinear model
randomize(0) ; sets a seed for the random generator x=2*uniform(20)-1 ; generates 20 on [-1,1] uniform ; distributed values eps=normal(20) ; generates 20 standard normal distributed ; values y=2*x^2+eps/2 ; creates y
Next we transform the data
and compute the simple linear
regression using the quantlet
linreg
.
xtrans=x^2 ; transforms x into the variable xtrans {beta,bse,bstan,bpval}=linreg(xtrans,y) ; computes the linear regressionAs in the linear case, we get the ANOVA and parameter tables.
A N O V A SS df MSS F-test P-value ______________________________________________________________ Regression 7.781 1 7.781 30.880 0.0000 Residuals 4.535 18 0.252 Total Variation 12.316 19 0.648 Multiple R = 0.79483 R^2 = 0.63175 Adjusted R^2 = 0.61130 Standard Error = 0.50196 PARAMETERS Beta SE StandB t-test P-value _____________________________________________________________ b[ 0,]= -0.1143 0.1785 -0.0000 -0.640 0.7350 b[ 1,]= 1.7433 0.3137 0.7948 5.557 0.0000Both tables are interpreted as in the previous sections. The parameter table shows the estimates for
Now we want to visualize this result.
data=sort(x~y) ; creates the graphical object for ; the data setmaskp(data,1,11,8) ; sets the options for the graphical ; object data rx=#(-10:10)/10 ; creates the vector (-1,-0.9,...,1) yq=(beta[2]*rx^2) ; creates vector with the regressed ; values rdata=sort(rx~yq) ; creates the graphical object for ; the regressed values rdata=setmask(rdata,"reset","line","red","medium") ; sets the options for the graphical ; object rdata rf=sort(rx~2*rx^2) ; creates the graphical object for ; the original function rf=setmask(rf,"reset","line","green","medium") ; sets the options for the graphical ; object rf nlplot=createdisplay(1,1) ; creates the display nlplot show(nlplot,1,1,data,rdata,rf) ;shows the display nlplot setgopt(nlplot,1,1,"title","Nonlinear Regression") ; sets the title of the display
![]() |
Looking at this plot, we see that the transformation of the variables leads to a
good reproduction of the shape of the true function, even when the errors are
in the same range as the function itself. But we should remember that we have to
know the functions .
We don not want to consider the case leading to a multiple linear regression because the principle is exactly the same as with our example. We just have to use the methods of Section 4.2.