0

I need help utilizing Numpy via Python for linear regression determination of two independent variables and one dependent variable. I have found this code snippet below for finding the r^2 values I believe from http://rosettacode.org/wiki/Multiple_regression#Python

import numpy as np

height = [1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63,
    1.65, 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83]
weight = [52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93,
    61.29, 63.11, 64.47, 66.28, 68.10, 69.92, 72.19, 74.46]

X = np.array(height)[:, None]**range(3)
y = (weight)

print(np.linalg.lstsq(X, y)[0])

How can I edit this for determining the r^2 values for two independent variables and one dependent variable? Thanks

MichaelChirico
  • 33,841
  • 14
  • 113
  • 198
Techno04335
  • 1,365
  • 6
  • 22
  • 43
  • 1
    The name of the game is "multivariate linear regression", and the answer you can find here: http://stackoverflow.com/questions/11479064/multivariate-linear-regression-in-python. On the other hand, this makes your question a duplicate ;). – Jblasco Aug 31 '15 at 19:32
  • Thank you very much, very useful information indeed! I tried to search for a answer before submitting my question. Thanks again! – Techno04335 Aug 31 '15 at 19:46
  • Welcome! It's difficult when you don't know the name of what you are looking for! – Jblasco Aug 31 '15 at 19:46

0 Answers0