A quick way to fit an origin line to a Poisson point cloud

Just as a quick note, sometimes there is a more quick way to estimate the parameter of a Poisson model from data than a generalised linear model (via e.g. R’s glm function). This is the case when the expected mean λ is just a straight line that starts at 0 at time 0: $$\lambda(t) = gt.$$ This can model for example the number n(t) of a steadily produced mRNA species in a cell after the enhancer becomes active for the first time: the sum of two Poisson-distributed values with means λ1 (already existing number), λ2 (production during next time slice) is also Poisson-distributed with mean $$\lambda_1+\lambda_2$$

In this case the maximum likelihood or Bayesian estimate (they are the same, assuming no particular prior knowledge) for g is simply

$$ g=\frac{\sum{n}}{\sum{t}} $$

This is because the probability of a single Poisson event with λ=gt is Continue reading

Caveat emptor with iOS / HealthKit step data

Step counts have not been recorded uniformly before and after September 2016 on the iPhone, which leads to some artefacts. This slight complication might be interesting to those who intend to analyse long periods of health data.

The change came with an iOS update. Helpfully the exported data points from the Health App contain the current iOS version after iOS 9. Perhaps you can spot the difference pre- and post iOS 10 below. The plot shows steps/second over the years from the same device. Each dot was calculated from one record.

Magnification around the update shows that there are fewer data points post iOS 10:

Continue reading