I am relatively new to R and I am interested in performing a Box-Cox transformation. However, I am a little lost as to the step-by-step process of doing this. I have been searching the web for a number of days and have tried various code to no avail.

Overall, within my dataset (data=fw) I want to test for differences in a dependent variable (x) between between two locations (north and south). However, my data is not normally distributed and has unequal variance. Therefore, I need to transform my data (log and square root have not worked). Is the 'MASS' package the only package that I need to use to perform the Box-Cox transformation, or do I need some others? Any advice on the step-by-step process on Box-Cox transformation of the data would be much appreciated.


closed as off-topic by Andy, kjetil b halvorsen, Scortchi, Xi'an, gung Jan 19 '15 at 13:57

  • This question does not appear to be about statistics within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Read the manual ?boxcox, & see Faraway (2002), Practical Regression and Anova using R, Ch.8 for some examples. $\endgroup$ – Scortchi Jan 19 '15 at 10:40
  • 2
    $\begingroup$ Your data need NOT necessarily be normal to apply a model. Only your residual from the model should be normal. even if your residual are non normal, This could be caused by outliers and other anomalies. Even after correcting for outliers if your residuals are non normal then you could use an appropriate box-cox transformation. $\endgroup$ – forecaster Jan 19 '15 at 11:37
  • $\begingroup$ I think this may be off-topic because it is about how to use R without a reproducible example. $\endgroup$ – gung Jan 19 '15 at 13:57

First, I would review some introductory resources on data transformations, in general, and on Box-Cox transformation, in particular. For example, see my relevant answer and this webpage.

For more details on performing Box-Cox transformation in R, check this excellent discussion. In addition to MASS package, some other R packages can be used for Box-Cox transformation, also consider using car package, which offers several types of power transformations and somewhat more general than in MASS functions, for example this one.

In regard to selecting the optimal parameter for the transformation, see this answer on StackOverflow as well as the AID R package (see page on CRAN).


You can use function "preProcess" of caret package for univariate CB transformation and "bcPower" function of "car" package for multivariate CB transformation. Regards, Jüri.


We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

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