Fix a regression coefficient in Python

Viewed 25

I'm doing some regressions using Numpy Polynomial.fit but I would like to fix some of the coefficients, for example the zero order coefficient.

Is there a way to do so using standard Python libraries? In the documentation it seems that there is no option to do so, and here on SO I only found this post suggesting to use the statsmodels library, which I rather not use.

Here is the code I'm using now, but I don't think it will be of help:

x = df['Time'] 
y = df['Velocity']
lin_reg = np.polynomial.polynomial.Polynomial.fit(x, y, 1)
m = lin_reg.coef[1]
q = lin_reg.coef[0]

I would like to fix the value for q at, let's say, 2.24.

0 Answers
Related