Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The default regression argument of zepid.base.interaction_contrast_ratio differs from the description in the documentation. #174

Open
singledoggy opened this issue Jan 29, 2024 · 4 comments

Comments

@singledoggy
Copy link

if regression == 'logit':
It's strange that the default argument will cause warning,

    if regression == 'logit':
        f = sm.families.family.Binomial()
        warnings.warn('Using the Odds Ratio to calculate the ICR is only valid when the OR approximates the RR',
                      UserWarning)
    elif regression == 'log':
        f = sm.families.family.Binomial(sm.families.links.log())
    else:
        raise ValueError("Either 'logit' or 'log' must be specified for the regression parameter")

And the docs here
regression (string, optional) – Type of regression model to fit. Default is ‘log’ which fits the log-binomial model. Options include: * ‘log’ Log-binomial model. Estimates the Risk Ratio * ‘logit’ Logistic model. Estimates Odds Ratio. Only valid when odds ratio approximates the risk ratio

@pzivich
Copy link
Owner

pzivich commented Jan 29, 2024

The docs are misaligned as you mention. I believe the default was set to logit since the logit-bin model tends to converge better. However it does have the additional assumption of the OR approximating the RR.

The default is probably better as log since that is the original scale for the ICR.

@singledoggy
Copy link
Author

Thank you for your prompt response. I am not well-versed in the field of epidemiology, as I am currently attempting to apply this concept to a different area. As a result, I am unfamiliar with the distinctions between these two models. Your explanation has greatly clarified the matter for me.

@pzivich
Copy link
Owner

pzivich commented Jan 30, 2024

No problem! But I am going to re-open this issue since I do need to fix the misalignment in the documentation and the actual defaults.

To go into a little more detail in case it is helpful for you (or others who come across this thread), the ICR is a measure to assess effect measure modification for the risk ratio. In epidemiology, the risk ratio is the probability of the outcome among one group divided by the probability of the outcome among the other group. In this case, the risk ratios are estimated for each exposure-modifier combination. One way to estimate these risk ratios is to use a log-binomial model. This is the method used in the background. Essentially, I use a generalized linear model to estimate the risk ratios that make up the ICR and then compute the ICR for the user.

The disadvantage of the log-binomial model is that it can sometimes not converge well. statsmodels throws a DomainWarning when you try to fit this model. This is because the risk ratio is bounded on one side, which the generalized linear model doesn't incorporate. So, the log-binomial model can fail to converge in some cases.

This is different from the logit-binomial model (or logistic regression). Logistic models don't have the same bounding issue and are much easier to converge. The issue that occurs with the use of logistic regression is that it estimates the odds ratio. Since the ICR is defined for the risk ratio, there is a problem that occurs when trying to estimate the ICR using logistic regression. However, the odds ratio approximates the risk ratio for 'rare' events (rare is usually something like <10%). So, I included using the logistic model as an option but have the warning to remind the user of the assumption being made.

Hope this all helps!

@pzivich pzivich reopened this Jan 30, 2024
@singledoggy
Copy link
Author

Thank you very much for providing the additional information. It is very helpful to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants