Title: | Add Standardized Regression Coefficients to Linear-Model-Objects |
---|---|
Description: | Adds standardized regression coefficients to objects created by 'lm'. Also extends the S3 methods 'print', 'summary' and 'coef' with additional boolean argument 'standardized' and provides 'xtable'-support. |
Authors: | Stefan Behrendt [aut, cre] |
Maintainer: | Stefan Behrendt <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.7-2 |
Built: | 2024-10-24 06:33:25 UTC |
Source: | CRAN |
lm
-Objects
Adds standardized regression coefficients to objects created by lm
.
Also extends the S3 methods print
, summary
and coef
with additional boolean argument standardized and provides xtable
-support.
Please regard:
Package lm.beta
works in the way of common statistical softwares like SPSS by standardizing the coefficients after estimating them using the standard deviations or similar measures of the used variables. So there are unstandardized and standardized coefficients available simultaneously.
Standardizing before estimating is not (yet) available in this package, but by using the command scale
you can do this by using basic commands. Hereby please regard that the option center
influences the way of interpretation of the intercept.
Package lm.beta
standardizes all coefficients disregarding the use in interpretation. In this version, all types of scales of the variables (metrical, categorical, ...), all types of contrasts, interaction effects and additional terms on both sides of the formula can be handled if lm
can handle them. The sensitive use in interpretation has to be regarded by the user.
Package: | lm.beta |
Type: | Package |
Version: | 1.7-2 |
Date: | 2023-03-12 |
License: | GPL(>=3) |
Stefan Behrendt <[email protected]>
Urban, D., Mayerl, J., Sackmann, R. (Hrsg.) Regressionsanalyse : Theorie, Technik und Anwendung, VS-Verlag, 4. Aufl.
Vittinghoff, E. et al (2005) Regression methods in biostatistics: Linear, logistic, survival, and repeated measures models, Springer, p 75
## Taken from lm help ## ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". ## Page 9: Plant Weight Data. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~ group) # standardize lm.D9.beta <- lm.beta(lm.D9) print(lm.D9.beta) summary(lm.D9.beta) coef(lm.D9.beta) xtable::xtable(lm.D9.beta)
## Taken from lm help ## ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". ## Page 9: Plant Weight Data. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~ group) # standardize lm.D9.beta <- lm.beta(lm.D9) print(lm.D9.beta) summary(lm.D9.beta) coef(lm.D9.beta) xtable::xtable(lm.D9.beta)
S3-method coef
for object lm.beta
.
## S3 method for class 'lm.beta' coef(object, standardized = TRUE, ...)
## S3 method for class 'lm.beta' coef(object, standardized = TRUE, ...)
object |
An R object of class |
standardized |
Logical. Should the standardized values be returned? |
... |
additional arguments. (Currently ignored.) |
If standardized=FALSE
, the unstandardized regression coefficients are printed like if calling standard coef.lm
-method, else (the standard value) the standardized regression coefficients are printed.
named numeric Vector of (un)standardized regression coefficients.
Stefan Behrendt, [email protected]
lm.beta
for creating the lm.beta
-object.
## Taken from lm help ## ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". ## Page 9: Plant Weight Data. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~ group) # standardize lm.D9.beta <- lm.beta(lm.D9) coef(lm.D9.beta) coef(lm.D9.beta,standardized=FALSE)
## Taken from lm help ## ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". ## Page 9: Plant Weight Data. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~ group) # standardize lm.D9.beta <- lm.beta(lm.D9) coef(lm.D9.beta) coef(lm.D9.beta,standardized=FALSE)
Adds standardized regression coefficients to objects created by lm
.
lm.beta(object, complete.standardization = FALSE)
lm.beta(object, complete.standardization = FALSE)
object |
An R object of type |
complete.standardization |
Logical. (See Details.) |
Calculates the standardized regression coefficients by common method used for example in SPSS. For translating the formula, functions model.matrix
(for the right-hand side) and model.frame
(for the left-hand side) are used. Additionally the case weights are regarded. So all options saved in the lm
-object are supported.
In the case of models with intercept, the standardization results in the same estimates as lm(..., data = scale(data))
.
In the case of models without intercept, there are two different types of standardization available. (1) Complete standardization (complete.standardization = TRUE
) results in the same estimates as lm(..., data = scale(data))
and therefore results in the same estimates as the same model with intercept. (2) Incomplete standardization (complete.standardization = FALSE
, the standard value) results in the same estimates as lm(..., data = scale(data, center = FALSE))
. This estimation is implemented in IBM SPSS Statistics. For a theoretical justification see Eisenhauer 2003.
Please regard:
Package lm.beta
standardizes the coefficients after estimating them using the standard deviations or similar measures of the used variables. So there are unstandardized and standardized coefficients available simultaneously.
Standardizing before estimating is not (yet) available in this package, but by using the function scale
you can do this by using basic commands. Hereby please regard that the option center
influences the way of interpretation of the intercept.
Package lm.beta
standardizes all coefficients disregarding the use in interpretation. In this version, all types of scales of the variables (metrical, categorical, ...), all types of contrasts, interaction effects and additional terms on both sides of the formula can be handled if lm
can handle them. The sensitive use in interpretation has to be regarded by the user.
A list of class lm.beta
like a lm
-object extended by
standardized.coefficients named vector of the standardized coefficients.
Some S3 methods, where standardized coefficients mind, are extended, the others work unchanged.
Stefan Behrendt, [email protected]
Eisenhauer, J.G. (2003). Regression through the Origin. In Teching Statistics, 25(3).
Urban, D., Mayerl, J., Sackmann, R. (Hrsg.) Regressionsanalyse : Theorie, Technik und Anwendung. VS-Verlag, 4th ed.
Vittinghoff, E. et al (2005) Regression methods in biostatistics: Linear, logistic, survival, and repeated measures models, Springer, p 75
lm
for creating the demanded object and print.lm.beta
, summary.lm.beta
and coef.lm.beta
as well as xtable.lm.beta
for extended S3-methods.
## Taken from lm help ## ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". ## Page 9: Plant Weight Data. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~ group) # standardize lm.D9.beta <- lm.beta(lm.D9) print(lm.D9.beta) summary(lm.D9.beta) coef(lm.D9.beta) xtable::xtable(lm.D9.beta)
## Taken from lm help ## ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". ## Page 9: Plant Weight Data. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~ group) # standardize lm.D9.beta <- lm.beta(lm.D9) print(lm.D9.beta) summary(lm.D9.beta) coef(lm.D9.beta) xtable::xtable(lm.D9.beta)
S3-method print
for object lm.beta
.
## S3 method for class 'lm.beta' print(x, standardized = TRUE, ...)
## S3 method for class 'lm.beta' print(x, standardized = TRUE, ...)
x |
An R object of class |
standardized |
Logical. Should the standardized values be printed? |
... |
Additional arguments to pass to |
If standardized=FALSE
, the standard print.lm
-method is called, else (the standard value) the regression coefficients are replaced by the standardized ones.
The additional arguments are in case of standardized=FALSE
passed to print.lm
, else they are passed to print
for classes call
and vector
.
Original object.
Stefan Behrendt, [email protected]
lm.beta
for creating the lm.beta
-object.
## Taken from lm help ## ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". ## Page 9: Plant Weight Data. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~ group) # standardize lm.D9.beta <- lm.beta(lm.D9) print(lm.D9.beta) print(lm.D9.beta,standardized=FALSE)
## Taken from lm help ## ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". ## Page 9: Plant Weight Data. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~ group) # standardize lm.D9.beta <- lm.beta(lm.D9) print(lm.D9.beta) print(lm.D9.beta,standardized=FALSE)
S3-method summary
for object lm.beta
.
## S3 method for class 'lm.beta' summary(object, standardized = TRUE, ...)
## S3 method for class 'lm.beta' summary(object, standardized = TRUE, ...)
object |
An R object of class |
standardized |
Logical. Should the standardized values be integrated? |
... |
Additional arguments to pass to |
If standardized=FALSE
, the standard summary.lm
-method is called, else (the standard value) the standardized regression coefficients are added into the coefficient table.
The additional arguments are passed to summary.lm
.
Adapted summary.lm
-object, in case of standardized=TRUE
with additional class summary.lm.beta
.
Stefan Behrendt, [email protected]
lm.beta
for creating the lm.beta
-object.
## Taken from lm help ## ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". ## Page 9: Plant Weight Data. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~ group) # standardize lm.D9.beta <- lm.beta(lm.D9) summary(lm.D9.beta) summary(lm.D9.beta,standardized=FALSE)
## Taken from lm help ## ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". ## Page 9: Plant Weight Data. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~ group) # standardize lm.D9.beta <- lm.beta(lm.D9) summary(lm.D9.beta) summary(lm.D9.beta,standardized=FALSE)
S3-method xtable
for object lm.beta
and summary.lm.beta
.
## S3 method for class 'lm.beta' xtable(x, caption = NULL, label = NULL, align = NULL, digits = NULL, display = NULL, auto = FALSE, ...) ## S3 method for class 'summary.lm.beta' xtable(x, caption = NULL, label = NULL, align = NULL, digits = NULL, display = NULL, auto = FALSE, ...)
## S3 method for class 'lm.beta' xtable(x, caption = NULL, label = NULL, align = NULL, digits = NULL, display = NULL, auto = FALSE, ...) ## S3 method for class 'summary.lm.beta' xtable(x, caption = NULL, label = NULL, align = NULL, digits = NULL, display = NULL, auto = FALSE, ...)
x |
An R object of class 'lm.beta' or 'summary.lm.beta'. |
caption |
see |
label |
see |
align |
see |
digits |
see |
display |
see |
auto |
see |
... |
Additional arguments. (Currently ignored.) |
see xtable
see xtable
Stefan Behrendt, [email protected]
lm.beta
for creating the lm.beta
-object and xtable
for creating the tables.
## Taken from lm help ## ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". ## Page 9: Plant Weight Data. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~ group) # standardize lm.D9.beta <- lm.beta(lm.D9) xtable::xtable(lm.D9.beta)
## Taken from lm help ## ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". ## Page 9: Plant Weight Data. ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~ group) # standardize lm.D9.beta <- lm.beta(lm.D9) xtable::xtable(lm.D9.beta)