Quiz: beyond linear models

Short conceptual questions on linear vs nonlinear models, nonlinear fitting and neural networks. Try each on paper first, then open the answer. A model is linear when it is linear in its parameters: the prediction is \(X\boldsymbol\beta\) for columns of \(X\) that can be computed from the data. A neural network alternates matrix × vector with a nonlinearity such as \(\text{ReLU}(s) = \max(0, s)\).


Q1. A colleague says: “The relation between temperature and growth rate is curved, so I cannot use lm().” Is that right?

What does “linear” refer to in a linear model?

No. A linear model has to be linear in the parameters, not in temperature. lm(growth ~ temp + I(temp^2)) fits a parabola: \(\text{temp}^2\) is just one more column of \(X\), and least squares still gives one exact answer.


Q2. Which of these are linear in the parameters \(a, b, c\)? (i) \(y = a + b\sqrt{x}\); (ii) \(y = a + b\,e^{-x/c}\); (iii) \(y = a\cos(2\pi t/24) + b\sin(2\pi t/24) + c\).

Is every parameter only multiplying something you can compute from the data?

  1. Linear: columns \(1, \sqrt{x}\). (ii) Not linear: \(c\) sits in the exponent (with \(c\) known it would be linear in \(a\) and \(b\)). (iii) Linear: a Fourier basis with a known 24 h period plus an intercept.

Q3. Why does nls() need starting values, while lm() does not?

Is there a one-step formula for the best parameters of a Hill curve?

For a linear model, least squares has an exact solution that can be computed in one step. For a nonlinear model there is no such formula: nls() searches, starting from a guess and taking steps that lower the sum of squared errors until it stops improving. It needs somewhere to start.


Q4. In a dose–response curve, viability is 95% at the lowest doses and 10% at the highest, and about 50% at 2 µM. Give sensible starting values for top, bottom, ec50 and h.

Read the plateaus and the half-way dose off the plot.

top = 95, bottom = 10, ec50 = 2 (the dose half-way between the plateaus), and h = 1 as a neutral guess for the slope.


Q5. nls() converged without warnings, but the fitted curve misses most of the points. What may have happened, and what do you do?

The search only walks downhill from where it starts.

It probably stopped in a local minimum: a dip in the error that is not the lowest one. Plot the fit over the data, refit from several different starting values (or scan the difficult parameter on a grid), and keep the fit with the smallest sum of squared errors.


Q6. A cubic polynomial in log dose fits a dose–response data set about as well as the Hill curve. Give two reasons to prefer the Hill curve.

What do the parameters mean, and what happens outside the measured doses?

  1. The Hill parameters mean something: EC50, the plateaus, the slope. None of the cubic’s coefficients is the EC50. (2) Outside the data the cubic can go anywhere (above 100% viability, below 0), while the Hill curve stays on its plateaus.

Q7. A network has input \((x, y) = (2, 1)\), \(A = \begin{pmatrix} 1 & -3 \\ 1 & 1 \end{pmatrix}\), \(\mathbf{b} = \mathbf{0}\), \(C = (2,\ 1)\), \(d = 0\). Compute the output with ReLU and without ReLU.

Matrix × vector, then replace negatives by 0, then \(C\) × hidden.

\(A\mathbf{x} = (2 - 3,\ 2 + 1) = (-1,\ 3)\). With ReLU: hidden \(= (0, 3)\), output \(= 2\cdot 0 + 1\cdot 3 = 3\). Without ReLU: \(2\cdot(-1) + 1\cdot 3 = 1\).


Q8. Someone builds a 10-layer network but forgets the nonlinearity between the layers. Why is this no better than a linear model?

What is “apply \(A\), then \(C\)” as one matrix?

Applying matrices one after another is the same as applying their product: \(C(A\mathbf{x}) = (CA)\mathbf{x}\). Ten layers of matrices (with shifts) collapse to one matrix and one shift, a straight-line map. The nonlinearity between the layers is what allows curves.


Q9. Cycling cells form a ring in two marker genes. Why can PC1 not give each cell a single number that tracks its cell-cycle phase, and what number could?

Project a ring onto a straight line. Which cells land on the same spot?

PC1 projects the ring onto a straight axis, which folds it: two cells in different phases, mirror images across the axis, get the same score. The angle round the ring (from polar coordinates, atan2) keeps every phase apart. It is a nonlinear function of the genes, so no matrix (and so no principal component) can compute it. Methods such as UMAP and variational autoencoders learn curved coordinates like this from the data.