Home > Enterprise >  Standardized regression coefficients, need to extract one from the table
Standardized regression coefficients, need to extract one from the table

Time:10-04

I'm trying to extract 1/4 standardized regression coefficients using lm.beta, and hitting a snag. Usually I would just code model$coefficients[x], but I have always been pulling unstandardized coefficients before. For some reason, it does not appear to work on the standardized version. I am getting all kinds of weird results. Is there another way to do this? Sorry if this is a dumb question, but I am confused as to why this would be a problem. Below is the code chunk. It's just a standardized regression table, and I need one value.

top_dog=lm.beta(new_lreg)

CodePudding user response:

Fitting Regression And Getting Betas

You didn't provide data (I advise doing that next time) but I have used the iris dataset native to R to show you how it can be done. First fit a regression:

#### Run Iris Regression ####
iris.lm <- lm(Petal.Length ~ Sepal.Width   Sepal.Length,
              data = iris)

Then save the betas as an object:

#### Save Betas as Object ####
beta.iris <- lm.beta::lm.beta(iris.lm)

Printing Beta Coefficients

You can call the coefficients this way:

#### Call Them ####
beta.iris$standardized.coefficients

Which will give you this printout:

 (Intercept)  Sepal.Width Sepal.Length 
          NA   -0.3305168    0.8328950

If you want a specific coefficient you do so like this:

#### Select Which ####
beta.iris$standardized.coefficients[2]

Which will give you the Sepal.Width beta:

Sepal.Width 
 -0.3305168 
  •  Tags:  
  • r
  • Related