17  Nonlinear Regression

Many relationships in agriculture are inherently nonlinear: crop growth follows an S-shaped curve that approaches a ceiling, yield approaches a plateau as fertilizer increases (the law of diminishing returns), pest populations grow exponentially, leaf area is a power function of leaf length, and soil nutrients are released by first-order kinetics. Some of these can be made linear by a transformation; others cannot. This chapter covers both cases, and the method of nonlinear least squares (Bates and Watts 1988; Draper and Smith 1998; Montgomery, Peck, and Vining 2021).

17.1 Intrinsically linear models

A model is intrinsically linear if a transformation of \(y\) and/or \(x\) makes it linear in the parameters.

Table 17.1: Common intrinsically linear models
Model Form Linearized form Regress
Exponential \(y=ae^{bx}\) \(\ln y=\ln a+bx\) \(\ln y\) on \(x\)
Exponential (base \(b\)) \(y=ab^x\) \(\ln y=\ln a+x\ln b\) \(\ln y\) on \(x\)
Power \(y=ax^b\) \(\ln y=\ln a+b\ln x\) \(\ln y\) on \(\ln x\)
Logarithmic \(y=a+b\ln x\) (already linear) \(y\) on \(\ln x\)
Reciprocal \(y=1/(a+bx)\) \(1/y=a+bx\) \(1/y\) on \(x\)
Hyperbolic \(y=x/(a+bx)\) \(1/y=b+a(1/x)\) \(1/y\) on \(1/x\)
Cobb–Douglas \(y=AL^{\beta_1}K^{\beta_2}\) \(\ln y=\ln A+\beta_1\ln L+\beta_2\ln K\) \(\ln y\) on \(\ln L\), \(\ln K\)

17.1.1 Fitting the exponential curve

For \(y=ab^x\), taking logarithms gives \(Y=A+Bx\) with \(Y=\ln y\), \(A=\ln a\), \(B=\ln b\). The normal equations are

\[\sum Y=nA+B\sum x,\qquad \sum xY=A\sum x+B\sum x^2, \tag{17.1}\]

and \(a=e^A\), \(b=e^B\). The growth rate per unit of \(x\) is \((b-1)\times100\%\); this is how compound growth rates of area, production and productivity are computed from time series (\(x\) = year).

17.1.2 Fitting the power curve

For \(y=ax^b\), \(\ln y=\ln a+b\ln x\). With \(X=\ln x\) and \(Y=\ln y\),

\[\sum Y=n\ln a+b\sum X,\qquad \sum XY=\ln a\sum X+b\sum X^2. \tag{17.2}\]

The exponent \(b\) is the elasticity: a 1% increase in \(x\) gives a \(b\%\) increase in \(y\).

Example 17.1 The length (cm) and area (cm²) of 15 banana sucker leaves are in csv/leaf.csv. Fit the power curve \(\text{area}=a\cdot\text{length}^b\).

Solution

With \(X=\ln(\text{length})\) and \(Y=\ln(\text{area})\): \(n=15\), \(\sum X=46.1449\), \(\sum Y=81.0448\), \(\sum X^2=145.3590\), \(\sum XY=255.8730\). Solving Equation 17.2,

\[b=\frac{n\sum XY-\sum X\sum Y}{n\sum X^2-(\sum X)^2}=1.9260,\qquad \ln a=\bar Y-b\bar X=-0.5219,\qquad a=e^{-0.5219}=0.5934.\]

The fitted curve is \(\widehat{\text{area}}=0.593\times\text{length}^{1.926}\). An exponent close to 2 is expected for leaves of similar shape, since area scales with the square of a linear dimension.

Note

Fitting on the log scale assumes multiplicative errors, \(y=ax^b\varepsilon\), so that \(\ln\varepsilon\) is additive with constant variance. If instead the error is additive, \(y=ax^b+\varepsilon\), the model is intrinsically nonlinear and should be fitted by nonlinear least squares; the log-scale fit can provide good starting values. Also, \(e^{\hat A}\) estimates the median, not the mean, of \(y\) at \(x=0\) (or \(x=1\)).

17.2 Intrinsically nonlinear models

The general nonlinear regression model is

\[y_i=f(\mathbf x_i,\boldsymbol\theta)+\varepsilon_i,\qquad i=1,2,\ldots,n, \tag{17.3}\]

