Nonlinear Regression Models and Transformations – STAT Principles of Statistics II – Study Notes
offline

Difficulty: Intermediate | Prerequisites: Polynomial regression study notes (Part 1), logarithmic and exponential functions from precalculus.


Big Picture

Not every curved relationship in data can be handled by stacking polynomial terms. Some phenomena follow exponential growth, logarithmic decay, or periodic oscillation, and these are better described by purpose-built nonlinear functions. This set of notes covers two strategies for handling such data: fitting genuinely nonlinear models (where the parameters themselves enter the equation nonlinearly) and using transformations to convert a nonlinear problem into a linear one. Both approaches appear regularly in applied statistics, and knowing when to reach for each one is a core skill. You should be comfortable with polynomial regression (Part 1) before tackling this material.


TL;DR

When polynomials are not the right shape for your data, you can either fit a nonlinear regression model directly (using iterative algorithms like Gauss-Newton) or transform the data (often with logarithms) so that a linear model applies. Log transformations are especially common: they straighten exponential relationships, linearise power-law relationships, and stabilise non-constant variance. Choosing between these strategies depends on the data's structure and the goals of the analysis.


Key Terms

Nonlinear regression model

A model where at least one parameter enters the equation in a nonlinear way, for example Y = αe^(βx) + ε. In simple terms, you cannot rearrange the equation into the form Y = Xβ + ε, so ordinary least squares does not apply directly.

Nonlinear least squares (NLS)

The estimation method for nonlinear models. It still minimises the sum of squared residuals, but because the derivatives depend on the unknown parameters, the solution requires iterative numerical algorithms rather than a closed-form matrix formula.

Gauss-Newton algorithm

An iterative method for nonlinear least squares that approximates the objective function with a linear Taylor expansion at each step, then solves a linear least squares problem to update the parameter estimates.

Levenberg-Marquardt algorithm

A modification of Gauss-Newton that blends it with gradient descent. It is more robust when the initial parameter guesses are poor or when the problem is ill-conditioned. Think of it as Gauss-Newton with a safety net.

Initial values (starting values)

The parameter guesses you supply to an iterative algorithm before it begins optimising. Bad starting values can cause the algorithm to converge to a local minimum or fail to converge at all.

Log transformation

Applying the natural logarithm (or log base 10) to the response, the predictor, or both. This is the single most common transformation in applied statistics because it simultaneously straightens many curved relationships and stabilises variance that fans out.

Heteroscedasticity

Non-constant variance of the residuals across levels of the predictor. When a scatterplot fans out (wider spread at larger x or larger fitted values), heteroscedasticity is present. Log transformation of the response is a standard remedy.

Linearisable model

A nonlinear model that can be converted into a linear model through a transformation. The exponential model Y = αe^(βx) becomes linear in log Y: log Y = log α + βx. Not all nonlinear models are linearisable.


Core Content

Non-Polynomial Nonlinear Models

  • Some relationships in data have a specific functional form that polynomials approximate poorly, especially extrapolation-sensitive shapes like exponential growth or periodic oscillation.

  • General form: Y = f(x; θ₁, ..., θ_k) + ε, where f is a known function and the θ's are unknown parameters.

  • Common examples:

    • Exponential: Y = αe^(βx) + ε (population growth, radioactive decay, compound interest)

    • Trigonometric: Y = θ₁ cos(2πθ₂x) + ε (seasonal patterns, signal processing)

    • Logistic: Y = L / (1 + e^(-k(x - x₀))) + ε (saturation/growth curves)

Estimation via Nonlinear Least Squares

  • The objective is the same as linear regression: minimise Σ(yᵢ - f(xᵢ; θ))².

  • The difference is that the partial derivatives of f with respect to θ depend on θ itself, so there is no closed-form solution.

  • Iterative algorithms (Gauss-Newton, Levenberg-Marquardt) start from initial guesses and refine the parameter estimates step by step.

  • Convergence is not guaranteed. Poor starting values, flat regions of the objective surface, or near-collinear parameters can all cause problems.

  • In R, the function nls() handles nonlinear least squares: nls(y ~ a exp(b x), start = list(a = 1, b = 0.1))

Transformations to Achieve Linearity

  • Log transformation of the response (log Y):

    • Use when Y shows exponential growth or when variance increases with the level of Y.

    • Exponential model Y = αe^(βx) × ε becomes log Y = log α + βx + log ε, which is linear in x.

    • After fitting, predictions on the original scale require back-transformation (exponentiation), and care is needed because E[e^(log Y)] ≠ e^(E[log Y]) due to Jensen's inequality.

  • Log transformation of the predictor (log x):

    • Use when the effect of x on Y is multiplicative or when x spans several orders of magnitude.

    • Power-law model Y = αx^β × ε becomes log Y = log α + β log x + log ε, linear in log x.

    • The coefficient β then has a percentage-change interpretation: a 1% increase in x is associated with roughly a β% change in Y.

  • Log-log transformation (log Y vs. log x):

    • Combines both transformations.

    • Appropriate for power-law relationships where both variables span wide ranges.

  • Variance stabilisation:

    • Even when the primary goal is not to linearise, log-transforming Y often makes the residual variance roughly constant across x, addressing heteroscedasticity.

Choosing Between Polynomial, Nonlinear, and Transformation Approaches

  • Use polynomial regression when the curvature is moderate, the data range is limited, and you have no strong theory about the functional form.

  • Use a nonlinear model when theory or domain knowledge dictates a specific function (e.g., exponential decay in pharmacokinetics).

  • Use a transformation when the nonlinear model is linearisable and you want the simplicity of OLS, or when you need to stabilise variance.


Formulas and Notation

Exponential model: Y = αe^(βx) + ε

