Tag Info

Hot answers tagged

36

I always hesitate to jump into a thread with as many excellent responses as this, but it strikes me that few of the answers provide any reason to prefer the logarithm to some other transformation that "squashes" the data, such as a root or reciprocal. Before getting to that, let's recapitulate the wisdom in the existing answers in a more general way. Some ...


21

I always tell students there are three reasons to transform a variable by taking the natural logarithm. The reason for logging the variable will determine whether you want to log the independent variable(s), dependent or both. To be clear throughout I'm talking about taking the natural logarithm. Firstly, to improve model fit as other posters have noted. ...


12

I am very wary of using logarithmic axes on bar graphs. The problem is that you have to choose a starting point of the axis, and this is almost always arbitrary. You can choose to make two bars have very different heights, or almost the same height, merely by changing the minimum value on the axis. These three graphs all plot the same data: An alternative ...


11

Charlie provides a nice, correct explanation. The Statistical Computing site at UCLA has some further examples: http://www.ats.ucla.edu/stat/sas/faq/sas_interpret_log.htm , and http://www.ats.ucla.edu/stat/mult_pkg/faq/general/log_transformed_regression.htm Just to compliment Charlie's answer, below are specific interpretations of your examples. As always, ...


9

Some additional ideas: (1) You needn't confine yourself to a logarithmic transformation. Search this site for the "data-transformation" tag, for example. Some data lend themselves well to certain transformations like a root or a logit. (Such transformations--even logs--are usually to be avoided when publishing graphics for a non-technical audience. On ...


9