where \(f\) is a known function, nonlinear in the \(p\) parameters \(\boldsymbol\theta=(\theta_1,\ldots,\theta_p)'\), and \(\varepsilon_i\sim\text{iid }N(0,\sigma^2)\).

17.3 Nonlinear least squares

The least squares estimate minimizes

\[S(\boldsymbol\theta)=\sum_{i=1}^n\left[y_i-f(\mathbf x_i,\boldsymbol\theta)\right]^2. \tag{17.4}\]

Under normal errors this is also the maximum likelihood estimate. Differentiating and equating to zero gives the normal equations

\[\sum_{i=1}^n\left[y_i-f(\mathbf x_i,\hat{\boldsymbol\theta})\right]\left[\frac{\partial f(\mathbf x_i,\boldsymbol\theta)}{\partial\theta_j}\right]_{\boldsymbol\theta=\hat{\boldsymbol\theta}}=0,\qquad j=1,\ldots,p. \tag{17.5}\]

Unlike the linear case, the derivatives depend on \(\boldsymbol\theta\), so these equations are nonlinear and must be solved iteratively.

17.3.1 The Gauss–Newton (linearization) method

Let \(\boldsymbol\theta_0\) be a starting value. Expand \(f\) in a first-order Taylor series about \(\boldsymbol\theta_0\):

\[f(\mathbf x_i,\boldsymbol\theta)\approx f(\mathbf x_i,\boldsymbol\theta_0)+\sum_{j=1}^p\left[\frac{\partial f(\mathbf x_i,\boldsymbol\theta)}{\partial\theta_j}\right]_{\boldsymbol\theta_0}(\theta_j-\theta_{j0}).\]

Writing \(\mathbf r_0=\mathbf y-\mathbf f(\boldsymbol\theta_0)\) (current residuals), \(\mathbf F_0\) for the \(n\times p\) matrix of derivatives \(F_{ij}=\partial f(\mathbf x_i,\boldsymbol\theta)/\partial\theta_j\) at \(\boldsymbol\theta_0\), and \(\boldsymbol\delta=\boldsymbol\theta-\boldsymbol\theta_0\), the model becomes approximately linear:

\[\mathbf r_0\approx\mathbf F_0\boldsymbol\delta+\boldsymbol\varepsilon.\]

Ordinary least squares gives the correction

\[\hat{\boldsymbol\delta}_0=(\mathbf F_0'\mathbf F_0)^{-1}\mathbf F_0'\mathbf r_0,\qquad \boldsymbol\theta_1=\boldsymbol\theta_0+\hat{\boldsymbol\delta}_0. \tag{17.6}\]

The process is repeated, linearizing about \(\boldsymbol\theta_1\), until the relative change in the parameters or in \(S(\boldsymbol\theta)\) is negligible (for example less than \(10^{-6}\)).

Other algorithms

  • Steepest descent moves in the direction of \(-\nabla S\); it is reliable far from the minimum but slow near it.
  • Newton–Raphson uses the full Hessian of \(S\); it converges fast near the minimum but can diverge.
  • Marquardt’s (Levenberg–Marquardt) compromise uses \((\mathbf F'\mathbf F+\lambda\mathbf I)^{-1}\mathbf F'\mathbf r\), behaving like steepest descent when \(\lambda\) is large and like Gauss–Newton when \(\lambda\) is small. It is the most widely used method.

Starting values

Convergence depends heavily on good starting values. They can be obtained from the physical meaning of the parameters (an asymptote from the largest observed values, a midpoint from the graph), from a linearizing transformation, or from a grid search. R’s self-starting models (SSlogis, SSgompertz, SSasymp, SSmicmen) compute them automatically.

17.3.2 Inference in nonlinear regression

At convergence, with \(\hat{\mathbf F}\) evaluated at \(\hat{\boldsymbol\theta}\),

\[s^2=\frac{S(\hat{\boldsymbol\theta})}{n-p},\qquad \widehat V(\hat{\boldsymbol\theta})\approx s^2(\hat{\mathbf F}'\hat{\mathbf F})^{-1}. \tag{17.7}\]

Approximate \(t\) tests and confidence intervals follow, \(\hat\theta_j\pm t_{\alpha/2,n-p}\,SE(\hat\theta_j)\). These are asymptotic results whose accuracy depends on how nearly linear the model is near \(\hat{\boldsymbol\theta}\) (its curvature); profile-likelihood intervals (confint() on an nls object) are more reliable in small samples. \(R^2\) is not well defined for nonlinear models; compare models by \(S(\hat{\boldsymbol\theta})\), \(s\), AIC and residual plots.

17.4 Growth and response models in agriculture

Table 17.2: Common nonlinear models for growth and response
Model Equation Parameters
Monomolecular / Mitscherlich \(y=A\left(1-e^{-c(x+b)}\right)\) \(A\) asymptote, \(c\) rate
Logistic \(y=\dfrac{A}{1+e^{-(x-m)/s}}\) \(A\) asymptote, \(m\) inflection point, \(s\) scale
Gompertz \(y=A\exp\left(-b\,e^{-cx}\right)\) \(A\) asymptote, inflection at \(y=A/e\)
Richards \(y=A\left(1+\nu e^{-k(x-m)}\right)^{-1/\nu}\) flexible inflection
Michaelis–Menten \(y=\dfrac{V_{\max}x}{K+x}\) \(V_{\max}\) maximum rate, \(K\) half-saturation

The logistic curve is symmetric about its inflection point \(x=m\), where \(y=A/2\) and the absolute growth rate is maximum (\(A/4s\)). The Gompertz curve is asymmetric, with inflection at \(y=A/e\approx0.37A\), and often fits crop and animal growth better. The Mitscherlich model expresses the law of diminishing returns in fertilizer response (Mitscherlich 1909).

Example 17.2 Dry matter accumulation (g/plant) of maize was recorded every 10 days from 10 to 110 days after sowing (csv/growth.csv). Fit the logistic growth model by nonlinear least squares and compare it with the Gompertz model.

Solution

Starting values can be read from the data: the asymptote is a little above the largest value (\(A_0=260\)), the inflection point is where dry matter is about half of the asymptote (\(m_0=55\) days), and \(s_0=10\). The Gauss–Newton iterations of Equation 17.6 are shown in Table 17.3.

Table 17.3: Gauss–Newton iterations for the logistic model
Iteration \(A\) \(m\) \(s\) \(S(\boldsymbol\theta)\)
0 260.000 55.000 10.0000 5295.876
1 247.116 59.464 11.1511 156.848
2 249.580 60.319 11.1219 112.733
3 249.743 60.333 11.1498 112.664
4 249.747 60.334 11.1498 112.664

The procedure converges in a few iterations to

\[\widehat{\text{DM}}=\frac{249.75}{1+\exp\left[-(\text{DAS}-60.33)/11.150\right]},\]

with standard errors 2.92, 0.548 and 0.443 respectively, and residual standard error \(s=3.753\) on 8 df. The crop reaches half of its final dry matter of about 250 g/plant at 60.3 days after sowing, when the growth rate is maximum, \(A/4s=5.60\) g/plant/day.

The Gompertz model gives \(s=3.607\) (AIC 63.9 against 64.8 for the logistic), so the Gompertz model fits these data better.

Figure 17.1: Logistic (solid) and Gompertz (dashed) curves fitted to maize dry matter

17.5 R practical

# Intrinsically linear: power and exponential curves
lf <- read.csv("csv/leaf.csv")
pw <- lm(log(area) ~ log(length), data = lf)
c(a = exp(coef(pw)[[1]]), b = coef(pw)[[2]])
#>         a         b 
#> 0.5933849 1.9259666
aph <- read.csv("csv/aphids.csv")
ex <- lm(log(aphid) ~ day, data = aph)
c(a = exp(coef(ex)[[1]]), growth_rate_percent = 100 * (exp(coef(ex)[[2]]) - 1))
#>                   a growth_rate_percent 
#>            3.355361           20.032555
# Same power model with additive error, by nonlinear least squares
nls(area ~ a * length^b, data = lf, start = list(a = exp(coef(pw)[[1]]), b = coef(pw)[[2]]))
#> Nonlinear regression model
#>   model: area ~ a * length^b
#>    data: lf
#>      a      b 
#> 0.5579 1.9443 
#>  residual sum-of-squares: 1337
#> 
#> Number of iterations to convergence: 3 
#> Achieved convergence tolerance: 4.772e-08
gr <- read.csv("csv/growth.csv")

# Logistic with user-supplied starting values (Gauss-Newton is the default algorithm)
fl <- nls(drymatter ~ A / (1 + exp(-(das - m) / s)), data = gr,
          start = list(A = 260, m = 55, s = 10), trace = TRUE)
#> 5295.876    (5.55e+00): par = (260 55 10)
#> 156.8479    (6.26e-01): par = (247.1164 59.46421 11.15111)
#> 112.7329    (2.47e-02): par = (249.5796 60.31937 11.12185)
#> 112.6645    (1.21e-03): par = (249.7427 60.33256 11.1498)
#> 112.6643    (6.45e-05): par = (249.7474 60.33422 11.14979)
#> 112.6643    (3.47e-06): par = (249.7477 60.33427 11.14987)
summary(fl)
#> 
#> Formula: drymatter ~ A/(1 + exp(-(das - m)/s))
#> 
#> Parameters:
#>   Estimate Std. Error t value Pr(>|t|)    
#> A 249.7477     2.9229   85.44 3.93e-13 ***
#> m  60.3343     0.5478  110.14 5.16e-14 ***
#> s  11.1499     0.4428   25.18 6.62e-09 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Residual standard error: 3.753 on 8 degrees of freedom
#> 
#> Number of iterations to convergence: 5 
#> Achieved convergence tolerance: 3.473e-06
confint(fl)                          # profile-likelihood intervals
#> 128.0049    (2.84e-01): par = (60.33427 11.14987)
#> 118.3666    (3.64e-03): par = (60.08489 10.96921)
#> 118.3651    (1.46e-04): par = (60.08123 10.97085)
#> 118.3651    (7.18e-06): par = (60.08127 10.9707)
#> 136.1003    (4.50e-03): par = (59.82629 10.79015)
#> 136.0976    (1.57e-04): par = (59.82942 10.79406)
#> 136.0976    (8.41e-06): par = (59.82951 10.79391)
#> 165.8423    (4.03e-03): par = (59.58258 10.6205)
#> 165.8397    (1.85e-04): par = (59.5856 10.62442)
#> 165.8397    (1.14e-05): par = (59.58566 10.6242)
#> 165.8397    (7.03e-07): par = (59.58565 10.62422)
#> 207.5566    (3.50e-03): par = (59.34629 10.45765)
#> 207.5542    (2.06e-04): par = (59.34915 10.46149)
#> 207.5542    (1.47e-05): par = (59.34918 10.46122)
#> 207.5542    (1.06e-06): par = (59.34918 10.46124)
#> 261.2125    (3.03e-03): par = (59.11683 10.3011)
#> 261.2102    (2.20e-04): par = (59.11954 10.30488)
#> 261.2102    (1.83e-05): par = (59.11954 10.30455)
#> 261.2102    (1.51e-06): par = (59.11954 10.30458)
#> 128.0049    (2.84e-01): par = (60.33427 11.14987)
#> 118.1554    (1.03e-02): par = (60.57994 11.32783)
#> 118.1425    (3.27e-04): par = (60.59031 11.33241)
#> 118.1425    (1.07e-05): par = (60.59053 11.33267)
#> 118.1425    (3.80e-07): par = (60.59055 11.33267)
#> 134.7305    (4.34e-03): par = (60.85401 11.5206)
#> 134.7279    (1.81e-04): par = (60.85726 11.52421)
#> 134.7279    (7.52e-06): par = (60.85745 11.5243)
#> 162.3836    (4.03e-03): par = (61.12997 11.71997)
#> 162.3809    (2.09e-04): par = (61.1334 11.72358)
#> 162.3809    (1.08e-05): par = (61.13362 11.72373)
#> 162.3809    (5.59e-07): par = (61.13363 11.72374)
#> 201.0654    (3.64e-03): par = (61.41597 11.92761)
#> 201.0625    (2.28e-04): par = (61.41955 11.93115)
#> 201.0625    (1.42e-05): par = (61.41979 11.93135)
#> 201.0625    (8.89e-07): par = (61.4198 11.93137)
#> 250.7328    (3.28e-03): par = (61.71269 12.14387)
#> 250.7299    (2.40e-04): par = (61.71644 12.14732)
#> 250.7299    (1.75e-05): par = (61.71671 12.14758)
#> 250.7299    (1.31e-06): par = (61.71673 12.1476)
#> 311.3397    (2.95e-03): par = (62.021 12.36919)
#> 311.3368    (2.46e-04): par = (62.02491 12.37252)
#> 311.3368    (2.05e-05): par = (62.02519 12.37284)
#> 311.3368    (1.72e-06): par = (62.02522 12.37286)
#> 124.1369    (2.25e-01): par = (249.7477 11.14987)
#> 118.2523    (5.54e-03): par = (248.405 11.0134)
#> 118.2489    (2.62e-04): par = (248.4235 11.01973)
#> 118.2489    (1.25e-05): par = (248.4227 11.01943)
#> 118.2489    (5.72e-07): par = (248.4227 11.01945)
#> 135.6898    (6.80e-03): par = (247.0736 10.88665)
#> 135.6838    (3.55e-04): par = (247.1064 10.89448)
#> 135.6838    (1.98e-05): par = (247.1052 10.89405)
#> 135.6838    (1.10e-06): par = (247.1053 10.89407)
#> 164.9495    (6.04e-03): par = (245.8033 10.77016)
#> 164.9438    (3.63e-04): par = (245.8347 10.77785)
#> 164.9438    (2.32e-05): par = (245.8335 10.77736)
#> 164.9438    (1.47e-06): par = (245.8335 10.77739)
#> 205.9975    (5.21e-03): par = (244.5756 10.66198)
#> 205.9923    (3.55e-04): par = (244.6052 10.66941)
#> 205.9923    (2.55e-05): par = (244.6039 10.66888)
#> 205.9923    (1.78e-06): par = (244.604 10.66892)
#> 258.8032    (4.48e-03): par = (243.3866 10.56151)
#> 258.7984    (3.41e-04): par = (243.4146 10.56869)
#> 258.7984    (2.73e-05): par = (243.4132 10.56812)
#> 258.7984    (2.18e-06): par = (243.4133 10.56816)
#> 124.1320    (2.27e-01): par = (249.7477 11.14987)
#> 118.1115    (4.13e-03): par = (251.1146 11.29219)
#> 118.1095    (1.33e-04): par = (251.1043 11.28746)
#> 118.1095    (4.26e-06): par = (251.1047 11.28761)
#> 134.8248    (6.89e-03): par = (252.504 11.42965)
#> 134.8185    (1.58e-04): par = (252.539 11.43758)
#> 134.8185    (3.91e-06): par = (252.5385 11.43738)
#> 162.7536    (6.53e-03): par = (253.9922 11.58922)
#> 162.7468    (1.05e-04): par = (254.0294 11.59745)
#> 162.7468    (1.82e-06): par = (254.0291 11.59731)
#> 201.8571    (6.01e-03): par = (255.5424 11.75967)
#> 201.8499    (5.78e-05): par = (255.5815 11.76807)
#> 201.8499    (6.28e-07): par = (255.5813 11.76799)
#> 252.0854    (5.51e-03): par = (257.1592 11.9415)
#> 252.0778    (1.99e-05): par = (257.2002 11.95006)
#> 252.0778    (7.37e-08): par = (257.2001 11.95003)
#> 313.3838    (5.05e-03): par = (258.8483 12.13536)
#> 313.3758    (9.16e-06): par = (258.8912 12.14405)
#> 122.7189    (1.87e-01): par = (249.7477 60.33427)
#> 118.5413    (2.59e-03): par = (248.5329 60.16746)
#> 118.5405    (4.31e-05): par = (248.5267 60.16396)
#> 118.5405    (7.36e-07): par = (248.5265 60.1639)
#> 136.4690    (3.64e-03): par = (247.3142 59.99479)
#> 136.4672    (1.09e-04): par = (247.3326 60.00005)
#> 136.4672    (3.37e-06): par = (247.3331 60.00021)
#> 166.4365    (3.11e-03): par = (246.1632 59.83976)
#> 166.4348    (1.35e-04): par = (246.1801 59.84464)
#> 166.4348    (6.00e-06): par = (246.1807 59.84486)
#> 208.4285    (2.59e-03): par = (245.0508 59.69253)
#> 208.4270    (1.48e-04): par = (245.0661 59.69701)
#> 208.4270    (8.63e-06): par = (245.0668 59.69727)
#> 262.4305    (2.15e-03): par = (243.9742 59.5525)
#> 262.4292    (1.53e-04): par = (243.9881 59.5566)
#> 262.4292    (1.11e-05): par = (243.9889 59.5569)
#> 262.4292    (8.03e-07): par = (243.989 59.55692)
#> 122.4485    (1.87e-01): par = (249.7477 60.33427)
#> 118.3098    (1.66e-03): par = (250.9912 60.51246)
#> 118.3094    (1.28e-05): par = (250.9888 60.51029)
#> 118.3094    (1.08e-07): par = (250.9889 60.51031)
#> 135.0779    (3.91e-03): par = (252.2459 60.68859)
#> 135.0759    (8.04e-05): par = (252.2673 60.69463)
#> 135.0759    (1.68e-06): par = (252.2669 60.69451)
#> 162.9548    (3.77e-03): par = (253.5709 60.88246)
#> 162.9526    (1.23e-04): par = (253.5942 60.88897)
#> 162.9526    (4.06e-06): par = (253.5936 60.88876)
#> 201.9272    (3.59e-03): par = (254.9478 61.08704)
#> 201.9247    (1.59e-04): par = (254.9732 61.09408)
#> 201.9247    (7.18e-06): par = (254.9722 61.09376)
#> 251.9803    (3.41e-03): par = (256.3801 61.3031)
#> 251.9775    (1.91e-04): par = (256.4078 61.3107)
#> 251.9775    (1.08e-05): par = (256.4065 61.31027)
#> 251.9775    (6.12e-07): par = (256.4065 61.3103)
#> 313.0991    (3.23e-03): par = (257.8718 61.53151)
#> 313.0961    (2.17e-04): par = (257.9018 61.53966)
#> 313.0961    (1.48e-05): par = (257.9001 61.5391)
#> 313.0961    (1.02e-06): par = (257.9002 61.53914)
#>        2.5%     97.5%
#> A 243.11763 256.88184
#> m  59.06675  61.66266
#> s  10.16143  12.21258
# Self-starting models need no starting values
fl2 <- nls(drymatter ~ SSlogis(das, Asym, xmid, scal), data = gr)
fg  <- nls(drymatter ~ SSgompertz(das, Asym, b2, b3), data = gr)
sapply(list(logistic = fl2, gompertz = fg), AIC)
#> logistic gompertz 
#> 64.80834 63.93904
# The monomolecular model, nls(drymatter ~ SSasymp(das, Asym, R0, lrc)), fails here
# ("singular gradient"): it has no inflection point and cannot describe S-shaped growth.

plot(fitted(fl), resid(fl), xlab = "Fitted", ylab = "Residual"); abline(h = 0, lty = 2)

Historical Insights

Verhulst, Gompertz and Mitscherlich

The logistic curve was introduced by the Belgian mathematician Pierre-François Verhulst in 1838 to describe population growth limited by resources; it was rediscovered by Raymond Pearl and Lowell Reed in 1920 for the population of the United States. Benjamin Gompertz, an actuary, proposed his curve in 1825 to describe human mortality. In 1909 the German soil scientist Eilhard Alfred Mitscherlich formulated his “law of physiological relationships”, that each increment of a growth factor produces a smaller increase in yield than the previous one (Mitscherlich 1909), the basis of the monomolecular response curve still used in fertilizer research.

Quotes to Inspire

“Nature uses only the longest threads to weave her patterns, so that each small piece of her fabric reveals the organization of the entire tapestry.”
- Richard Feynman

17.6 Practical exercises

17.6.1 Practical 17.1: Compound growth rate of production

Rubber production in a district (thousand tonnes) over eight years was 52, 55, 59, 62, 67, 70, 76, 80. Fit the exponential trend \(y=ab^t\) (\(t=1,\ldots,8\)) and compute the compound growth rate.

Solution

With \(Y=\ln y\): \(\sum t=36\), \(\sum t^2=204\), \(\sum Y=33.3292\), \(\sum tY=152.5928\). Solving the normal equations Equation 17.1,

\[B=\frac{8(152.5928)-36(33.3292)}{8(204)-36^2}=0.06218,\qquad A=\bar Y-B\bar t=3.8864.\]

So \(a=e^A=48.733\), \(b=e^B=1.06415\), and the fitted trend is \(\hat y=48.73(1.0642)^t\). The compound growth rate is \((b-1)\times100=6.42\%\) per year.

Doing it in R

rubber <- data.frame(t = 1:8, y = c(52, 55, 59, 62, 67, 70, 76, 80))
fe <- lm(log(y) ~ t, data = rubber)
c(a = exp(coef(fe)[[1]]), b = exp(coef(fe)[[2]]),
  CGR_percent = 100 * (exp(coef(fe)[[2]]) - 1))
#>           a           b CGR_percent 
#>   48.732720    1.064151    6.415125
confint(fe)["t", ]                         # CI for ln b; transform for CGR limits
#>      2.5 %     97.5 % 
#> 0.05923411 0.06512096

17.6.2 Practical 17.2: Fitting the Mitscherlich response by nonlinear least squares

Maize grain yield (t/ha) at six nitrogen levels was: 0: 2.1, 40: 3.9, 80: 5.1, 120: 5.8, 160: 6.2, 200: 6.4. Fit the Mitscherlich model \(y=A\left(1-e^{-c(x+b)}\right)+\varepsilon\) and interpret the parameters.

Solution

Starting values: the asymptote is a little above the largest yield (\(A_0=6.6\)); from \(y(0)=A(1-e^{-cb})\approx2.1\) and the half-way point near 50 kg N, \(c_0=0.015\), \(b_0=25\). Nonlinear least squares (Section 17.3) converges to

\[\hat y=6.823\left(1-e^{-0.01252(x+29.11)}\right),\]

with standard errors 0.072, 0.00050 and 1.36 and residual standard error 0.0436. \(A=6.82\) t/ha is the maximum attainable yield; \(b=29.1\) kg/ha is the nitrogen equivalent already supplied by the soil; and \(c\) is the efficiency factor: each additional kg of N closes a fraction 0.0125 of the remaining gap to \(A\).

Doing it in R

maize <- data.frame(N = seq(0, 200, 40), y = c(2.1, 3.9, 5.1, 5.8, 6.2, 6.4))
fm <- nls(y ~ A * (1 - exp(-c * (N + b))), data = maize,
          start = list(A = 6.6, c = 0.015, b = 25))
summary(fm)
#> 
#> Formula: y ~ A * (1 - exp(-c * (N + b)))
#> 
#> Parameters:
#>    Estimate Std. Error t value Pr(>|t|)    
#> A 6.823e+00  7.185e-02   94.95 2.58e-06 ***
#> c 1.252e-02  5.036e-04   24.86 0.000143 ***
#> b 2.911e+01  1.356e+00   21.47 0.000221 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Residual standard error: 0.0436 on 3 degrees of freedom
#> 
#> Number of iterations to convergence: 4 
#> Achieved convergence tolerance: 4.447e-06
plot(y ~ N, data = maize, pch = 19)
nn <- seq(0, 200, 1); lines(nn, predict(fm, data.frame(N = nn)))

17.7 Chapter Summary

Fill in the blanks

Answers are given at the end of the chapter.

  1. A nonlinear model that can be linearized by transformation is called __________ linear.

  2. The power curve \(y=ax^b\) is linearized by regressing __________ on __________.

  3. In \(y=ab^x\), the compound growth rate is __________.

  4. In the power model, the exponent \(b\) is the __________ of \(y\) with respect to \(x\).

  5. Nonlinear least squares minimizes \(S(\boldsymbol\theta)=\) __________.

  6. The Gauss–Newton method is based on a first-order __________ expansion of \(f\).

  7. The Gauss–Newton correction is \(\hat{\boldsymbol\delta}=\) __________.

  8. The method that combines steepest descent and Gauss–Newton is due to __________.

  9. The logistic curve has its inflection point at \(y=\) __________.

  10. The Gompertz curve has its inflection point at \(y=\) __________.

Short-answer questions

  1. Distinguish between intrinsically linear and intrinsically nonlinear models with examples.

  2. Explain how to fit exponential and power curves.

  3. What error structure is assumed when a model is linearized by logarithms?

  4. Write the normal equations of nonlinear least squares and explain why they are difficult to solve.

  5. Derive the Gauss–Newton iteration.

  6. How are starting values obtained?

  7. How are standard errors obtained in nonlinear regression?

  8. Describe the logistic, Gompertz and Mitscherlich models and interpret their parameters.

  9. How is the compound growth rate of production computed?

  10. Why is \(R^2\) not appropriate for nonlinear models?

Numerical and conceptual questions

Answers are given at the end of the chapter.

  1. A fitted exponential trend of rice production is \(\ln y=2.30+0.025t\). Find the compound growth rate.

  2. A power curve \(\ln y=0.5+0.8\ln x\) is fitted. Find \(a\) and interpret \(b\).

  3. Linearize \(y=x/(a+bx)\).

  4. For the logistic curve with \(A=240\), \(m=60\), \(s=12\), find \(y\) at \(x=60\) and \(x=84\).

  5. For Question 4, find the maximum growth rate.

  6. For the Michaelis–Menten model, what is \(y\) when \(x=K\)?

  7. Given \(n=12\), \(p=3\) and \(S(\hat{\boldsymbol\theta})=45\), find \(s^2\).

  8. Why might the Gauss–Newton method fail to converge?

Important formulae

Exponential and power curves:

\[ \ln y=\ln a+x\ln b,\qquad\ln y=\ln a+b\ln x \]

Nonlinear least squares:

\[ S(\boldsymbol\theta)=\sum[y_i-f(\mathbf x_i,\boldsymbol\theta)]^2 \]

Gauss–Newton step:

\[ \boldsymbol\theta_{k+1}=\boldsymbol\theta_k+(\mathbf F_k'\mathbf F_k)^{-1}\mathbf F_k'[\mathbf y-\mathbf f(\boldsymbol\theta_k)] \]

Approximate covariance matrix:

\[ \widehat V(\hat{\boldsymbol\theta})=s^2(\hat{\mathbf F}'\hat{\mathbf F})^{-1},\qquad s^2=\frac{S(\hat{\boldsymbol\theta})}{n-p} \]

Logistic and Gompertz models:

\[ y=\frac{A}{1+e^{-(x-m)/s}},\qquad y=A\exp(-be^{-cx}) \]

Quick revision

  • Intrinsically linear → transform (log, reciprocal) and use OLS; assumes multiplicative error.
  • Exponential → growth rate \((b-1)\times100\%\); power → elasticity \(b\).
  • Intrinsically nonlinear → nonlinear least squares, iterative.
  • Gauss–Newton → linearize, regress residuals on derivatives, update; Marquardt for stability.
  • Good starting values are essential; self-starting models help.
  • Inference is approximate: \(s^2(\hat{\mathbf F}'\hat{\mathbf F})^{-1}\), profile intervals.
  • Growth curves: logistic (symmetric), Gompertz (asymmetric), Mitscherlich (diminishing returns).

Answers to fill in the blanks

1. Intrinsically 2. \(\ln y\); \(\ln x\) 3. \((b-1)\times100\%\) 4. Elasticity 5. \(\sum[y_i-f(\mathbf x_i,\boldsymbol\theta)]^2\) 6. Taylor series 7. \((\mathbf F'\mathbf F)^{-1}\mathbf F'\mathbf r\) 8. Marquardt 9. \(A/2\) 10. \(A/e\)

Solutions to numerical and conceptual questions

  1. \(b=e^{0.025}=1.0253\); compound growth rate \(=2.53\%\) per year.

  2. \(a=e^{0.5}=1.649\); \(b=0.8\): a 1% increase in \(x\) gives a 0.8% increase in \(y\).

  3. \(1/y=b+a(1/x)\): regress \(1/y\) on \(1/x\).

  4. At \(x=60\): \(y=240/2=120\). At \(x=84\): \(y=240/(1+e^{-2})=211.2\).

  5. \(A/(4s)=240/48=5\) units per unit of \(x\).

  6. \(y=V_{\max}/2\).

  7. \(s^2=45/9=5\) (Equation 17.7).

  8. Poor starting values, strong correlation among parameter estimates (an ill-conditioned \(\mathbf F'\mathbf F\)), or a model that is not supported by the data (for example, data that do not reach the asymptote).