Created
July 9, 2014 02:24
-
-
Save gileno/1b58b43e7b1d13eabfaa to your computer and use it in GitHub Desktop.
Simples regressão linear múltipla
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import numpy as np | |
def mmq(x, y): | |
u""" | |
x é uma matriz com as variáveis independentes | |
y é um array com a variável dependente | |
O retorno é um array contendo os valores dos beta's | |
""" | |
x = np.insert(x, 0, 1, axis=1) | |
x_t = np.transpose(x) | |
xt_x = np.dot(x_t, x) | |
inverse_xt_x = np.linalg.inv(xt_x) | |
xt_y = np.dot(x_t, y) | |
return np.dot(inverse_xt_x, xt_y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment