I have two datasets that are both organised as follows: an algorithm calculated a quality score (Q) of a specific image (image) that was processed using a certain algorithm (method). One has 315 observations, the other 2709. I first tried applying a simple linear regression model, only looking at method as a possible predictor, and looked at the QQ-plot.

fd <- lm(q ~ method, data=data)

QQ-plot for lm

I decided that the residuals did not follow a normal distribution. I then tried a Box-Cox transformation to fix the issue. The new model showed this QQ-plot:

bc <- boxcox(data_drim$q ~ data_drim$method)
(lambda <- bc$x[which.max(bc$y)])
powerTransform <- function(y, lambda1, lambda2 = NULL, method = "boxcox") {

  boxcoxTrans <- function(x, lam1, lam2 = NULL) {

    # if we set lambda2 to zero, it becomes the one parameter transformation
    lam2 <- ifelse(is.null(lam2), 0, lam2)

    if (lam1 == 0L) {
      log(y + lam2)
    } else {
      (((y + lam2)^lam1) - 1) / lam1

         , boxcox = boxcoxTrans(y, lambda1, lambda2)
         , tukey = y^lambda1

# re-run with transformation
fd_bc <- lm(powerTransform(data_drim$q, lambda) ~ data_drim$method)

QQ-plot for new lm

I wasn't convinced yet, so I went with a non-parametric test instead: the Kruskal-Wallis test. I followed this up with paired comparison tests (Wilcoxon with BH correction).

My questions:

  1. Is this a good approach, given the results with the linear models? I read that you can ignore the normality assumption safely due to the central limit theorem once the number of observations surpasses 200, but I figured that was a 'per condition' number (or is it?), so I didn't go that way.

  2. Suppose I now want to investigate the interaction between different images and the method used. That's not something I can do with Kruskal-Wallis. I could have done that with a (g)lm, but I'm not sure how to go about that using non-parametric methods (if that is indeed what I should be doing).


First, I'm not a fan of transforming variables to meet statistical criteria. This used to be necessary, but the advent of fast computers and good software has made it unnecessary. So, I like going non-parametric.

Second, there are a variety of methods of non-parametric regression. Depending on exactly what you are trying to find out, you might consider:

  • Quantile regression
  • Robust regression of various sorts
  • Trees and their offspring like forests
  • Spline regression or MARS
  • Generalized additive models

or something I'm not thinking of at the moment.

  • 1
    $\begingroup$ Hi Peter, thanks a lot for your answer. I'm currently looking into quantile regression on the median. I get results that are along the lines of my earlier Kruskal-Wallis test (and follow-up comparisons), so that looks alright. Thanks! $\endgroup$ – Inkidu616 Nov 6 '18 at 12:48

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.