简体   繁体   中英

Standardized regression coefficients, need to extract one from the table

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)

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM