Transformations that earn their keep
Today let's find out which transformation of a skewed outcome is actually worth using, and which one only looks like it helps.
Here are 36 small online stores. For each one you have two numbers: how much it spent on ads last month, from \$560 up to \$8,910, and how much it made in sales that same month, from \$2,724 up to \$78,668. Plot ad spend against sales and this is what you get.
Most stores sit low and bunched close together, but a handful run far higher than the rest, a shape that is going to give an ordinary straight line some trouble.
A skewed outcome and what it does to an ordinary fit
Fit an ordinary straight line through ad spend and sales, and check two things: how well it fits, and how skewed its leftovers are.
The fit says sales equals 6435.58 plus 2.389 times ad spend: every extra dollar of ad spend adds 2.389 dollars to the line's prediction. But the R-squared is only 0.153, so this line explains just 15.3% of how sales vary across the 36 stores. That is a poor fit.
A residual is the gap between what a store actually made in sales and what the fitted line predicts for it. skew() above computes skewness from its definition: it averages the cubed distance of each value from the mean, then divides by the standard deviation cubed so the result does not depend on the scale the data happens to be measured in.
Skewness is a single number that says how lopsided a set of values is around its average. A value of 0 means the values spread out evenly on both sides, the shape of a symmetric bell. A large positive number means a long tail stretching out to the right: most values sit low and close together, but a few sit far above the rest, exactly the shape the plot showed a moment ago.
Skewness of sales comes out to 2.22, confirming that long right tail. And the residuals left over after fitting the line carry nearly the same skew, 2.29. The line is not just missing some variation. It is missing it in a lopsided way, undershooting the handful of big stores far more than it undershoots the small ones.
This matters because a fit whose residuals are this skewed cannot be trusted to give an even, well behaved estimate of how ad spend relates to sales. Something about the scale sales is measured on is working against the fit.