squaring doesn't seem to work
twiecki opened this issue · comments
I tried y ~ x**2
but it seemed like the squaring was ignored.
Hi @twiecki, you are right. If you want to square a variable you have to do y ~ I(x **2)
or, using an alternative syntax, y ~ {x ** 2}
. This is because **
is a valid operator for a set of terms.
For example, (a + b + c) ** 2
is equivalent to a + b + c + a:b + a:c + b:c
.
PS: This is the same logic behind the addition between terms. If you want a term that is the sum of other two terms, you do I(x + y)
or {x + y}
instead of just x + y
because the latter means you want to include x
and y
as separated terms.
We don't have it documented yet, but you can find it in Patsy docs here
Added warning in #13. Thanks for opening the issue!