Correlated variables and scipy curve_fit
Try to use method = 'trf' as a parameter for your fit. This avoids using least squares and works with pseudoinverse of the Jacobian. I believe a Jacobian with a zero eigenvalue then should not be a problem.
I have a physical model with one independent variable X and three parameters A, B and C. The dependent variable is Y=F(X,A,B,C) where F is the model's function which is smooth and continuous.
I have many files with data points (X,Y) that I want to fit (each file) with the model to study how the parameters change. The model is non-linear with respect to the independent variable and all the parameters.
To fit the model, I use scipy.optimize curve_fit in Python inside a for loop throughout the files with the data points. For each file, I get the best fitting parameters (A,B,C) and the model fits great to all the files. However, when I check the parameter errors after the fittings, I notice that the errors in A are really large, even two orders of magnitude higher than the corresponding values.
The experience tells me that these large variances might be due to the fact that the parameter A could be correlated to any of the others. To check this assumption, I plotted the obtained values of A against the values of B and C. I see that, in fact, a power-law relation of the form A=a*B^b arises, which is physically acceptable.
Is there a way to tell curve_fit to take care of this correlation without having to introduce new parameters (say a and b) in order to fit the model with the lowest variance possible?