-
Notifications
You must be signed in to change notification settings - Fork 55
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
Non-collapsibility: additive vs multiplicative models #234
Comments
Note: additive model is collapsible but wrong, e.g. adding the other two will give the same (wrong?) answer. It's because it's the wrong data gen mechanism |
log odds calc is wrong for the first one because it doesn't include the baseline probability |
just to follow up on your comment, I think this should be: log(((coefs[1] + coefs[2]) / (1 - (coefs[1] + coefs[2]))) / (coefs[1] / (1 - coefs[1]))) but also this is kind of a weird thing to do here because it will be different for every difference in x1 I think (like here we are saying the difference between x1 = 0 and x1 = 1, but because the odds ratios are not linear if instead you looked at the difference between x1 = 1 and x1 = 2 it would be a different value |
I also don't think you want random error here: plogis(beta0 + beta1 * x1 + beta2 * x2 + beta3 * x3 + rnorm(n, sd = .1)) because the randomness is already baked in by pulling from plogis, and then also by running through rbinom. I think maybe would make more sense to just have the randomness come from the draw from the binomial distribution, so something like this: prob <- with(
multiplicative_data,
1 / (1 + exp(-(beta0 + beta1 * x1 + beta2 * x2 + beta3 * x3))
) |
update collapsibility comment (related to #234)
Ah maybe I’m wrong! Is plogis deterministic? This seems to say yes! Edit: oh yeah of course it is 🫣 my poor little brain hahaha. I still think we don’t need rnorm in there since we already do rbinom but plogis is good 😂 |
I think I have a working simulation that shows the contrast in non-collapsibility effects in models that were generated with additive and multiplicative models.
@LucyMcGowan, what do you think?
One thing I find weird but may be doing incorrectly: the LPM works for the additive model but not for the multiplicative model. I would have guessed using the LPM would workish for the multiplicative model because even though additive, it's collapsible. Could it be due to something in the generating process? Is my expectation wrong about what log odds ratio it should produce?
Created on 2024-03-12 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: