# Logistic regression

#### blueycool

##### New Member
Hi,
I am stuck with my assignment question for awhile, need some advise on solving. Here is the question:

The following logistic model (Model A) is postulated for the data (from a data file) that has been observed.

P= 1/ (1 + exp {-(β1*x1 + β2*x2 + β3*x3 + β4*x4 )})

Fit a logistic model with all first order terms and 2 parameter interactions (Model B). Using Model A, compute the odds ratios due to x1 and x2. Using Model B, compute the odds ratio for x3 and x4. Show all relevant workings. Comment on the difference in considerations in the odds ratio computations for the two models.

My approach:
Run model A & B in stats software to get the logistic regression coefficients
Fitted model A:
P = 1/ (1 + exp {-(-2.553*x1 -0.335*x2 – 0.003*x3 – 0.0008*x4)})

Model B -> model A + all 2 parameter interactions?
P = 1/ (1 + exp {-(β1*x1 + β2*x2 + β3*x3 + β4*x4 + β5*x1*x2 + β6*x1*x3 + β7*x1*x4 + β8*x2*x3+ β9*x2*x4 + β10*x3*x4)})

Fitted model B:
P = 1/ (1 + exp {-(1.446*x1 -86.227*x2 + 1.911*x3 + 1.672*x4 + 75.534*x1*x2 -1.721*x1*x3 - 1.519*x1*x4 -0.0002*x2*x3+ 0.00798*x2*x4 + 0.0001*x3*x4)})

Since need to show all relevant workings, not able to get odds ratio directly from software.
For model A,
Odds ratio of x1
= (odds| x1=1) / (odds| x1=0)
= exp {β0 + β1*(1) + β2*x2 + β3*x3 + β4*x4}/ exp {β0 + β1*(0) + β2*x2 + β3*x3 + β4*x4} = ......
= e (β1)
= e -2.553= 0.0778

Odds ratio of x2
= (odds| x2=1) / (odds| x2=0)
= exp {β0 + β1*x1+ β2*(1) + β3*x3 + β4*x4}/ exp {β0 + β1* x1+ β2*(0) + β3*x3 + β4*x4} = ....
= e (β2)
= e -0.335= 0.7153

For model B,
Odds ratio of x3
= (odds| x3=1) / (odds| x3=0)
= exp { β0 + β1*x1 + β2*x2 + β3*(1) + β4*x4 + β5*x1*x2 + β6*x1*(1) + β7*x1*x4 + β8*x2*(1) + β9*x2*x4 + β10*(1)*x4}/ exp { β0 + β1*x1 + β2*x2 + β3*(0) + β4*x4 + β5*x1*x2 + β6*x1*(0) + β7*x1*x4 + β8*x2*(0)+ β9*x2*x4 + β10*(0)*x4} = ...
= e (β3 + β6*x1 + β8*x2+ β10*x4)

For model B, how do I simply the odds ratio (above expression) to get:
Odds ratio of x3 = e (β3)
Odds ratio of x4 = e (β4)
to get the defined formula of odds ratio?

Or do I need to remove parameters from model B? How do I go about doing it but still maintaining it as model with interaction terms?

Anybody who can help me on this.
Thanks!

#### blueycool

##### New Member
Anybody can offer advise on this?
Thanks a lot!

#### fed1

##### TS Contributor

Can you summarize in 50 words or less an important sub question maybe

:shakehead :tup: :yup:

#### blueycool

##### New Member
Summarised question:

Model A: P= 1/ (1 + exp {-(β1*x1 + β2*x2 + β3*x3 + β4*x4 )})

Fit a logistic model with all first order terms and 2 parameter interactions (Model B). Using Model B, compute the odds ratio for x3 and x4. Show all relevant workings.

My approach:
Model B -> model A + all 2 parameter interactions?
P = 1/ (1 + exp {-(β1*x1 + β2*x2 + β3*x3 + β4*x4 + β5*x1*x2 + β6*x1*x3 + β7*x1*x4 + β8*x2*x3+ β9*x2*x4 + β10*x3*x4)})

Fit model B to get regression coefficients

Odds ratio of x3
= (odds| x3=1) / (odds| x3=0)
= exp { β0 + β1*x1 + β2*x2 + β3*(1) + β4*x4 + β5*x1*x2 + β6*x1*(1) + β7*x1*x4 + β8*x2*(1) + β9*x2*x4 + β10*(1)*x4}/ exp { β0 + β1*x1 + β2*x2 + β3*(0) + β4*x4 + β5*x1*x2 + β6*x1*(0) + β7*x1*x4 + β8*x2*(0)+ β9*x2*x4 + β10*(0)*x4} = ...
= e (β3 + β6*x1 + β8*x2+ β10*x4) = ?

How do I simply the above expression? Or do I need to remove parameters from model B? How do I go about doing it but still maintaining it as model with interaction terms?

#### fed1

##### TS Contributor
Odds ratio should be the exponentiation of parameter B_3

logit( P|X_3 = 1 ) - logit( P|X_3 = 0 ) = log( OR_x3 )

= B_3 (1) + whatever - B_3 (0) - whaterver