Linear Regression
Let's start with an example which shows the growth of caterpillars fed on experimental diets differing in their tannin content:
reg.data<-read.table("c:\\temp\\regression.txt",header=T) attach(reg.data) names(reg.data) [1] "growth" "tannin" plot(tannin,growth,pch=16)

The higher the percentage of tannin in the diet, the more slowly the caterpillars grew. You can get a crude estimate of the parameter values by eye. Tannin content increased by 8 units, in response to which growth declined from about 12 units to about 2 units, a change of −10 units of growth. The slope, b, is the change in y divided by the change in x, so
![]()
The intercept, a, is the value of y when x = 0, and we see by inspection of the scatterplot that growth was close to 12 units when tannin was zero. Thus, our rough parameter estimates allow us to write the regression equation as
![]()
Of course, different people would get different parameter estimates by eye. What we want is an objective method of computing parameter estimates from the data that are in some sense the ‘best’ estimates of the parameters for these data and this particular model. The convention in modern statistics is to use the maximum likelihood ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access