Interactive demo · Applied Statistical Learning in R and Python · Chapter 4

Least squares or Poisson regression for the Bikeshare counts

The response is the number of bike-share users in each of 8,645 hours. Least squares models the mean count as a linear function of month, hour, working day, temperature and weather, with the same variance everywhere; Poisson regression models the log of the mean as linear, so effects multiply, fitted means are always positive, and the variance equals the mean. Choose the predictors, compare the month and hour effects of the two fits, and look at what the data say about the variance.

Predictors

Effects shown for

Try these

Month and hour use the sum-to-zero coding (the last level's effect is minus the sum of the others, so each set of effects averages zero); weather uses clear skies as the baseline. The column factor is eβ for the Poisson fit: the multiplicative change in the mean count. Least squares is solved from the normal equations; Poisson regression by Newton–Raphson on the log-likelihood (4.38). Dispersion is the Pearson statistic ∑(y − m)2/m over the fitted means m, divided by its degrees of freedom; it is 1 if the Poisson variance is right.

In the lecture notes