6
$\begingroup$

I have some bimodal data like the one generated down (R language), and I don't know how to transform it to have a normal distribution or homoscedasticity. I'm running a linear discriminant analysis and I need homoscedasticity, but I'm not able to get it with this kind of distribution. Do you have an alternative to this problem?

Generating fake data

x = rnorm(100, mean = 10, sd = 2)
y = rnorm(100, mean = 20, sd = 2)
bimodal =c(x,y)
shapiro.test(bimodal)
hist(bimodal)

Transformation with Box-Cox

library(geoR)
lambda=boxcoxfit(bimodal)$lambda
bin.tr.bc=((bimodal^lambda)-1)/(lambda)

shapiro.test(bin.tr.bc)
hist(bin.tr.bc)

Log

shapiro.test(log(bimodal))
hist(log(bimodal))

Square root

shapiro.test(sqrt(bimodal))
hist(sqrt(bimodal))

Log squared

shapiro.test((log(bimodal))^2)
hist((log(bimodal))^2)

log exponent 1.5

shapiro.test((log(bimodal))^1.5)
hist((log(bimodal))^1.5)

Cube root

shapiro.test((bimodal)^(1/3))
hist((bimodal)^(1/3))

Desperate arcsin complex transformation

shapiro.test(asin((bimodal/max(bimodal))^(1/2)))
hist(asin((bimodal/max(bimodal))^(1/2)))
$\endgroup$
2
  • $\begingroup$ I thought that for any discrimination analysis you would want the opposite of unimodality: bimodality is one indication that a simple discrimination function is likely to work well! $\endgroup$
    – whuber
    Commented Apr 25, 2016 at 21:41
  • $\begingroup$ That sounds right! Haha. But then, is there a way to make the data more homoscedastic? $\endgroup$ Commented Apr 25, 2016 at 23:17

2 Answers 2

6
$\begingroup$

Your variable binomial is not binomial. Did you mean bimodal?

Try this:

transformed <- abs(binomial - mean(binomial))
shapiro.test(transformed)
hist(transformed)

which produces something close to a slightly censored normal distribution and (depending on your seed)

        Shapiro-Wilk normality test

data:  transformed
W = 0.98961, p-value = 0.1564

enter image description here

In general, arbitrary transformations are difficult to justify. You need a reason for doing this sort of thing, independent of the actual data

$\endgroup$
5
  • $\begingroup$ You're right, it's bimodal. The thing is that I want to predict new value with my linear discriminant analysis (LDA). So it's not possible to run something that calculates the mean. For example, if i'm putting log(oxygen) in my model, then I can calculate log(new_oxygen_value) and feed it to my model so that I know to which group it's belonging. $\endgroup$ Commented Apr 25, 2016 at 20:42
  • $\begingroup$ @M.Beausoleil - in that case you really do not want to remove the bimodality, as it will reduce the discrimination of your analysis $\endgroup$
    – Henry
    Commented Apr 25, 2016 at 20:51
  • $\begingroup$ The problem in my data is that it's not homoscedastic. So I'd like to apply something to make it homoscedastic and use the LDA. Beside normalization, I don't know what could be possible... $\endgroup$ Commented Apr 25, 2016 at 23:09
  • $\begingroup$ @Henry What was the intuition behind abs(binomial - mean(binomial)) ? How did you figure that out? Is it a standard method or adhoc ? $\endgroup$
    – talegari
    Commented Sep 6, 2017 at 7:23
  • 3
    $\begingroup$ @talegari: it is not a standard transformation, but looking at the mixture distribution, it was a simple way in this case of superimposing the two modes to make a single mode. It would not have worked so well if there there had been differing numbers of observations from the two original normals or if they had had different standard deviations $\endgroup$
    – Henry
    Commented Sep 6, 2017 at 8:09
0
$\begingroup$

No monotonic transformation can do what you wish and a non-monotonic transformation is usually a bad idea. Typically, you should model the bimodality either empirically or with a mixture model.

For example, place a point into the left lobe or right lobe with an indicator variable as though two processes are generating two different distributions but you can only see the combined result. Without knowing more about your problem, I don't have any more particular suggestions.

$\endgroup$

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.