2
$\begingroup$

I want to solve a nonlinear regression model $y=\alpha*\exp(\beta𝑥)$ using a linear regression model through variable transformation. Simple question up-front: Can I use log transformation even though some of my data (in Y) is negative?

Is there a way to find out which transformation to use for a certain model? I have a data set of two variables without any knowledge of what they stand for.

Update the goal is to find the parameters $\alpha$ and $\beta$ of the regression model above, using a linear regression. Therefore I need to transform the model into a linear one. The data set contains only 99 entries for X and Y and can be found here https://drive.google.com/open?id=1M6kllETfEF7m-tT-1EG3QChuNXufeh_C

$\endgroup$
  • $\begingroup$ If $y$ changes sign in your data, the model makes no sense. It forces $$\mathrm{sgn}(y_i) = \mathrm{sgn}(\alpha) \quad \forall\ i$$ $\endgroup$ – AlexR Apr 17 '18 at 8:27
  • 1
    $\begingroup$ @AlexR The model can make sense even when $y$ changes sign, if we assume non-multiplicative errors. For instance, $$y_i=\alpha \exp(\beta x_i) + \varepsilon_i$$ with $\varepsilon_i$ iid Normal$(0,\sigma^2)$ errors can produce such sign changes, especially when some $\beta x_i\ll 0.$ $\endgroup$ – whuber Apr 17 '18 at 13:40
  • 1
    $\begingroup$ @whuber You‘re right. I automagically assumed a multiplicative error term. OP should specify the assumed error structure. $\endgroup$ – AlexR Apr 17 '18 at 14:44
  • 1
    $\begingroup$ Re the update: First note that there is, up to a linear transformation, a unique way to transform the expected response so that the regression is linear: take the log. Next, please do not confuse linear regression, in its usual sense of the conditional expectation of the response varying linearly with the regressor $x,$ with some particular procedure to estimate a linear regression, such as Ordinary Least Squares. The crux of the matter seems to be that you cannot apply OLS directly by transforming the response. So don't even try--use an appropriate method instead, such as fitting a GLM. $\endgroup$ – whuber Apr 17 '18 at 14:48
  • 1
    $\begingroup$ If it is of any use to you, when I directly fit your data to the equation "y = a * exp(bx)" with no transform, I get parameter values of a = 1.7423978267794393E-01 and b = 4.1413585384216617E-01 with R-squared of 0.902 and RMSE of 0.874 $\endgroup$ – James Phillips Apr 17 '18 at 15:09
2
$\begingroup$

Here are the 100 (not 99) observations in a display that might be more convenient for some people.

  x      y 
  0   .045
 .1   1.55
 .2    .14
 .3   1.03
 .4  1.107
 .5  1.547
 .6  -.484
 .7  1.152
 .8   .499
 .9  -.796
  1  1.064
1.1  -.626
1.2  1.283
1.3  -.725
1.4   .824
1.5  1.005
1.6  -.089
1.7   .165
1.8  1.807
1.9  -.453
  2  1.331
2.1  1.514
2.2   .795
2.3   .782
2.4   .351
2.5  1.916
2.6  1.179
2.7  1.933
2.8  1.305
2.9  1.872
  3   .611
3.1  1.834
3.2   .967
3.3  2.203
3.4  -.063
3.5  -.321
3.6   .704
3.7  -.463
3.8   .951
3.9   .042
  4   .895
4.1  2.208
4.2  2.037
4.3   .466
4.4   1.59
4.5    .61
4.6  1.461
4.7  -.179
4.8   .213
4.9   .244
  5  1.522
5.1   .703
5.2    .69
5.3   .202
5.4  3.028
5.5   .676
5.6   .821
5.7   .857
5.8   3.25
5.9  1.351
  6  3.084
6.1  1.059
6.2  3.315
6.3  2.688
6.4  3.625
6.5  3.116
6.6  3.667
6.7  2.079
6.8  1.555
6.9  2.616
  7  2.782
7.1  4.467
7.2  2.519
7.3  3.066
7.4  3.971
7.5  3.746
7.6  4.913
7.7  5.246
7.8  3.463
7.9  3.782
  8  4.089
8.1   3.64
8.2  5.278
8.3  5.663
8.4  6.046
8.5  7.148
8.6   5.78
8.7  6.801
8.8  6.536
8.9  5.963
  9   8.13
9.1  8.791
9.2  6.489
9.3  7.389
9.4  8.787
9.5  9.722
9.6  9.745
9.7   9.37
9.8  10.71
9.9 10.032

The evident issue here is the 10 negative values of y. But no matter: the data are otherwise very well behaved and nonlinear least squares and generalized linear model with log link and Gaussian family return practically the same predictions. (I have no dogma against different set-ups, but there is no need for a transformation. A standard pitfall in comparing data and fitted curve is to forget to judge differences vertically, which is much of the point of the plots of residual versus fitted.)

enter image description here

The portfolio above is top line: nonlinear least squares; bottom line generalized linear model. A separate analysis confirms that the predictions are very close (biggest absolute difference is about $10^{-6}$). The errors look very much additive, not multiplicative.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Excellent analysis, my professional compliments. $\endgroup$ – James Phillips Apr 17 '18 at 15:29
  • 1
    $\begingroup$ +1. A diagnostic plot of the absolute deviance residuals (against the log predicted value) in the GLM suggests some mild heteroscedasticity, with the SD of the response near $X=10$ being only about half that near $X=2.$ Otherwise the GLM is a nice fit. $\endgroup$ – whuber Apr 17 '18 at 15:30
  • $\begingroup$ Thanks for the positive comments. You have to strain to see convincing evidence of heteroscedasticity given fewer observations for large $y$. $\endgroup$ – Nick Cox Apr 17 '18 at 15:35
  • $\begingroup$ I am impressed by how similar the two models are. I appreciate the help, the answer and comments help me a lot! I do think that my Professor created the negative Y-values solely to make things a little bit more complicated as I agree that they do not make much sense as outcome for an exponential formula. $\endgroup$ – Phi Lipp Apr 18 '18 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.