1
$\begingroup$

Question asked: Fit a linear model on $y,x$ where $y=\exp x$.

I replied: Take $\log$ on both sides then fit $\log y$ vs $x$. Get $y_{pred}$ then take exponential of $y_{pred}$ to get corresponding $y$ value. Interviewer said something is missing in conversion of $y_{pred}$ to $y$. I am not able to find it.

Can somebody help me in understanding that?

1 Answers 1

0

I suppose that this is just a question of terminology.

You have $n$ data points $(x_i,y_i)$ and you want to fit the exponential model $$y=e^{a+bx}$$ You make the problem linear taking logarithms $$\log(y)=a+bx$$ Defining $z_i=\log(y_i)$, the model is then $$z_i=a+b x$$ The linear regression gives $a$ and $b$. Now, for a given value of $x=x_*$, you want to predict $y_{pred}$ from the model. So, the steps are $$z_{pred}=a+bx_*\implies y_{pred}=e^{z_{pred}}$$

  • 0
    `you want to fit the exponential` From OP's quote, the question was to "*fit a linear model*". That's the confusing part, since what could be considered the "*best*" fit may depend on wording pedantries.2017-02-09
  • 0
    The start of the post includes $y=\exp(x)$. This is why I supposed that there were some terminology issues in the process.2017-02-09
  • 0
    Well, Interviewer was good with talking log of y and then fit a regression model on log y vs x. He said now you make prediction on new dataset with that model and you get y_pred(logy). Now i want to convert y_pred to y, Tell me how would you do that? Then i said if we take exponential of y_pred, we will get y. He said something is missing in conversion. I could not think of anything missing.2017-02-09
  • 0
    @PrashantSharma. To me, Interviewer's attitude looks very strange. In French, we have an expression which says "this is looking for hair on eggs".2017-02-09