How can I do a fit for negative $y$-data, which has exponential phenomena?
Such as:
coefs = np.polyfit(xs,np.log(rs+abs(np.min(rs))+1), 1)
fit = np.exp(coefs[1])*np.exp(coefs[0]*xs)
But if I move $\log(y)$ to $\log(y+a)$, then do a fit, how can I go back to the original pre-fit $\log(y)$?
What confuses me is that can I know how polyfit or others treat the input. Should I do the adjusting somewhere else?
Something else I could do?
The pic describes everything prior to the model building. So I only have some $x$s and negative $y$s and want to infer whether it has "exponentiality" to it or parts of it.
Suggests doing a transformation of the form $\log(y)=\log(Y+1-\min(Y))$. But again I wonder, whether, after doing the fit, the "back-transformation" would be algebraically accurate. That is, whether $y=\exp(y_{fit})-1+\min(y)$ or $y \approx \exp(y_{fit})-1+\min(y)$.
The data has no specific meaning (it's random generated), but the order has meaning.
How about doing $\log(|Y|)$ to mirror/flip the shape to the positive side, do the fit, then mirror it back?
But I wonder if flipping the pattern would alter the fit? That is, whether this should be "moved", rather than flipped? Flipping would make larger values smaller values. OR this might depend on the interpretation of "larger". What if it's "larger negative"?
Reproducible code:
https://pastebin.com/ncpzrN4M (with transforms)


polyfitand $\log$. – mavavilj Dec 31 '18 at 21:37polyfitwould return the coefs as opposite sign and then I can just flip their sign? So I would build my fit likefit = np.exp(-coefs[1])*np.exp(-coefs[0]*xs). – mavavilj Dec 31 '18 at 21:45-min(y)), but you could add more. I'm going to stop answering now sorry, because judging what the 'best' approach is depends on much more context that we don't have (the goal of the analysis, why you need to fit an exponential, your level of computational and statistical sophistication and that of your audience, etc. ...) – Ben Bolker Jan 01 '19 at 00:09