lindeloev/tests-as-linear

Is there any python code add on ?

Closed this issue · 3 comments

Thanks very much for the R code and explanation of the GLM !
I think pretty cool to let people understand all those statistics in GLM way
Though the R code is easy and clear , is it possible to add python code for reference ?

I list below as those I can find (mostly scipy, , but the syntax is NOT as beautiful as R ...

Y ~ continous x

Y ~ descrete x

Multiple regression : lm(y ~ 1 + x1 + x2 + ...)

Thanks for doing some legwork here! It seems that scipy.stats is suboptimal for several reasons. First, they don't compute confidence intervals for most (any?) of the tests using the built-in functions. Second, stats.linregress does not seem to work for categorical predictors.

I'm currently looking into statsmodels which uses patsy, which is really just the R syntax. This may do all the functions that we want to, but because of the large similarity to R, I'm not sure whether it adds enough to offset the cost of doing it. For example, the cheat sheet would be virtually the same.

But I would be VERY happy if someone did it anyway! Whether in this repo (with full credit, of course) or somewhere else. What do you think?

@lindeloev @t0mst0ne I'd be interested in taking this on!

I'm planning on porting this to Python as a side-project, purely for my own education. However, I think there's also value in having a Python port of this project: it will increase the audience of this post, and if nothing else, it will highlight the shortcomings with the Python statistical environment (at least compared to R).

I think it makes most sense to have the port in a separate repo: this resource is already very long, and mixing the code would make the exposition much messier. I've already start work here: https://github.com/eigenfoo/tests-as-linear, and the result is hosted on my blog here: https://eigenfoo.xyz/tests-as-linear. Obviously, still a work in progress!

@lindeloev if you don't mind, I am sure I will eventually have some questions or need some feedback. Would you be willing to take a look at the port when the time comes?

I'm thrilled to see this, @eigenfoo! Yes, I'd be very happy to give some feedback on your version. Looks like you're off to a good start. I am on holiday most of July, but until then (and afterwards), just mention me in a comment, and I'll take a look.