-2

I'm stuck in using R. In a simple linear regression;

y=a+b_1*x

I wanna know how much increase or decrease when one standard deviation of Independent Variable increases in R.

Do you know the way how to do it by using sapply() syntax?

neilfws
  • 32,751
  • 5
  • 50
  • 63
Key
  • 1
  • You would get this from `coef(lm(y ~ x, data = data))`. – zephryl Nov 18 '22 at 03:44
  • I did it already, but I wanna know "how much change the dependent variable when one unit of Standard Deviation increases. – Key Nov 18 '22 at 03:58

2 Answers2

0

Scale your explanatory variable by the inverse of its standard deviation and re-run your model. Then a 1-unit increase of the scaled explanatory variable equals a 1-SD increase of the unscaled one.

You can also have a look at these two packages:

...or just multiply the coefficient from the unscaled model by the standard deviation, of course.

dufei
  • 2,166
  • 1
  • 7
  • 18
0

Using the marginaleffects package – as suggested by @dufei – you can do:

library(marginaleffects)

mod <- lm(mpg ~ hp, data = mtcars)
cmp <- comparisons(mod, variables = list(hp = "sd"))
summary(cmp)

      Term                Contrast Effect Std. Error z value  Pr(>|z|)  2.5 %
    1   hp (x + sd/2) - (x - sd/2) -4.678     0.6938  -6.742 1.558e-11 -6.038
      97.5 %
    1 -3.318

    Model type:  lm 
    Prediction type:  response 

Disclaimer: I am the author of marginaleffects.

Vincent
  • 15,809
  • 7
  • 37
  • 39
  • Thanks. The example that you explained is that; half of Stdev increase makes a decrease amount of (-4.678)/2. Correct? – Key Nov 18 '22 at 22:27
  • Cause I wanna know how 1 Standard Deviation increase of the independent variable decreases the dependent variable. – Key Nov 18 '22 at 22:31
  • no, this is one standard deviation: half each side of the observed value. – Vincent Nov 19 '22 at 00:13
  • Okay, then how about I wanna know "just increase 1 standard deviation from mean on the right side?(not both positive and negative way). And it is not a normally distributed. – Key Nov 19 '22 at 00:25
  • Please read the documentation for `?comparisons`. The `variables` argument allows you to do a bunch of things, including specifying your own values. – Vincent Nov 19 '22 at 00:47