-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to do a polynomial? #20
Comments
The reason x22 doesn't work is that There's an argument that for numerical predictors, x2:x2 should be the same In your example, I(x2**2) doesn't work because x2 is a python list, not a On Tue, Jun 25, 2013 at 1:24 AM, Skipper Seabold
|
Is it possible/desirable that if the RHS of ** is an integer (or a numeric term) to not do the interaction expansion, because it's surely not what someone wants? |
I don't understand. The only legal RHS for ** is an integer, anything else The intended usage is to say things like "give me all 1, 2, or 3-way -n On Tue, Jun 25, 2013 at 1:10 PM, Skipper Seabold
|
Yeah I was thinking of |
It's better to use something like poly(x, 3) anyway, right? B/c that can On Tue, Jun 25, 2013 at 1:22 PM, Skipper Seabold
|
I suppose, if for ease of inference, though I rarely see it in practice. Might just be where I hang out. Different strokes. |
Translation of Stata's orthpoly.ado, so likely not fit for inclusion anywhere, but I'll leave it here. // cc @josef-pkt |
I think those are orthogonal polynomials, which are different. Orthogonal There's already code for doing this using qr in the patsy Poly class for
|
I find it confusing that polynomials should be QR orthogonalized. A question of choosing names so that most users (and not just R users) understand what the different versions mean. |
AFAICT, the Poly class is only intended for equally spaced categorical variables. At least, I couldn't figure out how to replicate what I'm not sure I understand your distinction between what's orthogonal to what. I think
|
I only looked at your code for a few seconds, so I could be confused :-) This looks like a good skimmable paper on why orthogonal is better than The confusion is that the term "orthogonal polynomial" almost always refers What we want are polynomials so that sum f1(x)f2(x) = 0 when summing over Poly() implements this latter (and only uses it for categorical variables What stata does I don't know. The manual page you pointed me to strongly Are the predictor vectors that you get out of orthpoly actually orthogonal AFAICT, the Poly class is only intended for equally spaced categorical I'm not sure I understand your distinction between what's orthogonal to from statsmodels.tools.tools import webuse http://www.stata.com/help11.cgi?orthpoly — |
Just parking this one-liner here, since I came back around to this. An equivalent to R's poly for continuous variables AFAIK, though not really numerically sound.
|
I'm going to close this one out since a PR exists that adds a |
I've seen https://groups.google.com/forum/#!topic/pystatsmodels/96cMRgFXBaA, but why doesn't something like this work.
or
This works
The text was updated successfully, but these errors were encountered: