The formulas are written in patsy. When writing your formulas, use NumPy functions whenever you can.
np.lognp.sqrtnp.power(x,2) for the square of x. Using x*x does not work!a:b means only the cross effect a multiplied by b.stuff * other means stuff + other + stuff:other.