0
$\begingroup$

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.

$\endgroup$
4
  • 2
    $\begingroup$ From your description, it looks like y = -0.1x, so no transformation needed. Or have I misunderstood? $\endgroup$ May 9, 2014 at 0:24
  • 1
    $\begingroup$ When you say "output from this model" do you mean "result of this transformation"? $\endgroup$
    – Glen_b
    May 9, 2014 at 2:19
  • 1
    $\begingroup$ Wouldn't output of the model be $y$? In any case, the purpose of the transformation is completely unclear. $\endgroup$ May 9, 2014 at 4:49
  • $\begingroup$ 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$. $\endgroup$
    – whuber
    May 9, 2014 at 14:03

1 Answer 1

5
$\begingroup$

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?

$\endgroup$
7
  • $\begingroup$ 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. $\endgroup$
    – Ricky Sahu
    May 9, 2014 at 13:50
  • $\begingroup$ 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 $\endgroup$
    – Glen_b
    May 9, 2014 at 21:20
  • $\begingroup$ 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. $\endgroup$
    – Glen_b
    May 9, 2014 at 21:24
  • $\begingroup$ If you want to keep it as a linear fit, I'd stick with whuber's suggestion earlier. $\endgroup$
    – Glen_b
    May 9, 2014 at 21:53
  • $\begingroup$ 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. $\endgroup$
    – Ricky Sahu
    May 9, 2014 at 22:04

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.