3 ms·
It's been awhile since my undergrad stats classes, but doesn't using a boxcox-transform on a objective metric, fitting the dataset to the transformed metric, an
by minimaxir 8y ago
It's been awhile since my undergrad stats classes, but doesn't using a boxcox-transform on a objective metric, fitting the dataset to the transformed metric, and then inverting it violate model assumptions? (or maybe that's just in the case of a linear regression and not Prophet's approach)
- oarabbus_ 8y agoFor those of us whom it's also been a while since our undergrad stats classes but clearly we retained much less of it than you did, could you elaborate a bit here? Shit, I've forgotten everything, I'm googling model assumptions, boxcox transform, the works
- wenc 8y agoI believe as long as the transformation function is invertible (no information is lost), it ought to be a valid approach. The Box-Cox function as far as I can tell is invertible. If a transformation f has the property (f^-1 o f)(x) = x then (f^-1 o g o f)(x) should be valid -- though how to rigorously demonstrate this in all cases evades me for now. (there are some conditions that need to be satisfied) Rob Hyndman, the author of the "forecast" package in R, also thinks it's ok (slide 17 [1]) [1] https://robjhyndman.com/talks/RevolutionR/7-Transformations.pdf https://robjhyndman.com/talks/RevolutionR/7-Transformations....
- tfehring 8y agoIt just establishes new model assumptions. In the linear regression case, fitting boxcox(y) = βX + ε and predicting with boxcox^(-1)(yhat) produces different predictions than fitting y = βX + ε (minimizing Σ(boxcox(y) - boxcox(yhat))^2 does not minimize Σ(y - yhat)^2 in general). Either model would be an approximation, of course, and it's possible for either to produce more accurate predictions than the other for a given set of observations. I'm not familiar enough with Prophet to know whether the same logic applies here, though I'd hazard a guess that it does.
- yorwba 8y agoRight. In particular, using least squares is justified by the assumption that errors are normally distributed, in which case least squares yields the maximum-likelihood estimate. Because boxcox is intended to transform a random variable into one that is normally distributed, the model assumptions are actually more likely to be satisfied if you do regression on the transformed values. (Which was probably the reason boxcox was invented in the first place.)
- CapmCrackaWaka 8y agoYes, it does. However, it can usually be offset by some adjustment measure. The same thing happens when you take the log of your target variable and run a regression with RMSE as your loss, then try to get your predictions by taking e^prediction. Going from a lognormal to a normal distribution requires an offset, in this case: exp(variance(log preds - log target)/2). Box-Cox (which is very similar to log) would require a similar offset, however I don't know how to calculate it. https://en.wikipedia.org/wiki/Log-normal_distribution https://en.wikipedia.org/wiki/Log-normal_distribution
- wenc 8y ago> Yes, it does. I'm trying to follow your explanation but help me understand better: which model assumptions would it violate? Typical assumptions for time-series forecasting are stationarity (differencing is used to achieve this if not already the case), residuals are homoskedastic (constant variance) and normally distributed, etc. In fact, the primary use of the Box-Cox is to stabilize the variance and make the data more normal. Box-Cox itself doesn't violate any model assumptions. Forecasting on Box-Cox transformed data shouldn't either -- if anything, Box-Cox attempts to better satisfy the assumptions of time-series forecast models (well, as best it can -- some data just don't want to be normal). Now the question is whether the inverse Box-Cox (or the entire process) violates any model assumptions. Intuitively, I don't believe it does (and Rob Hyndman, author of book on Forecasting agrees) but I'm not certain how to demonstrate this rigorously.
- CapmCrackaWaka 8y agoThe assumption that your target is normally distributed about the expected value. Let's say you take the log of your target, and run a regression using RMSE. You now assume that log(Y) is normally distributed. Now, for a given sample, your model outputs E[log(Y)|X]. However, exp(E[log(Y)|X]) is not the same as E[exp(log(Y)|X], which is what you really want. It can be shown mathematically that in order to get to E[exp(log(Y)|X], you need to multiply by an offset factor, which in this case is exp(var(E[log(Y)]-log(Y)/2), which is how you would normally transform between the mean of a normal distribution to a lognormal distribution. Here is a paper which addresses the issue in the introduction. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4024993/ https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4024993/