1
$\begingroup$

I have a dataset that I want to fit according to

$$\log(y) = a + b_1\log(x_1) + b_2\log(x_2) +\cdots + b_k\log(x_k).$$

My statistical package has options to do a linear regression and lognormal. I am not sure which one I should choose.

$\endgroup$
2
  • $\begingroup$ This is not exactly your question, but this thread: interpretation-of-log-transformed-predictor may be helpful in thinking about these issues. $\endgroup$ Commented Mar 29, 2013 at 16:25
  • $\begingroup$ Which package? Otherwise we'd just be guessing what the lognormal one is doing with the x-variables. $\endgroup$
    – Glen_b
    Commented Mar 30, 2013 at 1:12

3 Answers 3

4
$\begingroup$

Probably your best bet is just to form two new variables:

ly = log(y)
lx = log(x)

Then you can use those with a regular linear regression.

$\endgroup$
5
  • $\begingroup$ So I should avoid the lognormal function? $\endgroup$ Commented Mar 29, 2013 at 16:31
  • $\begingroup$ That might be best. $\endgroup$ Commented Mar 29, 2013 at 18:07
  • $\begingroup$ Thanks, gung. However, if I have a lot of independent variables, it can be tedious to log transform each variable before I run the set through the statistical package. $\endgroup$ Commented Mar 29, 2013 at 19:12
  • 3
    $\begingroup$ I don't see why. $\endgroup$ Commented Mar 29, 2013 at 19:13
  • $\begingroup$ Consider the following (in R): N = 30; x = matrix(runif(N*5), ncol=5); y = runif(N); X = cbind(y,x); lX = apply(X, 2, log); (Note that this would scale up to any number of columns.) $\endgroup$ Commented Mar 29, 2013 at 21:06
0
$\begingroup$

Your original model will be non-linear.

$y = cx^b $ $(1)$

If you take the natural log on both sides: $\ln(y) = \ln(c) + b*\ln(x)$ $(2)$

So, in your model: $\ln(c)=a$

You can run equation 1 with lognormal [actually, it should be log linear] [no transformation of variables needed] or you can run equation 2 with linear regression. To implement later, you need to log transform the x and y variables as mentioned by @gung, i.e. $ly=\ln(y)$ and $lx=\ln(x)$ where $lx$ and $ly$ are the new variables created from $x$ and $y$.

Note that you can't run log-normal or log linear if either your $x$ or $y$ has negative values.

$\endgroup$
3
  • $\begingroup$ Thanks. Is lognormal a generalized type of model that includes log-linear? Or is log-linear a type of logit regression? $\endgroup$ Commented Mar 29, 2013 at 19:40
  • $\begingroup$ I am not sure whether there is a term lognormal model. I just know that there exists the term lognormal distribution. if $x$ is a normally distributed then $logx$ is log normally distributed: a logit model is a case where your outcome takes a value of 1 or 0. I assume that your outcome is a continuous variable. $\endgroup$
    – Metrics
    Commented Mar 29, 2013 at 21:12
  • $\begingroup$ @user1493368 You have that backwards: if $x$ is normally distributed, then $e^x$ is log-normally distributed, since $\ln(e^x) = x$ is normal. $\ln x$ for normal $x$ is ill-defined, since you can't take the log of $x \le 0$, which is true with positive probability under the normal model. $\endgroup$
    – Danica
    Commented Mar 30, 2013 at 0:17
-2
$\begingroup$

Transformation of coordinates

Initial form (linear) ln(y) = a + b*ln(x)

with algebra this becomes power y = exp(a)*x^b = A*x^b

So don't choose lognormal, choose to do a linear fit on transformed coordinates.

Some general "good practices"

  • If you aren't sure about your data, or your method then stick to the road "more traveled", the tried and true.
  • If you are going to spend money on a result of an analysis, spend good quality time making sure the quality of the result is compatible with the value of money it is going to inform.

There is a lot of "real world" data that in theory fits either a linear analytic form, but in practice this nearly never happens. Things are almost always more complex. The high value things are always more complex.

EDIT: whuber is right. I am expressing this in Engineering terms. Implicit in my notation is that all the expressions are y_approximation where:

y_true = y_approximation + error

Statistics folks consider it rigor to append an epsilon and explicitly indicate that there is error in the expression. The variable they often use to indicate the error is epsilon.

$\endgroup$
10
  • 4
    $\begingroup$ Your algebra overlooks the terms that are truly crucial to a careful analysis of this problem: the "errors." As such I think this answer misses a key point. $\endgroup$
    – whuber
    Commented Mar 29, 2013 at 19:10
  • 1
    $\begingroup$ Re the edit: Including the errors explicitly is not merely a matter of convention, taste, or technical rigor. The reason you need to write them down is that doing so will clearly show where you have made an algebraic mistake in your reasoning. (The transformed model does not have the additive error structure you claim it does.) $\endgroup$
    – whuber
    Commented Apr 2, 2013 at 17:59
  • $\begingroup$ I am suggesting that when I say " y = Ax^b" what I mean is "y_approximation = Ax^b". I am exactly correct when saying what I meant, and in fact am the best person to say what it was that I meant. This is the difference between "Implicit" and "Explicit" because I am saying what the norm was that I was following. Would you mind explicitly articulating what would be required for an answer that did not miss your key point? $\endgroup$ Commented Apr 4, 2013 at 23:59
  • 1
    $\begingroup$ "Mistake in your reasoning" did not refer to the faithfulness with which you expressed what you meant, but rather to the incorrectness of your answer. Upon exponentiation, $\log(y)=a+b\log(x)+\varepsilon$ becomes $y=A x^b \exp(\varepsilon)$ which does not have the structure of "$y = A x^b + \text{error}$." I hope it is clear to you how the two models differ. The "key point" to which I referred is this awareness that statistical models, by their vary nature, must represent variability, and that ignoring the variability leads to mistakes, paradoxes, and errors of all sorts. $\endgroup$
    – whuber
    Commented Apr 5, 2013 at 12:34
  • $\begingroup$ Thank you. This is a good thought. The error is not in the domain, but the range. Typically the x-values are known nearly perfectly. The values known/measured are the "x" and "y" and not the "true model" if such a thing exists. Shouldn't the errors be applied as additive to them? log(y+epsilon) = a + b*log(x) $\endgroup$ Commented Apr 5, 2013 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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