Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

How can I fit a logarithmic regression equation of form $y=a+b (\log (x_1)) + c(\log(x_2))$ on a data set using R?

Here the main concern is that data contain zeros multiple times, so R will give infinity in the output.

I have tried adding some constant to the $x$ variables, such as log(x1+0.00001) to avoid Inf but

Is there any specific way to calculate this constant so that results are not affected?

https://dl.dropbox.com/u/53624395/11.csv : LINK FOR DATA FILE ON WHICH I WANT TO PERFORM THE OPERATION.This is time series data and i have to perform logarithmic regression of form y=a+b(logx1)+c(logx2). and find a,b,c and then check is there any such type of relation exists or not.

share|improve this question

closed as off topic by whuber Jan 11 '13 at 15:45

Questions on Cross Validated are expected to relate to statistics within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Why are you transforming the predictors? –  Macro Jan 10 '13 at 4:43
2  
Of course results are affected by any change to the transformation. 'Not affected' compared to what? What are you seeking to achieve? Why are you taking logs of something that can be zero? –  Glen_b Jan 10 '13 at 6:38
    
Any statistical package should give infinity. Try remove zeros from your data before modelling. –  mpiktas Jan 10 '13 at 8:08
2  
Very closely related: stats.stackexchange.com/questions/30728/…. –  whuber Jan 10 '13 at 13:55
1  
@whuber: Okies I have flagged this question for transferring it to stackoverflow. :) thank you. :) –  Komal Jan 11 '13 at 15:43

1 Answer 1

  1. You can shift your data ( $x_i\mapsto x_i+\mathrm{constant}_i $)

  2. You can try and do $y= a + b \log\left(\frac{x_1}{x_2}\right) $ or similar, you can use a sort of Laplace smoothing in this case $y= a + b * \log\left(\frac{x_1+1}{x_2+1}\right) $

  3. You can weight your data such that you kind of kill the very high ones, you can use $t\mapsto e^{-\frac{1}{t}}$ as weight for example.

  4. ...etc

It would be easier if you have a data example I guess .. But then it is ups to you to have a play around and see what suits you the best!

share|improve this answer
    
Presumably the subscript $i$ on the constant is a typo. –  Scortchi Jan 10 '13 at 12:14
    
I meant $x1 \mapsto x1+ c_1$ where $c_1$ is a shift for every single component of $x_1$ and same for $x_2$ –  DKK Jan 10 '13 at 12:35
    
Of course, I didn't read carefully enough –  Scortchi Jan 10 '13 at 12:59
    
DATA ON WHICH IT IS TO PERFORMED This is time series data and i have to perform logarithmic regression of form y=a+b(logx1)+c(logx2). and find a,b,c and then check is there any such type of relation exists or not. –  Komal Jan 11 '13 at 5:25

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