The data set
simulates the hourly counts from a not necessarily homogeneous Poisson process.
The variables are
count, the first counting
sequentially throughout a 14-day period
(running from 1 to 14 × 24 = 336) and the second giving the count
for that hour.
The following R statement plots these data
The idea of the regression is to get a handle on the mean as a function of time if it is not constant. Many time series have a daily cycle. If we pool the counts for the same hour of the day over the 14 days of the series, we see a clear pattern in the histogram.
Fitting the GLM
Since there seems to be a daily cycle with two peaks we fit a Fourier series with frequencies one per day and two per day.
Testing which Fourier Series Fits
Although we think the model fit in the preceding section is best, we do hypothesis tests to make sure.
The little model (frequency one per day) does not fit (P ≈ 0). The big model (frequency three per day) fits no better (P = 0.17) than the middle model (frequency two per day).