3 Variable no 3-way logistic regression

eq1 = (t0/(1 + t0)) p00 + (((t0 t3))/(1 + t0 t3)) 
            p10 + (((t0 t4))/(1 + t0 t4)) 
            p01 + (((t0 t3 t4))/(1 + t0 t3 t4)) p11 == 
        m0

eq2  =  (((t0 t3))/(1 + t0 t3)) 
            p10 + (((t0 t3 t4))/(1 + t0 t3 t4)) p11 == 
        m3

eq3 = (((t0 t4))/(1 + t0 t4)) 
            p01 + (((t0 t3 t4))/(1 + t0 t3 t4)) p11 == 
        m4

Solve[{eq1, eq2, eq3}, {t0, t3, t4}]

Solve[{(t0/(1 + t0))*p00 + ((t0*t3)/(1 + t0*t3))*p10 + ((t0*t4)/(1 + t0*t4))*p01 + 
     ((t0*t3*t4)/(1 + t0*t3*t4))*p11 == m0, 
   ((t0*t3)/(1 + t0*t3))*p10 + ((t0*t3*t4)/(1 + t0*t3*t4))*p11 == m3, 
   ((t0*t4)/(1 + t0*t4))*p01 + ((t0*t3*t4)/(1 + t0*t3*t4))*p11 == m4}, {t0, t3, t4}]

Solve[{(t0/(1 + t0))*p00 + ((t0*t3)/(1 + t0*t3))*
              p10 + ((t0*t4)/(1 + t0*t4))*
              p01 + ((t0*t3*t4)/(1 + t0*t3*t4))*p11 == 
          m0, ((t0*t3)/(1 + t0*t3))*
              p10 + ((t0*t3*t4)/(1 + t0*t3*t4))*p11 == 
          m3, ((t0*t4)/(1 + t0*t4))*
              p01 + ((t0*t3*t4)/(1 + t0*t3*t4))*p11 == 
          m4}, {t0, t3, t4}]

4 variable Logistic Regression model

Deriving logistic regression from Exponential Family below
f(x1,x2,y)∝exp(t0 y+t1 x1 +t2 x2+t3 x1 y+t4 x4 y+t5 x1 x2+t6 x1 x2 y)

eqns = {(t0/(1 + t0)) + (((t0 t3))/(1 + t0 t3)) + (((t0 t4))/(1 + t0 t4)) + (((t0 t3 t4 t6))/(1 + t0 t3 t4 t6)) == 
          4 m0, (((t0 t3))/(1 + t0 t3)) + (((t0 t3 t4 t6))/(1 + t0 t3 t4 t6)) == 
          4 m3, (((t0 t4))/(1 + t0 t4)) + (((t0 t3 t4 t6))/(1 + t0 t3 t4 t6)) == 
          4 m4, (((t0 t3 t4 t6))/(1 + t0 t3 t4 t6)) == 
          4 m6}

Solve[eqns, {t0, t3, t4, t6}]

Solution

sol = {t0 -> (((m0 - m3 - m4 + m6))/(1/4 - (m0 - m3 - m4 + m6))), t3 -> (((m3 - m6))/(1/
                    4 - (m3 - 
                      m6))) ((1/4 - (m0 - m3 - m4 + m6))/((m0 - m3 - m4 + m6))), 
        t4 -> (((m4 - m6))/(1/
                    4 - (m4 - 
                      m6))) ((1/4 - (m0 - m3 - m4 + m6))/((m0 - m3 - m4 + m6))), 
        t6 -> (m6/(1/4 - 
                  m6)) ((((m0 - m3 - m4 + m6))/(1/4 - (m0 - m3 - m4 + m6)))) ((1/4 - (m3 - m6))/((m3 - 
                    m6))) ((1/4 - (m4 - m6))/((m4 - m6)))}

eqns /. sol // Simplify

expr = {(1/4) ((t0/(1 + t0)) + (((t0 t3))/(1 + t0 t3)) + (((t0 t4))/(1 + t0 t4)) + (((t0 t3 t4 t6))/(1 + t0 t3 t4 t6))), (1/4) ((((t0 t3))/(1 + t0 t3)) + (((t0 t3 t4 t6))/(1 + t0 t3 t4 t6))), (1/4) ((((t0 t4))/(1 + t0 t4)) + (((t0 t3 t4 t6))/(1 + t0 t3 t4 t6))), (1/4) (((t0 t3 t4 t6))/(1 + t0 t3 t4 t6))}

expr /. sol // Simplify

General Logistic Regression equations

1.  Generate exponential family

d = 2

n = (2^d)

Sequence @@ ({Subscript[x, #], -∞, ∞} & /@ 
          Table[i, {i, 1, d}])

\(a1 = \(x\_# &\) /@ Table[i, {i, 1, d}]\)

a2 = Subsets[a1]

a3 = Prepend[#, 1] & /@ a2

a4 = Apply[Times, #] & /@ a3

\(a5 = \(th\_# &\) /@ Table[i, {i, 0, Length[a4] - 1}]\)

a6 = Thread[{a4, a5}]

a7 = Apply[Times, #] & /@ a6

a8 = Log[1 + Exp[Plus @@ a7]]

\(a9 = \(D[a8, th\_#] &\) /@ Table[i, {i, 0, 2^d - 1}]\)

bounds = {#, 0, 1} & /@ a1

a10 = Table[#, Evaluate[Sequence @@ bounds]] & /@ a9

a11 = Flatten[#] & /@ a10

a12 = Apply[Plus, #] & /@ a11

a13 = Thread[{a12, Table[(Subscript[m, i]), {i, 0, (2^d) - 1}]}]

equations = Apply[Equal, #] & /@ a13

unknowns = Table[(Subscript[th, i]), {i, 0, (2^d) - 1}]