Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a variable that can range from -100 to +100. When the number is -100, the output from this transformation should be something like 10. For +100 it should be around -10, and for 0 it should be 0. However, the points in between may be skewed so that the value for 1 is not necessarily .1, it may be 2 or .05.

What formula or transform should I use when putting this variable into a linear model for R? I feel like there's a sqrt or log involved but negative values are no good. There are many options, what's the best?

I'm looking for something like: $$y = B_1(x_1) + B_2(x_2) + B_3(transform(x_3))\\$$

I'd like the B3 to be able to tell me the skewness of the variable.

share|improve this question
From your description, it looks like y = -0.1x, so no transformation needed. Or have I misunderstood? – Jeremy Miles May 9 '14 at 0:24
When you say "output from this model" do you mean "result of this transformation"? – Glen_b May 9 '14 at 2:19
Wouldn't output of the model be $y$? In any case, the purpose of the transformation is completely unclear. – Nick Stauner May 9 '14 at 4:49
The only reason for using a nonlinear transformation would be to make the relationship between $x_3$ and $y$ more linear than it is: that is, to correct lack of a good fit. (And that indicates where to look for solutions: separately regress $x_3$ and $y$ against the other variables and study the relationship between their residuals with, say, a scatterplot.) $B_3$ is going to tell you little or nothing about the skewness of the distribution of $x_3$. – whuber May 9 '14 at 14:03

There are any number of smooth transformations which go through those three points.

Here are three examples:

enter image description here

The most obvious, as Jeremy points out in comments, is a simple linear transformation (blue in my plot above).

The red one involves a square root function (but is more complicated), and the green one involves a quadratic (it's quadratic to the left and right, but they're different quadratics which join smoothly). There's an infinite number of other functions you might choose.

We can't tell you what's best for your purposes unless you define 'best' in very specific terms.

Can you explain what properties you need to have in between the specified points?

share|improve this answer
This is so close to what I want. How do I make the B3 the variable which slides points from the green to blue to red line to show me which curve is the best fit. – Ricky May 9 '14 at 13:50
You're confounding the transformation of $x_3$ with the fitting to $y$. What you currently have is a linear regression (specify a transformation, fit a linear model to the transformed predictor). Choosing a transformation on the basis of the data would require an additional parameter, one that indexed the power in the transformation, effectively making it a nonlinear regression. You're looking at a model like $E(y) = \beta_1 x_1 + \beta_2 x_2 + \beta_3g(x_3,\beta_4)$. This makes it a very different kind of question. I think it would be best posted as a new question with a link back to this one – Glen_b May 9 '14 at 21:20
Alternatively, instead of marking this one as answered and asking a new one, you could edit your question here (fairly heavily), and mention to me you did so, and I'd need to edit my answer to write a new answer to a pretty different question. Personally, I'd prefer the first approach but I can work either way. – Glen_b May 9 '14 at 21:24
If you want to keep it as a linear fit, I'd stick with whuber's suggestion earlier. – Glen_b May 9 '14 at 21:53
I think I need to use a x + x^2 + x^3 but I have to figure out a way to incorporate an inverse of the cube (to produce the red line) for negative numbers. I'll post that as a new question. Thanks for pointing me in the right direction. – Ricky May 9 '14 at 22:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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