-1
$\begingroup$

I am trying to log transform time series data of Inflation. However, there is one negative value. I have added the constant 1 to all my values and the log transformed.

loginfl <- log(infl_ts + 1)

Will this affect my analysis?

I am planning to tun predictions on this data.

$\endgroup$

marked as duplicate by whuber Dec 11 '17 at 16:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Dec 11 '17 at 12:59

This question came from our site for professional and enthusiast programmers.

  • $\begingroup$ You would usually log-transform your data X if you can safely assume that the underlying probability distribution of Y = log(X) is normal; you can then use a linear model with normally distributed residuals for a downstream modelling/prediction analysis. The fact that you have negative values suggests to me that this is not the case. Could you please clarify, what is the rationale/justification for log-transforming the data? $\endgroup$ – Maurits Evers Dec 11 '17 at 0:15
  • $\begingroup$ i am log transformig the data so i can interpret it as % increments $\endgroup$ – user1607 Dec 11 '17 at 0:24
  • $\begingroup$ I would first model inflation directly (i.e. not log-transformed), then look at the distribution of residuals. You can always infer % changes from the model coefficients. If residuals are not (approximately) normally distributed, you might try a log transformation of the data; however the negative values suggest to me that your data is in fact not log-normal. $\endgroup$ – Maurits Evers Dec 11 '17 at 0:33
  • $\begingroup$ I am doing a time series analysis - checking for stationary, looking for granger causality, cointegration, predictions ... Why is the normality assumption of my residuals so crucial in this case? I thought i just need my residuals to be white noise ? I use the Ljung Box test to validate my Autoregressive Distributed Lag model $\endgroup$ – user1607 Dec 11 '17 at 0:44
  • $\begingroup$ Most popular models for time series data analysis (AR(1), ARIMA, etc.) have some form of normality assumption. If your residuals are not (approximately) normal, the MLE process to estimate model parameters may not be reliable. Looking at the distribution of residuals is always a crucial step in assessing the quality/validity of your model. $\endgroup$ – Maurits Evers Dec 11 '17 at 0:54
2
$\begingroup$

You might want to consider the log-plus-one transformation, as suggested on Cross Validated by @Firebug,

$Y = \text{sign}(x) \log(|x|+1)$

x <- sample(c(1,-1),size = 100,replace = T)*exp(runif(100, 10,20))
y <- sign(x)*log1p(abs(x))
$\endgroup$
  • 3
    $\begingroup$ The whole beast has also been called the neglog transformation. "log-plus-one" just sounds like what the OP is suggesting, but this is different. $\endgroup$ – Nick Cox Dec 11 '17 at 13:40
  • $\begingroup$ A reference is Whittaker, J., J. Whitehead and M. Somers. 2005. The neglog transformation and quantile regression for the analysis of a large credit scoring database. Applied Statistics 54: 863-878 FWIW, I don't find the name transparent, but I can't think of a much better one, and in any case it needs a really good name to justify muddying the waters with yet more terminology. I think I'd explain it as an extended logarithmic transformation, but even then it doesn't collapse to logarithm as a special case; it just is arbitrarily close for large $|x|$. $\endgroup$ – Nick Cox Dec 11 '17 at 14:30

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