Monolix
Auto Light Dark
Auto Light Dark

Count data models

Related resources on modeling count data in Monolix:

On the current page, we show examples of count data models from the Monolix demos.

Demos: count1a_project, count1b_project, count2_project

Count data with constant distribution over time

  • count1a_project (data = ‘count1_data.txt’, model = ‘count_library/poisson_mlxt.txt’)

A Poisson model is used for fitting the data:

[LONGITUDINAL]
input = lambda

DEFINITION:
Y = {type = count,  log(P(Y=k)) = -lambda + k*log(lambda) - factln(k) }

OUTPUT:
output = Y

Residuals for noncontinuous data reduce to NPDEs. We can compare the empirical distribution of the NPDEs with the distribution of a standardized normal distribution either with the pdf (top) or the cdf (bottom):


Monolix NPDE distribution plots for the Poisson count model. Top, a histogram of NPDE density from about minus 3 to 3 closely follows the dashed standard normal curve peaking near 0.4. Bottom, the empirical cumulative distribution of NPDE nearly overlaps the predicted dashed curve.


VPCs for count data compare the observed and predicted frequencies of the categorized data over time:


Monolix visual predictive check for count data with the Poisson model, three panels versus time from 1 to 30. Empirical probabilities of Y equals 0, of 1 to 5, and of 6 to 80 counts are plotted as lines over blue prediction intervals. Probabilities are about 0.6, 0.35 and 0.02 and mostly stay within the intervals.


  • count1b_project (data = ‘count1_data.txt’, model = ‘count_library/poissonMixture_mlxt.txt’)

A mixture of two Poisson distributions is used to fit the same data. For that, we define the probability of k occurrences as the weigthed sum of two Poisson distributions with two expected numbers of occurrences lambda1 and lambda2. The structural model file writes

[LONGITUDINAL]
input = {lambda1, alpha, mp}

EQUATION:
lambda2 = (1+alpha)*lambda1

DEFINITION:
Y = { type = count,
       P(Y=k) = mp*exp(-lambda1 + k*log(lambda1) - factln(k)) + (1-mp)*exp(-lambda2 + k*log(lambda2) - factln(k)) 
}

OUTPUT:
output = Y

Thus, the parameter alpha has to be strictly positive to ensure different expected number of occurrences in the two poisson distributions and mp has to be in [0, 1] to ensure the probability is correctly defined. Thus those parameters should be defined with lognormal and probitnormal distribution respectively as shown on the following figure.


Monolix Individual model panel for the Poisson mixture model. Parameter lambda1 is lognormal, alpha, highlighted in green, is lognormal to keep it strictly positive, and mp, highlighted in blue, is probitnormal to keep it between 0 and 1. All three have random effects and no correlations.


We see on the VPC below that the data set is well modeled using this mixture of Poisson distributions.


Monolix visual predictive check for the Poisson mixture model, three panels versus time from 1 to 30. Empirical probabilities of Y equals 0, about 0.55 to 0.7, of 1 to 5 counts, about 0.3 to 0.45, and of 6 to 80 counts, about 0 to 0.04, stay within the blue prediction intervals, indicating a good fit.


Count data with time varying distribution

  • count2_project (data = ‘count2_data.txt’, model = ‘count_library/poissonTimeVarying_mlxt.txt’)

The distribution of the data changes with time in this example:

We then use a Poisson distribution with a time varying intensity:

[LONGITUDINAL]
input =  {a,b}
                           
EQUATION:
lambda= a*exp(-b*t)
                           
DEFINITION:
y = {type=count, P(y=k)=exp(-lambda)*(lambda^k)/factorial(k)}

OUTPUT:
output = y

This model seems to fit the data very well:


Monolix visual predictive check for count data with a time varying Poisson distribution, three panels versus time from 0 to 100. The probability of 0 to 6 counts rises from 0 to 1, the probability of 7 to 19 counts peaks near 0.9 at time 30, and the probability of 20 to 62 counts falls from 1 to 0. Empirical lines follow the narrow prediction intervals.


Last updated: