7

Is there any library to perform a Multivariate Multiple Regression (a Multiple Regression with multiple dependent variables) in Python?

Greetings and thanks in advance

1
  • 1
    Asking for library recommendations is explicitly off topic. See: help center, tour, How to Ask. Commented Feb 16, 2020 at 5:08

1 Answer 1

5

You can try the modules in sklearn, the response variable can be 2 or more dimensional, and i think it works for OLS (linear regression), lasso, ridge.. The models in statsmodels can only do 1 response (just checked).

Example dataset:

import pandas as pd
from sklearn.datasets import load_iris
iris = load_iris()
df = pd.DataFrame(data= iris['data'],
                     columns= iris['feature_names'] )

df.shape
(150, 4)

Now we do the fit:

from sklearn import linear_model
clf = linear_model.LinearRegression()
clf.fit(df[['sepal length (cm)']],df[['petal length (cm)','petal width (cm)']])
clf.coef_

array([[1.85843298],
       [0.75291757]])

You can see the coefficients are the same as when you fit one response in this case:

clf.fit(df[['sepal length (cm)']],df[['petal width (cm)']])
clf.coef_
array([[0.75291757]])
Sign up to request clarification or add additional context in comments.

1 Comment

Asking for library recommendations is explicitly off topic. See: help center, tour, How to Ask.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.