# I have log transformed my data in R, but I want to find out what the 'original' unlogged value would be

I have a binomial glm modelling the probability of the occurrence of otter roadkill hotspots. My data were not normally distributed therefore to adhere to model assumptions I log transformed all of my variables in R.

The scale of the x-axis on my model prediction graphs are therefore logged. I have a graph looking at the association between roadkill hotspots and distance to nearest road-river crossing. In my model reporting, I have said 'At locations 5 or more metres from a road-river crossing, hotspots were very unlikely to occur.' I would like to know that the value 5 is unlogged, and add this to my figure caption. 5 metres is a tiny distance and in real life and based off of my data this is more likely to be say something like 750m.

Please could anyone tell me how I could find out what this value is unlogged?! To transform the data I just did log(dframe$rivercrossing). Have added my graph for context which has the logged scale. I can't seem to find any answers on this, I'm stumped! Any help would be massively appreciated. Thanks! ) • A logistic regression does not assume normally distributed variables whatsoever. If you used log(dframe$rivercrossing) then dframe$rivercrossing should hold the original distance. Otherwise, use exp() to backtransform a specific number, say$5$(approximately$148.4$meters). Oct 12 at 11:52 • @COOLSerdash thanks for your reply! I'm apprehensive using exp() as it doesn't seem right for other variables. E.g. I also have a variable which is distance to town (km), I am also mentioning the probability dipping at 6km. If I do exp(6) this gives me 403km, none of my original values in my dataset were over 15km. Oct 12 at 12:00 • The "unlog" is called the exponential function (not a "power" function--that would be different). For instance,$\exp(5)\approx 148$because$\log(148)=5.$– whuber Oct 12 at 16:45 ## 1 Answer I have a binomial glm modelling the probability of the occurrence of otter roadkill hotspots. My data were not normally distributed therefore to adhere to model assumptions I log transformed all of my variables in R. For the next time (or maybe when you want to redo the analysis), this log transform is not necessary for the reason to get the data shaped according to the assumption that it must be normally distributed. The problem situation that you refer to is the case when the error distribution is not following a normal distribution. In fact, the binomial GLM model doesn't assume normally distributed residuals either. That particular model is for data where the response variable has only values 0 and 1. However, log transforming the x coordinate might still be done for visualisation or in order to fit a specific trendline or function. The scale of the x-axis on my model prediction graphs are therefore logged. I have a graph looking at the association between roadkill hotspots and distance to nearest road-river crossing. In my model reporting, I have said 'At locations 5 or more metres from a road-river crossing, hotspots were very unlikely to occur.' I would like to know that the value 5 is unlogged, and add this to my figure caption. 5 metres is a tiny distance and in real life and based off of my data this is more likely to be say something like 750m. The inverse of taking the logarithm is exponentiation. Often the log refers to either the natural logarithm or a logarithm with base 10. So the value 5 will refer to $$10^5 = 100000 \text{ meters } = 100 \ \text {km}$$ or to $$\exp(5) = e^5 \approx 148 \text{ meters }$$ To make your graph easier to read you could transform all x values back in the plotting and plot the x-axis as a log-scale. Then you have the same shape as in your current graph but with the labels transformed to the actual values in meters. See below for example: • Thanks for your reply! I'm a bit lost with the suggestion of having the x-axis as a log-scale, is that not already what is it? I didn't really want to change the scale, just find out what 5 would be in metres and pop that in the figure caption. If I were to change the scale, how would I plot the x-axis as the actual values instead? I've had a search to see if anyone has asked a similar question on here about how to do this but I'm not having much luck. Thank you! Oct 12 at 12:25 • @EllaRobertson you plotted indeed already on a log-scale but you did this by transforming the labels as well. You could also plot on a log-scale without transforming the variable. Then the curve shape and the positions of the points are adjusted in the graph, but the labels are not transformed. See the example that I have added to the answer. In R you would use something like plot(x, y, log = "x") instead of plot(log(x), y). Oct 12 at 15:50 • At "this log transform is not necessary" you seem to be telling us that any logistic regression with explanatory variables$x_1,\ldots, x_k$is the same as the logistic regression with variables$\log x_1, \ldots, \log x_k.\$ Of course you didn't intend that: these are obviously different models. But what are you trying to say?
– whuber
Oct 12 at 20:15
• @SextusEmpiricus I see what you mean and thanks so much for the example graphs! I still can't figure out how to do this in R. If I plot the non logged scale the prediction lines only cover a tiny % of the graph because they are running from the logged values which are 1-8, where as the true values are 0-3000m. I don't understand how to keep everything the same, but change the x-axis scale?! Thanks again! Oct 13 at 10:36
• @Ella What I did is convert the variable exp(x) but plot on a log scale log = "x" giving combined plot(exp(x), y, log = "x") Oct 13 at 10:56