Title: | Confidence Intervals for Standardized Regression Coefficients |
---|---|
Description: | Generates confidence intervals for standardized regression coefficients using delta method standard errors for models fitted by lm() as described in Yuan and Chan (2011) <doi:10.1007/s11336-011-9224-6> and Jones and Waller (2015) <doi:10.1007/s11336-013-9380-y>. The package can also be used to generate confidence intervals for differences of standardized regression coefficients and as a general approach to performing the delta method. A description of the package and code examples are presented in Pesigan, Sun, and Cheung (2023) <doi:10.1080/00273171.2023.2201277>. |
Authors: | Ivan Jacob Agaloos Pesigan [aut, cre, cph] |
Maintainer: | Ivan Jacob Agaloos Pesigan <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.5.9000 |
Built: | 2024-11-21 05:51:06 UTC |
Source: | https://github.com/jeksterslab/betaDelta |
Estimate Standardized Regression Coefficients and the Corresponding Sampling Covariance Matrix
BetaDelta(object, type = "mvn", alpha = c(0.05, 0.01, 0.001))
BetaDelta(object, type = "mvn", alpha = c(0.05, 0.01, 0.001))
object |
Object of class |
type |
Character string.
If |
alpha |
Numeric vector.
Significance level |
Returns an object
of class betadelta
which is a list with the following elements:
Function call.
Function arguments.
Processed lm
object.
Asymptotic covariance matrix of the sample covariance matrix.
Asymptotic covariance matrix of the standardized slopes.
Sampling covariance matrix of the standardized slopes.
Vector of standardized slopes.
Ivan Jacob Agaloos Pesigan
Jones, J. A., & Waller, N. G. (2015). The normal-theory and asymptotic distribution-free (ADF) covariance matrix of standardized regression coefficients: Theoretical extensions and finite sample behavior. Psychometrika, 80(2), 365–378. doi:10.1007/s11336-013-9380-y
Pesigan, I. J. A., Sun, R. W., & Cheung, S. F. (2023). betaDelta and betaSandwich: Confidence intervals for standardized regression coefficients in R. Multivariate Behavioral Research. doi:10.1080/00273171.2023.2201277
Yuan, K.-H., & Chan, W. (2011). Biases and standard errors of standardized regression coefficients. Psychometrika, 76(4), 670–690. doi:10.1007/s11336-011-9224-6
Other Beta Delta Functions:
DiffBetaDelta()
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) # Methods ------------------------------------------------------- print(std) summary(std) coef(std) vcov(std) confint(std, level = 0.95)
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) # Methods ------------------------------------------------------- print(std) summary(std) coef(std) vcov(std) confint(std, level = 0.95)
Standardized Regression Slopes
## S3 method for class 'betadelta' coef(object, ...)
## S3 method for class 'betadelta' coef(object, ...)
object |
Object of class |
... |
additional arguments. |
Returns a vector of standardized regression slopes.
Ivan Jacob Agaloos Pesigan
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) coef(std)
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) coef(std)
Estimates
## S3 method for class 'deltamethod' coef(object, ...)
## S3 method for class 'deltamethod' coef(object, ...)
object |
Object of class |
... |
additional arguments. |
Returns a vector of estimates.
Ivan Jacob Agaloos Pesigan
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) def <- list("exp(wt)", "exp(disp)") out <- DeltaGeneric( object = object, def = def, alpha = 0.05 ) coef(out)
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) def <- list("exp(wt)", "exp(disp)") out <- DeltaGeneric( object = object, def = def, alpha = 0.05 ) coef(out)
Differences of Standardized Regression Slopes
## S3 method for class 'diffbetadelta' coef(object, ...)
## S3 method for class 'diffbetadelta' coef(object, ...)
object |
Object of class |
... |
additional arguments. |
Returns a vector of differences of standardized regression slopes.
Ivan Jacob Agaloos Pesigan
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) diff <- DiffBetaDelta(std) coef(diff)
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) diff <- DiffBetaDelta(std) coef(diff)
Confidence Intervals for Standardized Regression Slopes
## S3 method for class 'betadelta' confint(object, parm = NULL, level = 0.95, ...)
## S3 method for class 'betadelta' confint(object, parm = NULL, level = 0.95, ...)
object |
Object of class |
parm |
a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered. |
level |
the confidence level required. |
... |
additional arguments. |
Returns a matrix of confidence intervals.
Ivan Jacob Agaloos Pesigan
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) confint(std, level = 0.95)
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) confint(std, level = 0.95)
Confidence Intervals
## S3 method for class 'deltamethod' confint(object, parm = NULL, level = 0.95, ...)
## S3 method for class 'deltamethod' confint(object, parm = NULL, level = 0.95, ...)
object |
Object of class |
parm |
a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered. |
level |
the confidence level required. |
... |
additional arguments. |
Returns a matrix of confidence intervals.
Ivan Jacob Agaloos Pesigan
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) def <- list("exp(wt)", "exp(disp)") out <- DeltaGeneric( object = object, def = def, alpha = 0.05 ) confint(out, level = 0.95)
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) def <- list("exp(wt)", "exp(disp)") out <- DeltaGeneric( object = object, def = def, alpha = 0.05 ) confint(out, level = 0.95)
Confidence Intervals for Differences of Standardized Regression Slopes
## S3 method for class 'diffbetadelta' confint(object, parm = NULL, level = 0.95, ...)
## S3 method for class 'diffbetadelta' confint(object, parm = NULL, level = 0.95, ...)
object |
Object of class |
parm |
a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered. |
level |
the confidence level required. |
... |
additional arguments. |
Returns a matrix of confidence intervals.
Ivan Jacob Agaloos Pesigan
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) diff <- DiffBetaDelta(std) confint(diff)
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) diff <- DiffBetaDelta(std) confint(diff)
Calculates delta method sampling variance-covariance matrix for a function of parameters using a numerical Jacobian.
Delta( coef, vcov, func, ..., theta = 0, alpha = c(0.05, 0.01, 0.001), z = TRUE, df = NULL )
Delta( coef, vcov, func, ..., theta = 0, alpha = c(0.05, 0.01, 0.001), z = TRUE, df = NULL )
coef |
Numeric vector. Vector of parameters. |
vcov |
Numeric matrix. Matrix of sampling variance-covariance matrix of parameters. |
func |
R function.
|
... |
Additional arguments to pass to |
theta |
Numeric vector. Parameter values when the null hypothesis is true. |
alpha |
Numeric vector. Significance level/s. |
z |
Logical.
If |
df |
Numeric.
Degrees of freedom if |
Returns an object
of class deltamethod
which is a list with the following elements:
Function call.
Function arguments.
Estimates.
Sampling variance-covariance matrix.
Jacobian matrix.
Function used ("Delta").
Ivan Jacob Agaloos Pesigan
Other Delta Method Functions:
DeltaGeneric()
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) func <- function(x) { y <- exp(x) names(y) <- paste0("exp", "(", names(x), ")") return(y[-1]) } Delta( coef = coef(object), vcov = vcov(object), func = func, alpha = 0.05 )
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) func <- function(x) { y <- exp(x) names(y) <- paste0("exp", "(", names(x), ")") return(y[-1]) } Delta( coef = coef(object), vcov = vcov(object), func = func, alpha = 0.05 )
Calculates delta method sampling variance-covariance matrix for a function of parameters using a numerical Jacobian.
DeltaGeneric( object, def, theta = 0, alpha = c(0.05, 0.01, 0.001), z = TRUE, df = NULL )
DeltaGeneric( object, def, theta = 0, alpha = c(0.05, 0.01, 0.001), z = TRUE, df = NULL )
object |
R object.
Fitted model object with |
def |
List of character strings. A list of defined functions of parameters. The string should be a valid R expression when parsed and should result a single value when evaluated. |
theta |
Numeric vector. Parameter values when the null hypothesis is true. |
alpha |
Numeric vector. Significance level/s. |
z |
Logical.
If |
df |
Numeric.
Degrees of freedom if |
Returns an object
of class deltamethod
which is a list with the following elements:
Function call.
Function arguments.
Estimates.
Sampling variance-covariance matrix.
Jacobian matrix.
Function used ("DeltaGeneric").
Ivan Jacob Agaloos Pesigan
Other Delta Method Functions:
Delta()
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) def <- list("exp(wt)", "exp(disp)") DeltaGeneric( object = object, def = def, alpha = 0.05 )
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) def <- list("exp(wt)", "exp(disp)") DeltaGeneric( object = object, def = def, alpha = 0.05 )
Estimate Differences of Standardized Slopes and the Corresponding Sampling Covariance Matrix
DiffBetaDelta(object, alpha = c(0.05, 0.01, 0.001))
DiffBetaDelta(object, alpha = c(0.05, 0.01, 0.001))
object |
Object of class |
alpha |
Numeric vector.
Significance level |
Returns an object
of class diffbetadelta
which is a list with the following elements:
Function call.
The argument object
.
Function arguments.
Sampling covariance matrix of differences of standardized slopes.
Vector of differences of standardized slopes.
Ivan Jacob Agaloos Pesigan
Other Beta Delta Functions:
BetaDelta()
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) diff <- DiffBetaDelta(std) # Methods ------------------------------------------------------- print(diff) summary(diff) coef(diff) vcov(diff) confint(diff, level = 0.95)
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) diff <- DiffBetaDelta(std) # Methods ------------------------------------------------------- print(diff) summary(diff) coef(diff) vcov(diff) confint(diff, level = 0.95)
1982 National Academy of Sciences Doctoral Programs Data
nas1982
nas1982
Ratings of 46 doctoral programs in psychology in the USA with the following variables:
Program quality ratings.
Number of faculty members in the program.
Number of program graduates.
Percentage of program graduates who received support.
Percent of faculty members holding research grants.
Number of published articles attributed to program faculty member.
Percent of faculty with one or more published article.
National Research Council. (1982). An assessment of research-doctorate programs in the United States: Social and behavioral sciences. doi:10.17226/9781. Reproduced with permission from the National Academy of Sciences, Courtesy of the National Academies Press, Washington, D.C.
betadelta
Print Method for an Object of Class betadelta
## S3 method for class 'betadelta' print(x, alpha = NULL, digits = 4, ...)
## S3 method for class 'betadelta' print(x, alpha = NULL, digits = 4, ...)
x |
Object of class |
alpha |
Numeric vector.
Significance level |
digits |
Digits to print. |
... |
additional arguments. |
Prints a matrix of standardized regression slopes, standard errors, test statistics, degrees of freedom, p-values, and confidence intervals.
Ivan Jacob Agaloos Pesigan
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) print(std)
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) print(std)
deltamethod
Print Method for an Object of Class deltamethod
## S3 method for class 'deltamethod' print(x, alpha = NULL, digits = 4, ...)
## S3 method for class 'deltamethod' print(x, alpha = NULL, digits = 4, ...)
x |
Object of class |
alpha |
Numeric vector.
Significance level |
digits |
Digits to print. |
... |
additional arguments. |
Returns a matrix of coefficients, standard errors, test statistics, degrees of freedom (if z = FALSE), p-values, and confidence intervals.
Ivan Jacob Agaloos Pesigan
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) def <- list("exp(wt)", "exp(disp)") out <- DeltaGeneric( object = object, def = def, alpha = 0.05 ) print(out)
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) def <- list("exp(wt)", "exp(disp)") out <- DeltaGeneric( object = object, def = def, alpha = 0.05 ) print(out)
diffbetadelta
Print Method for an Object of Class diffbetadelta
## S3 method for class 'diffbetadelta' print(x, alpha = NULL, digits = 4, ...)
## S3 method for class 'diffbetadelta' print(x, alpha = NULL, digits = 4, ...)
x |
Object of class |
alpha |
Numeric vector.
Significance level |
digits |
Digits to print. |
... |
additional arguments. |
Prints a matrix of standardized regression slopes, standard errors, test statistics, degrees of freedom, p-values, and confidence intervals.
Ivan Jacob Agaloos Pesigan
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) diff <- DiffBetaDelta(std) print(diff)
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) diff <- DiffBetaDelta(std) print(diff)
betadelta
Summary Method for an Object of Class betadelta
## S3 method for class 'betadelta' summary(object, alpha = NULL, digits = 4, ...)
## S3 method for class 'betadelta' summary(object, alpha = NULL, digits = 4, ...)
object |
Object of class |
alpha |
Numeric vector.
Significance level |
digits |
Digits to print. |
... |
additional arguments. |
Returns a matrix of standardized regression slopes, standard errors, test statistics, degrees of freedom, p-values, and confidence intervals.
Ivan Jacob Agaloos Pesigan
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) summary(std)
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) summary(std)
deltamethod
Summary Method for an Object of Class deltamethod
## S3 method for class 'deltamethod' summary(object, alpha = NULL, digits = 4, ...)
## S3 method for class 'deltamethod' summary(object, alpha = NULL, digits = 4, ...)
object |
Object of class |
alpha |
Numeric vector.
Significance level |
digits |
Digits to print. |
... |
additional arguments. |
Returns a matrix of standardized regression slopes, standard errors, test statistics, degrees of freedom, p-values, and confidence intervals.
Ivan Jacob Agaloos Pesigan
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) def <- list("exp(wt)", "exp(disp)") out <- DeltaGeneric( object = object, def = def, alpha = 0.05 ) summary(out)
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) def <- list("exp(wt)", "exp(disp)") out <- DeltaGeneric( object = object, def = def, alpha = 0.05 ) summary(out)
diffbetadelta
Summary Method for an Object of Class diffbetadelta
## S3 method for class 'diffbetadelta' summary(object, alpha = NULL, digits = 4, ...)
## S3 method for class 'diffbetadelta' summary(object, alpha = NULL, digits = 4, ...)
object |
Object of class |
alpha |
Numeric vector.
Significance level |
digits |
Digits to print. |
... |
additional arguments. |
Returns a matrix of standardized regression slopes, standard errors, test statistics, degrees of freedom, p-values, and confidence intervals.
Ivan Jacob Agaloos Pesigan
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) diff <- DiffBetaDelta(std) summary(diff)
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) diff <- DiffBetaDelta(std) summary(diff)
Sampling Covariance Matrix of the Standardized Regression Slopes
## S3 method for class 'betadelta' vcov(object, ...)
## S3 method for class 'betadelta' vcov(object, ...)
object |
Object of class |
... |
additional arguments. |
Returns a matrix of the variance-covariance matrix of standardized slopes.
Ivan Jacob Agaloos Pesigan
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) vcov(std)
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) vcov(std)
Sampling Covariance Matrix
## S3 method for class 'deltamethod' vcov(object, ...)
## S3 method for class 'deltamethod' vcov(object, ...)
object |
Object of class |
... |
additional arguments. |
Returns a matrix of the variance-covariance matrix.
Ivan Jacob Agaloos Pesigan
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) def <- list("exp(wt)", "exp(disp)") out <- DeltaGeneric( object = object, def = def, alpha = 0.05 ) vcov(out)
object <- glm( formula = vs ~ wt + disp, family = "binomial", data = mtcars ) def <- list("exp(wt)", "exp(disp)") out <- DeltaGeneric( object = object, def = def, alpha = 0.05 ) vcov(out)
Sampling Covariance Matrix of Differences of Standardized Regression Slopes
## S3 method for class 'diffbetadelta' vcov(object, ...)
## S3 method for class 'diffbetadelta' vcov(object, ...)
object |
Object of class |
... |
additional arguments. |
Returns a matrix of the variance-covariance matrix of differences of standardized regression slopes.
Ivan Jacob Agaloos Pesigan
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) diff <- DiffBetaDelta(std) vcov(diff)
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982) std <- BetaDelta(object) diff <- DiffBetaDelta(std) vcov(diff)