Yes. Quantiles can be transformed under any monotonically increasing transformation. To see this, suppose $Y$ is the random variable and $q_{0.16}$ is the 16% quantile. Then $$ \text{Pr}(Y\le q_{0.16}) = \text{Pr}(\log(Y)\le\log(q_{0.16})) = 0.16. $$ Generally, if $f$ is monotonic and increasing then $$ \text{Pr}(Y\le q_{\alpha}) = \text{Pr}(f(Y)\le ...


8

In the log-log- model, see that $$\begin{equation*}\beta_1 = \frac{\partial \log(y)}{\partial \log(x)}.\end{equation*}$$ Recall that $$\begin{equation*} \frac{\partial \log(y)}{\partial y} = \frac{1}{y} \end{equation*}$$ or $$\begin{equation*} \partial \log(y) = \frac{\partial y}{y}. \end{equation*}$$ Multiplying this latter formulation by 100 gives the ...


8

You could also use the open source plotting package Gnuplot for this task. The first section of a very readable tutorial here shows how to plot with a log scale.


8

R is good and can be freely downloaded from http://www.r-project.org/ R takes some time to get used to, but here's a simple example ("#" indicates that a comment follows): x <- rnorm(20) # generate a sample of size 20 from N(0,1) y <- 10^x # define y_i = 10^(x_i) for each i=1,...,20 plot(x, y) # plot y vs x plot(x, y, log="y") # plot y vs x with ...


8

Reasons to use logged variables fall into two categories: Statistical and substantive. Statistically, if your variables are right-skew (that is, they have a long tail at the high end) then a measure such as correlation or regression can be influenced a lot by one or a few cases at the high end on one or both variables (outliers, leverage points, influential ...


6

I agree with onestop. You may also find this blog post from Econometrics Beat useful in learning how to interpret the coefficients on dummy variables when the dependent variable is logged: http://davegiles.blogspot.com/2011/03/dummies-for-dummies.html The Cliffs Notes version is that for a model like \begin{equation} \ln(Y) = a + b \cdot \ln(X) + c \cdot ...


6

You tend to take logs of the data when there is a problem with the residuals. For example, if you plot the residuals against a particular covariate and observe an increasing/decreasing pattern (a funnel shape), then a transformation may be appropriate. Non-random residuals usually indicate that your model assumptions are wrong, i.e. non-normal data. Some ...


6

One typically takes the log of an input variable to scale it and change the distribution (e.g. to make it normally distributed). It cannot be done blindly however; you need to be careful when making any scaling to ensure that the results are still interpretable. This is discussed in most introductory statistics texts. You can also read Andrew Gelman's ...


5

For more on whuber's excellent point about reasons to prefer the logarithm to some other transformations such as a root or reciprocal, but focussing on the unique interpretability of the regression coefficients resulting from log-transformation compared to other transformations, see: Oliver N. Keene. The log transformation is special. Statistics in Medicine ...


4

In case you are using LaTeX for your report writing, the package pgfplots can read in data files and plot single or double logarithmic axis. In case you need to do calculations you can escape to gnuplot. It just looks this tiny bit better if your text font matches your axis labels font.


3

I think the more important point is suggested in @whuber's comment. Your whole approach is misfounded because by taking logarithms you effectively are throwing out of the dataset any students with zero missing days in either 2010 or 2011. It sounds like there are enough of these people to be a problem, and I am sure your results will be wrong based on the ...


3

Correlation(pearson) measures a linear relationship between two continuous variables. There is no such choice for (X,Y) or (log X, log Y). Scatter plot of the variables can be used for understanding of the relationship. The following link may answer regarding normality issue. link


3

Isn't the derivative that you want actually $\frac{dy}{dx_{1}}=\frac{300}{x_{1}}-\frac{30}{x_{1}}\ln x_{1}$? Your derivative is the change in $y$ for a small change in $\ln x_{1}$. I think it's probably easier to think about about changing $x_{1}$ on the original (non-logged) scale. That shows that the marginal effect of $x_{1}$ starts out positive for small ...


3

A few quick points about logs The following R code is a reminder that the log of a negative number is not a number and that the log of zero is negative infinity. Thus, if you are going to take a log of a z-score, you first need to make all values obtained greater than zero. > values <- c(-2, -1, 0, .001, .1, 1, 10) > data.frame(values=values, ...


3

If we consider "approximation" in a fairly general sense we can get somewhere. Let's say that $a$ is "approximately normal" (and concentrated near the mean*) in a sense that we can handwave away the concerns about $a$ coming near 0 (and its subsequent impact on the moments of $\log(a)$, because $a$ doesn't 'get down near 0'), but with the same low order ...


2

Can you just use a scale comprised of powers of (1+r) for some small r, and round to the nearest integer? For example, in R, with r = 0.25: > x <- unique(round(1.25^(0:50))) > x [1] 1 2 3 4 5 6 7 9 12 15 18 23 28 36 44 56 69 87 108 136 169 212 265 331 414 [26] 517 646 ...


2

As I understand it, you've generally discretized to create a set of $n$ points, $x_1, \dots, x_n$, with probability $p_1, \dots, p_n$, and you then calculate the cumulative probabilities, say $c_i = \sum_{j=1}^i p_j$. So you can draw $U \sim Uniform(0,1)$ and then take $X = x_{i^*}$ where $i^* = \min_i \{i:c_i \ge U\}$, or something like that. But your ...


2

On normal scale the extreme points would be far from the other point and to fit them on the same curve would either require putting a break on the curve or making the difference in consecutive tick marks large enough to fit everything in. But that would make it very difficult to discern differences between point in the center of the distribution. Using a ...


2

You have forgotten a crucial term in the PDFs: the measure $dx$. Really, $$p(x; \mu, \sigma) = \frac{log_{10}(e)}{x \sigma \sqrt{2 \pi}} e^{-\frac{(log_{10}(x) - \mu)^2}{2 \sigma^2}}\ dx,$$ whence $$\eqalign{ g(y=log_{10}(x); \mu, \sigma) &= \frac{log_{10}(e)}{10^y \sigma \sqrt{2 \pi}} e^{-\frac{(y - \mu)^2}{2 \sigma^2}}\ d(10^y) \\ ...


2

I agree with other respondents, especially with respect to the form of the model. If I understand the motivation of your question, however, you are addressing general audiences and want to convey the substantive (theoretical) meaning of your analysis. For this purpose I compare predicted values (e.g. estimated days missed) under various "scenarios." Based on ...


2

Log-scale informs on relative changes (multiplicative), while linear-scale informs on absolute changes (additive). When do you use each? When you care about relative changes, use the log-scale; when you care about absolute changes, use linear-scale. This is true for distributions, but also for any quantity or changes in quantities. Note, I use the word ...


2

If you assume a model form that is non-linear but can be transformed to a linear model such as $\log Y = \beta_0 + \beta_1t$ then one would be justified in taking logarithms of $Y$ to meet the specified model form. In general whether or not you have causal series , the only time you would be justified or correct in taking the Log of $Y$ is when it can be ...


2

Your model is not identifiable. Consider that if you double $a_1$ and halve $a_2$, or double both $a_0$ and $a_1$ - or many other combinations of increases and decreases, the $Y$ value is unchanged - what could possibly tell you which of an infinite number of possible combinations of $a$'s goes with some particular value of $\frac{Y X_1 X_2}{X_0}$? If you ...


1

If we have the model $Y = bX$, then we might expect that a 1 unit increase of $X$ yields a b unit increase in Y. Instead, if we have $Y = b \log(X)$, then we expect a 1 percent increase in $X$ to yield $b\log(1.01)$ unit increase in Y. Edit: whoops, didn't realize that your dependent variable was also log transformed. Here's a link with a good example ...


1

You cannot assign arbitrary Mean and SD to covert z-score data into Raw data (x). However, you can check a shape of the distribution of z-scores by calculating skewness or kurtosis. Log-transform only useful if you're data is positively skewed. Moreover, it would be good if you explain that what is your objective? as @Karl asked. It might be helpful to visit ...



Only top voted, non community-wiki answers of a minimum length are eligible