I have to get a regression model for a dataset, and it seems that the best fit is a log-linear model, so that I simply applied the least squares on the trasformed response vector.

$ log(\hat{Y}) = f(X) = \hat\beta_0 + \bf{\hat\beta}^TX$

This means that the values $\hat{z}_i$ I predict from the test set through my model will be the natural logarithms of the target values.

$\hat{z}_i =log(\hat{y}_i)$

Now, how am I supposed to compute the mean squared error and the $R^2$?

Is it correct to consider $MSE = \frac1n{\sum{(y_i - \hat{y}_i)^2}} = \frac1n{\sum{(y_i - e^{\hat{z}_i})^2}}$

or $MSE = exp(\frac1n\sum{(log(y_i)-\hat{z}_i)^2})$ ?

Same question for the $R^2$.


  • $\begingroup$ Do you mean that you have a log transformed outcome or are you analyzing categorical data? See here If the first, then this is not a log-linear model. $\endgroup$ – AdamO Jun 29 '17 at 16:13
  • $\begingroup$ It seems that some people do not agree on what a log-linear model is. Anyway, the way we call what I am trying to do is not that important , the link you provided did not really help me with my problem. I am trying to understand how to compute the error on the prediction of a log-transformed outcome, there are no categorical data. $\endgroup$ – Möbius Jun 29 '17 at 16:35

Your Answer

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

Browse other questions tagged or ask your own question.