
Bio300B Lecture 12
Institutt for biovitenskap, UiB
3 November 2026
Not all relationships are linear.
Non-linear least squares can be used when relationship is non-linear.
We know something about
the relationship

Mass of a dieting patient - has lower bound - asymptote.
Three options
\[y_i=\beta_0 + \beta_1x_i+\beta_2x^2 + \varepsilon_i\]
poly()
The relationship has an asymptote, and a exponential decline
\(y_i = \beta_0 + \beta_1\exp(\beta_2x_i) + \varepsilon_i\)
If \(\beta_2 < 0\)
limit \(x\to\infty\)
limit \(x\to0\)

Error in `getInitial.default()`:
! no 'getInitial' method found for "function" objects
Needs stating values - initial estimates of the coefficients
\(y_i = \beta_0 + \beta_1\exp(\beta_2x_i) + \varepsilon_i\)

Formula: Weight ~ b0 + b1 * exp(b2 * Days)
Parameters:
Estimate Std. Error t value Pr(>|t|)
b0 8.137e+01 2.269e+00 35.86 <2e-16 ***
b1 1.027e+02 2.083e+00 49.30 <2e-16 ***
b2 -4.884e-03 1.822e-04 -26.80 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.8949 on 49 degrees of freedom
Number of iterations to convergence: 7
Achieved convergence tolerance: 1.763e-07
Not calculated by the model - use bootstrap
And how to avoid them
Activities that distort results towards a researcher’s hypotheses
Make science less reproducible
Distinct from misconduct (fabrication, falsification)
But much more common
A scientist does an experiment
Error in `knitr::include_graphics()`:
! Cannot find the file(s): "figures/QRPpone.0200303.g001.png"
Preregister analyses
Registered reports
questionable research practices.
What is the relationship between the predictors and the response?
Are the data clustered/grouped?
What is the distribution of the residuals?
(also other types of model - survival, multivariate etc)
Answers usually usually known before data collection.
Linear models - ordinary least squares
generalised linear models
Binomial & Poisson distributions
Mixed effect models
Error in `knitr::include_graphics()`:
! Cannot find the file(s): "figures/fig-forest-plots-Zr-1.png"
Call:
lm(formula = bill_len ~ sex * species, data = penguins)
Residuals:
Min 1Q Median 3Q Max
-5.7904 -1.3735 -0.0638 1.2096 11.4265
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 37.2575 0.2710 137.473 < 2e-16 ***
sexmale 3.1329 0.3833 8.174 6.64e-15 ***
speciesChinstrap 9.3160 0.4808 19.377 < 2e-16 ***
speciesGentoo 8.3063 0.4073 20.393 < 2e-16 ***
sexmale:speciesChinstrap 1.3877 0.6799 2.041 0.0421 *
sexmale:speciesGentoo 0.7771 0.5721 1.358 0.1753
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.316 on 327 degrees of freedom
(11 observations deleted due to missingness)
Multiple R-squared: 0.8234, Adjusted R-squared: 0.8207
F-statistic: 305 on 5 and 327 DF, p-value: < 2.2e-16
targets package for reproducible analysis pipelines