0
$\begingroup$

I am looking for a method to transform a variable ($Y_{old}$) into a new variable ($Y_{new}$) with a target median ($Median_{new}$) and IQR ($IQR_{new}$).

The following transformation seems to work, but I don't understand why. Can anyone provide a mathematical explanation?

$Y_{new} = Median_{new} + (Y_{old} - Median_{old})*(IQR_{new}/IQR_{old})$

$\endgroup$
1
  • 1
    $\begingroup$ Note that your equation is simply a rearrangement of: $\frac{Y_\text{new}-\tilde{Y}_\text{new}}{q_\text{new}}=\frac{Y_\text{old}-\tilde{Y}_\text{old}}{q_\text{old}}$ (where $\tilde{Y}$ denoted the median and $q$ denotes the interquartile range). That is you are equating a standardized version of the new and the old variables, so that corresponding values are each the same number of IQRs from the median. $\endgroup$
    – Glen_b
    Jun 24 '17 at 0:49
1
$\begingroup$

First, suppose $Y^{(1)}_{old}<Y^{(2)}_{old}$. If $f$ is the transformation, then $$f(Y^{(2)}_{old})-f(Y^{(1)}_{old})=(Y^{(2)}_{old}-Y^{(1)}_{old})*(IQR_{new}/IQR_{old})>0$$ and so $f(Y^{(1)}_{old})<f(Y^{(2)}_{old})$ and so the transformation preserves the order of observations. This is important since it means if $Y$ is the $n$th quartile before the transformation, then $f(Y)$ is the $n$th quartile after the transformation.

Now observe that $$f(Median_{old})=Median_{new}-(Median_{old}-Median_{new})*(IQR_{new}/IQR_{old})$$ $$=Median_{new}$$ Similarly, if $Q_{1}$ and $Q_3$ are the old 1st and 3rd quartiles, you can show that $IQR_{new}=f(Q_3)-f(Q_1)$.

$\endgroup$

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.