3
$\begingroup$

I have 2 variables which I want to put as predictor (independent) variables in logistic regression. However, both on them are highly skewed (one on left and other on right). Also, both variables are actually ordinal (values of 1,2,3 and 4).

I am using following code to correct skewness with BoxCox transformation:

import scipy
df[feature] = scipy.stats.boxcox(df[feature])[0]

Following figures show histograms of 2 variables before and after transformation:

enter image description here

The skewness does not seem to have corrected very much. What are my options now? Can I safely use these variables in logistic regression to get reliable results or do I need to apply some other transformation? Is any particular method recommended for ordinal variables? Thanks for your insight.

$\endgroup$
3
  • 1
    $\begingroup$ 1) If you are about to treat your predictors as ordinal why are you doing Box-Cox transform which is for interval data? 2) Why skewness in predictors bothers you - you did not explain it in the Q? 3) The Box-Cox on your picture considerably lessened the skewness; it may seem not apparent visually because your data are so discrete-like, with gaps. But note that two smaller bars have become close to each other - so if you collapse them together into one bar you will see the effect. $\endgroup$
    – ttnphns
    Commented Jul 13, 2020 at 14:15
  • 1
    $\begingroup$ Box-Cox transformations indeed can be used to create a distribution with a zero skewness coefficient: but that is neither their intended purpose nor is it the mathematical objective used to estimate the Box-Cox parameter. The utility of transforming ordinal data arises from how it can simplify the relationship between that variable and other variables. It appears you have estimated the parameter without reference to any other variable, but that would make this a meaningless exercise. $\endgroup$
    – whuber
    Commented Jul 13, 2020 at 14:27
  • $\begingroup$ I am trying to understand these important comments. So there is no need to transform variables before entering them into logistic or linear regression? $\endgroup$
    – rnso
    Commented Jul 13, 2020 at 14:52

1 Answer 1

5
$\begingroup$

After going through comments by @ttnphns and @whuber and also other sites such as Regression: Transforming Variables , https://data.library.virginia.edu/normality-assumption/ and https://www.theanalysisfactor.com/the-distribution-of-independent-variables-in-regression-models/ , I realize that:

  1. There is no need to transform any predictor variable in regression unless residuals are not normally distributed.

  2. The effect of Box-Cox should be seen on the residual distribution, not on the variable itself.

  3. Box-Cox transformation is for interval data, not for ordinal, though it works there also to some extent.

$\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.