0

I want to ask for your help to model a multivariate non-liear model of the form: y=b1*x1^b2 + b3*x2 + b4*x3. Previously I used the next form for a single independent variable non-linear model. But now with an X array with multiple independent variables I dont know hoe to proceed.

def expon(x, Beta_1, Beta_2):
     y = Beta_1*np.exp(Beta_2*x)
     return y

from scipy.optimize import curve_fit

popt, pcov = curve_fit(sigmoid, xdata, ydata )
print(" beta_1 = %f, beta_2 = %f" % (popt[0], popt[1]))

1 Answers1

0

This question is very similar. In your case, pack your variables, pass them to the function and unpack inside the function -

X = (x1, x2, x3)
def expon(X, b1, b2, b3, b4):
    x1, x2, x3 = X
    y = b1 * (x1 ** b2) + b3 * x2 + b4 * x3
    return y
Abhineet Gupta
  • 624
  • 4
  • 12