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.

  • 1
    $\begingroup$ Read the manual ?boxcox, & see Faraway (2002), Practical Regression and Anova using R, Ch.8 for some examples. $\endgroup$ – Scortchi - Reinstate Monica 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 - Reinstate Monica 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.


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