# Incorrect Lambda value with Box-Cox transformation on time series data in python

I am trying to perform Box-Cox transformation of my time series data and I am getting a lambda value of -14.38 in python. Isn’t this wrong since lambda lies between -5 and 5 in Box-Cox transformation?

My data has high variance with increasing trend in annual growth rates for every year, so I want to transform it to stabilize variance. What could be wrong that I am getting this unusual lambda value?

For reference attached image shows how my series looks like.

Code used in python:

sessions_df['sessions'], lambd=  stats.boxcox(sessions_df['sessions'])
print('Lambda: %f' % lambd)


## 1 Answer

http://docplayer.net/12080848-Outliers-level-shifts-and-variance-changes-in-time-series.html suggests ways to treat deterministic non-constant error variance in the model's residuals. The distribution of the original series is not as relevant as the errors from a useful modelhttp://stats.stackexchange.com/questions/18844/when-and-why-to-take-the-log-of-a-distribution-of-numbers .

As to why your box-cox coefficient is "silly" ..it is probably due to the fact that you haven't considered a useful model and/o the presnce of untreated deterministic structure.

Look at @Glen_b remarks here Forecasting: Linear vs. Exponential vs. ARIMA for some pointers on modelling time series when both stochastic and deterministic structure(latent) are present.

Your data visually suggests a break point in trend and perhaps increased error variance with some outliers. Can't help you with Python .

You might contact the authors and present your data to them for more immediate help.

From : @Glen_b remarks What is Box-Cox regression?

" Consider that if you just look at Y and find a Box-Cox transformation before you consider your x-variables, you're looking at the marginal distribution for Y, when the issue in regression is really (a) the shape of the relationships with those predictors and (b) its conditional distribution (especially getting things like conditional variance reasonably close to constant). As such you can't really hope to find a suitable transformation without doing it within the context of the regression itself."

I modify/generalize the last sentence with "context of the model itself"