1
$\begingroup$

I have a conceptual concern about data tranformation and R^2. Often we transform data to respect the assumption of the linear model. Therefore, we can use multiple type of transformation such as log and square root. When the data contain zero and we find that the log transformation is the most suitable then we need to add a value to be able to transform it in log since log of zero is - Inf.

So we try to add a value that won't affect the result of our relationship. My problem is here that if I had value to my data set, the bigger it is , the higher is the R squared.

Here an example

x<-c(10,20,0,30,40,10,0,1,8,56)
y<-c(5.6,7.3,0,6.5,8.9,0,0.1,2,4.5,10.6)

 modelz<-lm(y~x)
 summary(modelz)

The square root transformation always give a higher R squared. Somebody know why ?( might be a stupid question sorry for that)

 modelzsq<-lm(sqrt(y)~sqrt(x))
 summary(modelzsq)

 modelzlog<-lm(log10(y+0.1)~log10(x+0.1))
 summary(modelzlog)

 modelzlog2<-lm(log10(y+0.05)~log10(x+0.05))
 summary(modelzlog2)

 modelzlog3<-lm(log10(y+0.2)~log10(x+0.2))
 summary(modelzlog3)

So if you notice, the modelzlog3 has a higher R squared than the two other log transform models. Therefore, I think the reason for that is that smaller value when transform in log10 are more negative .

For example log(0.1) give -1 and log(0.01) is -2 . So The bigger is the vaue the closest is the value to the other one (all positive value), this explain why the R squared is higher with bigger value I think...

My question is: I am doing model selection base on AIC but I can't compare different data transform model(see AIC equation...) so do I select model only base on the respect of the assumptions and the biological sense of the transformation ? Like "y" would be rodent density and a value of 0.1 would be the density value when we catch only one rodent so the minimal density that can be obersved.

Thanks a lot for your advice !

Cheers

$\endgroup$
  • $\begingroup$ Why not use the natural logarithm? And then try with log(x+1)... but really one should always avoid such transformations since they are completely arbitrary. There are many questions on this site that has discussion on this topic. I have a given an answer with a reference if you look though my profile. $\endgroup$ – Repmat Feb 9 '16 at 20:48
0
$\begingroup$

Conceptually, you should not be transforming your data, then doing a linear regression. Instead, you should use a member of the generalized linear model (Poisson, gamma, negative binomial, exponential, ...) to perform your regression. The problem is it becomes difficult to obtain $R^2$ with these models, since you seem very interested in $R^2$.

This recent article https://www.tandfonline.com/doi/full/10.1080/00031305.2016.1256839 provides a means for calculating $R^2$ for these models, and the author created a package in R for the same purpose https://cran.r-project.org/web/packages/rsq/index.html.

$\endgroup$
  • 1
    $\begingroup$ There is two philosophies and transforming data is one of them ! $\endgroup$ – Nico Coallier May 27 '17 at 22:46
  • $\begingroup$ Yes, there are two philosophies expressing different modeling techniques. However, more often than not, it is much better to use a generalized linear model. $\endgroup$ – Heteroskedastic Jim May 27 '17 at 23:12
  • 1
    $\begingroup$ Not right , and not always pertinent ! Anyways that is not the topic of the question and there is plaintyyy of book and questions on this topic! $\endgroup$ – Nico Coallier May 28 '17 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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