Runs in the past week

Section of Introduction to generalised linear models, part of Generalised linear models

Runs in the past week

Type Section
Taught in Introduction to generalised linear models
Part Generalised linear models

A hundred people at the gym were asked how many times they had run in the past week, and that count was plotted against age. The responses are integers, 0,1,2,\ldots, with plenty of ties. Jitter in a scatterplot is only there so that those ties do not sit on top of each other. A person cannot have run 1.37 times in a given week.

The mean is the first problem. A straight line through this cloud may not look absurd between the ages we actually saw. Extend it. By age 50 or 60 the line has crossed below zero, and a mean number of runs cannot be negative. Any function that is allowed to go to \pm\infty will do that for some covariate, whether or not that covariate appeared in the sample. A model has to stay valid for data we could have seen.

The repair is to put the straight line on the log of the mean, not on the mean: \mu=\exp({\boldsymbol{X}}^\top\boldsymbol{\beta}) \qquad\text{equivalently}\qquad {\boldsymbol{X}}^\top\boldsymbol{\beta}=\log\mu, where \mu=\mathrm{E}(Y\mid {\boldsymbol{X}}). The exponential of anything real is positive, so the mean cannot cross zero. The transformation that takes the mean across to the linear predictor is the link. The map the other way, from {\boldsymbol{X}}^\top\boldsymbol{\beta} back to \mu, is the inverse link. We will often interpret on the mean scale. The literature names the link in the other direction, and we will follow the literature so that we can talk to it.

Do not take logarithms of the counts. Zero runs is a common and perfectly sensible observation, and \log 0 is not a number. Logging the observations is not what a generalised linear model does. The data stay on the original scale. Only the mean curve moves.

The distribution is the next problem. Integer counts with ties are not normal draws. A reasonable starting model is Y_i\mid {\boldsymbol{X}}_i\stackrel{\mathrm{ind}}{\sim} \mathrm{Poisson}\!\left(\mu_i=\exp({\boldsymbol{X}}_i^\top\boldsymbol{\beta})\right). There are other distributions for counts. The Poisson is the default, not the only choice.

The variance comes with that choice, and it is not constant. For a Poisson random variable the variance equals the mean, \mathrm{Var}(Y_i\mid {\boldsymbol{X}}_i)=\mu_i=\exp({\boldsymbol{X}}_i^\top\boldsymbol{\beta}). That is what the scatterplot is already saying. Near a mean of zero the counts pile up on 0 and 1, because they cannot go negative, so the spread is small. Where the mean is larger, the spread is larger. A Poisson model does not have to be told this. It is the variance formula.

Used in

See also

Exponential family · Mean and variance of an exponential family · Generalised linear model · Canonical link · What a regression statement is hiding · Three examples the linear model does not fit · Clotting-time data · Cholesterol and heart disease

Glossary and index