How to use proportion_confint() for an age standardizied incidence rate?

16 views
Skip to first unread message

c.b...@posteo.jp

unread,
May 16, 2024, 10:48:44 AMMay 16
to pystat...@googlegroups.com
Hello,

I know how to calculate the confidence interval for an incidence rate.
But I am stuck with doing this for an incidence rate that was
standardized by age to a "standard population".

Here is a piece of Python code:

#!/usr/bin/env python3
import statsmodels.stats.proportion

x = 113235 # observations
n = 737237 # reference population
fx = 1000 # factor to multiply
alpha = 0.05 # confidence niveau

# incidence rate
ir = x / n * fx

# Clopper-Pearson-CI via "statsmodels"
ci = statsmodels.stats.proportion.proportion_confint(
count=x, nobs=n, alpha=alpha, method='normal')
ci = [val * fx for val in ci]

Not sure which values to use for "count" and "nobs" when it comes to
standardization .

Thanks in advance for any hints
Christian

josef...@gmail.com

unread,
May 16, 2024, 11:17:15 AMMay 16
to pystat...@googlegroups.com
The proportion functions like confint have the uncertainty from the sampling distribution.
So, count and nobs are from the sample that were used to estimate the population proportion.
We can use the sample proportion and sample confint to predict the counts for a different population size (nobs).

However, the underlying binomial distribution assumes that we have independent trials with the same proportion in each trial.
If the age adjustment is a weighted average of subgroups with different rates or proportions, then the average
proportion is not Binomial distributed anymore. (e.g. it could be beta-binomial which has excess dispersion relative to Binomial).
The same applies if the underlying distribution for the rates is assumed to be Poisson.

The normal/gaussian approximation might be good for large samples as long as the proportion is not too close to 0 or 1.

However, I'm not familiar with this application and literature, so I don't know how these cases are usually handled.

Josef


--
You received this message because you are subscribed to the Google Groups "pystatsmodels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pystatsmodel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pystatsmodels/9525e84f36f2bd0278cee97571537372%40posteo.de.

josef...@gmail.com

unread,
May 16, 2024, 1:31:29 PMMay 16
to pystat...@googlegroups.com
brief literature search


It lists methods for a weighted predicted average when the underlying distribution is assumed to be Poisson.
AFAICS, they don't separate estimation and prediction.

statsmodels does not have anything like this (yet).

Aside:
Our models have a get_prediction method that for some models allows prediction of population weighted averages.
However, their confidence intervals are just based on asymptotic normality and will not be as precise in smaller
samples as those based on approximations directly derived from the specific case.

Josef

josef...@gmail.com

unread,
May 17, 2024, 2:00:06 PMMay 17
to pystat...@googlegroups.com
just remembered: Mover confidence intervals

I added Mover intervals for Poisson rates, but only for two sample contrasts, AFAICS.
statsmodels.stats._inference_tools has some tools for mover_confint

for example 
statsmodels.stats.rates.confint_poisson_2indep computes two confint for one-sample case and 
then combines them for the desired contrast.


        elif method == "mover":
            method_p = method_mover
            ci1 = confint_poisson(y1, n1, method=method_p, alpha=2*alpha)
            ci2 = confint_poisson(y2, n2, method=method_p, alpha=2*alpha)

            ci = _mover_confint(rate1, rate2, ci1, ci2, contrast="ratio")

The same should work combining rates or proportion for weighted sums using one-sample confints.
But that's not yet implemented.

Josef

Reply all
Reply to author
Forward
0 new messages