Linearised exponential (multiplicative error): log Y = log α + βx + log ε

Power-law model: Y = αx^β × ε

Linearised power-law: log Y = log α + β log x + log ε

Trigonometric model: Y = θ₁ cos(2πθ₂x) + ε

General nonlinear model: Y = f(x; θ₁, ..., θ_k) + ε


Application Example: European Wheat Prices (1500 – 1869)

This classic dataset illustrates the choices covered in these notes.

  • The raw price index over nearly four centuries shows a long-term upward trend with fluctuations, and the relationship is clearly nonlinear.

  • A polynomial fit to the raw data captures the broad trend and some curvature, but residual analysis may reveal remaining heteroscedasticity (variance increasing with price level).

  • Log-transforming the price index often produces a more nearly linear trend and stabilises the variance, making a simple linear or low-degree polynomial fit on log(price) more appropriate.

  • Residual plots after transformation help confirm whether the model is now adequate or whether further terms are needed.

This example shows why model diagnostics and transformations are not optional extras: the raw data and the transformed data can lead to quite different models and conclusions.


Real-World Applications

Exponential models describe bacterial growth, radioactive decay, and compound interest. Logarithmic transformations are standard in economics (log GDP, log income) because economic variables tend to have multiplicative relationships and right-skewed distributions. Trigonometric models appear in signal processing, climate science (seasonal cycles), and electrical engineering. In all these fields, the choice between polynomial approximation, direct nonlinear fitting, and transformation depends on the domain, the data range, and whether interpretability or predictive accuracy is the priority.


Common Misconceptions

  • Students often think that if a model is "nonlinear," you cannot use least squares at all. You can: nonlinear least squares still minimises squared residuals, it just requires an iterative solver rather than a matrix formula.

  • Students sometimes apply a log transformation and then interpret the fitted coefficients as though they apply to the original (untransformed) scale. They do not. A slope of 0.03 in a log-Y model means a 3% change in Y per unit increase in x, not a 0.03-unit change in Y.

  • Students frequently forget that back-transforming a log-scale prediction (exponentiating) gives the median of Y, not the mean, unless a correction factor is applied. This matters when the goal is to predict the average outcome.

  • Students occasionally believe transformations are just a "trick" to force linearity. They are also a tool for stabilising variance and meeting the constant-variance assumption of OLS, which is often more important in practice than the linearity itself.


Why It Matters / Exam Flags

⚠️ Know the difference between a model that is nonlinear in x (polynomial regression, still estimated by OLS) and a model that is nonlinear in its parameters (exponential, trigonometric, requiring NLS).

⚠️ Be able to linearise an exponential model by taking logs and identify what the intercept and slope represent on the original scale.

⚠️ Understand why nonlinear least squares needs starting values and what can go wrong (non-convergence, local minima).

⚠️ Be prepared to explain when and why a log transformation stabilises variance.

⚠️ Know how to use nls() in R for a simple nonlinear model and interpret its output.


Quick Self-Test

True or false: The exponential model Y = αe^(βx) + ε is linear in its parameters. False. The parameter β appears inside the exponent, making the model nonlinear in the parameters.

Fill in the blank: Taking the log of both sides of Y = αx^β gives log Y = ________ + ________. log α + β log x (plus the error term).

True or false: Log transformation of the response variable can help with heteroscedasticity even when the goal is not to linearise the relationship. True. The transformation compresses large values more than small ones, which can equalise the spread of residuals.

Fill in the blank: The Levenberg-Marquardt algorithm is a blend of the ________ algorithm and ________. Gauss-Newton; gradient descent.


Practice Q&A

Q: Why might you choose a nonlinear regression model over a high-degree polynomial, even though polynomials can approximate any smooth function?

A: Polynomials can oscillate wildly outside the observed data range (poor extrapolation) and require many parameters for complex shapes. A purpose-built nonlinear model (e.g., exponential, logistic) uses fewer parameters, extrapolates more sensibly, and reflects the known structure of the phenomenon.

Q: You fit a linear model to log(Y) vs. x and obtain a slope of 0.05. Interpret this on the original scale.

A: Each one-unit increase in x is associated with approximately a 5% increase in Y. More precisely, Y is multiplied by e^0.05 ≈ 1.051 for each unit increase in x.

Q: What is the role of starting values in nonlinear least squares?

A: Iterative algorithms need an initial guess for each parameter to begin the optimisation. If the starting values are far from the true values, the algorithm may converge slowly, converge to a local (non-global) minimum, or fail to converge at all.

Q: In the European wheat price example, why does log-transforming the price index help?

A: The raw price data show increasing variance over time (heteroscedasticity) and a nonlinear upward trend. The log transformation stabilises the variance and often reveals a more nearly linear trend, making a simpler model appropriate.

Q: Name two iterative algorithms used for nonlinear least squares estimation.

A: Gauss-Newton and Levenberg-Marquardt.


Connections to Other Topics

Transformations connect to the assumptions of linear regression (constant variance, normality of residuals) covered earlier in the course. Nonlinear regression models reappear in advanced topics like generalised linear models (GLMs), where the link function plays a role similar to a transformation. The model-selection thinking from Part 1 (AIC, BIC) applies here as well when comparing, say, a polynomial fit against a log-linear fit. In time-series analysis, trigonometric nonlinear models connect to Fourier decomposition and seasonal modelling.


Related Terms / Search Tags

nonlinear regression, nonlinear least squares, NLS, Gauss-Newton, Levenberg-Marquardt, exponential model, log transformation, log-linear model, power-law, heteroscedasticity, variance stabilisation, linearisation, linearisable model, log Y, log x, back-transformation, Jensen's inequality, nls() in R, trigonometric model, European wheat prices, model diagnostics, Principles of Statistics II, Texas A&M