Lets say I want to find the alpha (a) values for an equation which has something like
y=a+ax1+ax2+...+axi
Using OLS lets say we start with 10 values for the basic case of i=2
#y=a+ax1+ax2
y = np.arange(1, 10)
x = np.array([[ 5, 10], [10, 5], [ 5, 15],
[15, 20], [20, 25], [25, 30],[30, 35],
[35, 5], [ 5, 10], [10, 15]])
Using statsmodel I would generally the following code to obtain the roots of nx1 x and y array:
import numpy as np
import statsmodels.api as sm
X = sm.add_constant(x)
# least squares fit
model = sm.OLS(y, X)
fit = model.fit()
alpha=fit.params
But this does not work when x is not equivalent to y. The equation is here on the first page if you do not know what OLS.