linregress: Replicate R's lm()

[email protected]
Newsgroups gmane.comp.python.scientific.devel
Message-ID <[email protected]>
I try to replicate R's lm() (linear regression, possibly "Ordinary Least 
Squares") wiht SciPy.

Based on the "mtcars" dataset the formula is 'qsec ~ mpg * wt + gear'.
This are 3 different types of arguments.

But SciPy's linregress() only offer two arguments [1].

This is not possible of course
linegress("qsec", "mpeg, wt", "gear", data=mtcars)


Here is an MWE in R:

data(mtcars)
m = lm(formula = qsec ~ mpg * wt + gear, data = mtcars)
summary(m)

That is an MWE in Python using statsmodels producing the same results 
then the R variant.

import pydataset
# Ordinary Least Squares
from statsmodels.formula.api import ols

mtcars = pydataset.data('mtcars')
m = ols(formula='qsec ~ mpg * wt + gear', data=mtcars)
print(m.fit().summery())

[1] -- 
<https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.linregress.html>
_______________________________________________
SciPy-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/scipy-dev.python.org/
Member address: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.