how fit a model with data following asymptotic / sigmoid pattern

441 Views Asked by At

I'm trying to fit data. I assume that the association between dependent and indepdent variable is of the form

$$T(y)=aR(x)+b$$

I also know that my data are ressemble either an asymptotic function so that

$$R(x)=\arctan(\frac{\mathrm{x-c}}{\mathrm{d}})$$

or a sigmoid function so that

$$ R(x) = \frac{\mathrm{1} }{\mathrm{1} + e^{(\frac{{c-x}} {\mathrm{d}})}} $$

How can I find $a$, $b$, $c$ and $d$ in each of those situations?

1

There are 1 best solutions below

2
On BEST ANSWER

In your previous problem, you had the advantage that your models were simple enough to admit a linearization. If you are willing to accept, for example, that $$T(y)=R(x,a,b)$$ instead of $$T(y)=aR(x,a,b)+b,$$ then as a practical matter you can do the following in each scenario:

  • Estimate $\tan\left(T(y)\right)$ given $x$ using linear regression. The slope is $m=\frac{1}{b}$, and the intercept is $k=-\frac{a}{b}$ so that $b=\frac{1}{m}$ and $a=-\frac{k}{m}$.
  • Estimate $\log\left(\frac{T(y)}{1-T(y)}\right)$ given $x$ using linear regression. The slope and intercept are the same as before so that $b=\frac{1}{m}$ and $a=-\frac{k}{m}$.

Without some sort of similar simplification, the linear regression you have been using no longer suffices, and you need to perform a more complicated regression. The best way to do this varies a bit based on your data and your desired goals, but a reasonably common way to start is to use the Mean Squared Error.

To apply MSE, you define an auxiliary error function $$E(a,b,c,d)=\sum_{i}(T(y_i)-aR(x_i,c,d)+b)^2,$$ where the $x_i$ and $y_i$ represent the observed data you have. There are a variety of black-box solvers to take care of this for you (recall scipy.optimize.curve_fit from before), or you can attempt to solve it analytically.

To solve it analytically, you would want to take the partial derivatives of $E$ with respect to each of $a,b,c,d$ and set those partial derivatives equal to $0$. This gives a system of auxiliary equations to solve. The nonlinearity makes those equations unpleasant at the least, and I'm not certain they have nice closed forms. Even if they did, the quadratic convergence of newton-based function minimizers is likely to make black-box solvers competitive in computer runtime for tiny problems like these.