0

I am looking for a function that allows me to calculate adjusted odds (not odds ratios) for a combination of multiple independent variables and one binary dependent variable. Would appreciate the help.

in the following dataframe example : z is the dependent binary variable. x and y are the independent variables. I want to find the odds of the groups of x adjusted on y and the odds of the groups of y adjusted on x.

set.seed(555)

x = rep(rep(c('a','b'),each=5),2)

y = rep(rep(1:5,2),2)

z = c(rep(1,10),rep(0,10))

Freq = trunc(runif(20,1,6))




m = data.frame(x,y,z,Freq)
m

The resulted dataset would look like this

enter image description here

Anas116
  • 797
  • 2
  • 9
  • You maximise your chance of getting a useful answer if you provide a minimal reproducible example. [This post](https://stackoverflow.com/help/minimal-reproducible-example) may help. – Limey Nov 16 '22 at 11:30
  • In the data you posted in your question, there is _no_ association between the dependent and independent variables. Since `z` has a single value each of 1 and 0 for each unique combination of `x` and `y`, the adjusted groupwise odds for each level of x and y is exactly 1. However, it sounds like you want do a logistic regression with `glm(z ~ x + y, data = m, family = binomial)`. The coefficients of this model will be the log of the adjusted odds for each factor level. Perhaps create a more realistic data set if you need further guidance? – Allan Cameron Nov 16 '22 at 14:30
  • please check the uploaded photo in the updated version of the question so you see what I mean – Anas116 Nov 16 '22 at 14:34
  • logistic regression is producing odds ratios. I want the odds that make these odds ratios. because my employer wants that each group has its odds value so they can see how they are increasing/decreasing according to the values of odds ratios. I know it's bizarre but they insist on that. – Anas116 Nov 16 '22 at 14:37

0 Answers0