Package 'betaDelta'

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

Help Index


Estimate Standardized Regression Coefficients and the Corresponding Sampling Covariance Matrix

Description

Estimate Standardized Regression Coefficients and the Corresponding Sampling Covariance Matrix

Usage

BetaDelta(object, type = "mvn", alpha = c(0.05, 0.01, 0.001))

Arguments

object

Object of class lm.

type

Character string. If type = "mvn", use the multivariate normal-theory approach. If type = "adf", use the asymptotic distribution-free approach.

alpha

Numeric vector. Significance level α\alpha.

Value

Returns an object of class betadelta which is a list with the following elements:

call

Function call.

args

Function arguments.

lm_process

Processed lm object.

gamma

Asymptotic covariance matrix of the sample covariance matrix.

acov

Asymptotic covariance matrix of the standardized slopes.

vcov

Sampling covariance matrix of the standardized slopes.

est

Vector of standardized slopes.

Author(s)

Ivan Jacob Agaloos Pesigan

References

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

See Also

Other Beta Delta Functions: DiffBetaDelta()

Examples

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

Description

Standardized Regression Slopes

Usage

## S3 method for class 'betadelta'
coef(object, ...)

Arguments

object

Object of class betadelta.

...

additional arguments.

Value

Returns a vector of standardized regression slopes.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaDelta(object)
coef(std)

Estimates

Description

Estimates

Usage

## S3 method for class 'deltamethod'
coef(object, ...)

Arguments

object

Object of class deltamethod.

...

additional arguments.

Value

Returns a vector of estimates.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

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

Description

Differences of Standardized Regression Slopes

Usage

## S3 method for class 'diffbetadelta'
coef(object, ...)

Arguments

object

Object of class diffbetadelta.

...

additional arguments.

Value

Returns a vector of differences of standardized regression slopes.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaDelta(object)
diff <- DiffBetaDelta(std)
coef(diff)

Confidence Intervals for Standardized Regression Slopes

Description

Confidence Intervals for Standardized Regression Slopes

Usage

## S3 method for class 'betadelta'
confint(object, parm = NULL, level = 0.95, ...)

Arguments

object

Object of class betadelta.

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.

Value

Returns a matrix of confidence intervals.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaDelta(object)
confint(std, level = 0.95)

Confidence Intervals

Description

Confidence Intervals

Usage

## S3 method for class 'deltamethod'
confint(object, parm = NULL, level = 0.95, ...)

Arguments

object

Object of class deltamethod.

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.

Value

Returns a matrix of confidence intervals.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

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

Description

Confidence Intervals for Differences of Standardized Regression Slopes

Usage

## S3 method for class 'diffbetadelta'
confint(object, parm = NULL, level = 0.95, ...)

Arguments

object

Object of class diffbetadelta.

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.

Value

Returns a matrix of confidence intervals.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaDelta(object)
diff <- DiffBetaDelta(std)
confint(diff)

Delta Method

Description

Calculates delta method sampling variance-covariance matrix for a function of parameters using a numerical Jacobian.

Usage

Delta(
  coef,
  vcov,
  func,
  ...,
  theta = 0,
  alpha = c(0.05, 0.01, 0.001),
  z = TRUE,
  df = NULL
)

Arguments

coef

Numeric vector. Vector of parameters.

vcov

Numeric matrix. Matrix of sampling variance-covariance matrix of parameters.

func

R function.

  1. The first argument x is the argument coef.

  2. The function algebraically manipulates coef to return a new numeric vector. It is best to have a named vector as an output.

  3. The function can take additional named arguments passed using ....

...

Additional arguments to pass to func.

theta

Numeric vector. Parameter values when the null hypothesis is true.

alpha

Numeric vector. Significance level/s.

z

Logical. If z = TRUE, use the standard normal distribution. If z = FALSE, use the t distribution.

df

Numeric. Degrees of freedom if z = FALSE.

Value

Returns an object of class deltamethod which is a list with the following elements:

call

Function call.

args

Function arguments.

coef

Estimates.

vcov

Sampling variance-covariance matrix.

jacobian

Jacobian matrix.

fun

Function used ("Delta").

Author(s)

Ivan Jacob Agaloos Pesigan

See Also

Other Delta Method Functions: DeltaGeneric()

Examples

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
)

Delta Method (Generic Object Input)

Description

Calculates delta method sampling variance-covariance matrix for a function of parameters using a numerical Jacobian.

Usage

DeltaGeneric(
  object,
  def,
  theta = 0,
  alpha = c(0.05, 0.01, 0.001),
  z = TRUE,
  df = NULL
)

Arguments

object

R object. Fitted model object with coef and vcov methods that return a named vector of estimated parameters and sampling variance-covariance matrix, respectively.

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 z = TRUE, use the standard normal distribution. If z = FALSE, use the t distribution.

df

Numeric. Degrees of freedom if z = FALSE.

Value

Returns an object of class deltamethod which is a list with the following elements:

call

Function call.

args

Function arguments.

coef

Estimates.

vcov

Sampling variance-covariance matrix.

jacobian

Jacobian matrix.

fun

Function used ("DeltaGeneric").

Author(s)

Ivan Jacob Agaloos Pesigan

See Also

Other Delta Method Functions: Delta()

Examples

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

Description

Estimate Differences of Standardized Slopes and the Corresponding Sampling Covariance Matrix

Usage

DiffBetaDelta(object, alpha = c(0.05, 0.01, 0.001))

Arguments

object

Object of class betadelta, that is, the output of the BetaDelta() function.

alpha

Numeric vector. Significance level α\alpha.

Value

Returns an object of class diffbetadelta which is a list with the following elements:

call

Function call.

fit

The argument object.

args

Function arguments.

vcov

Sampling covariance matrix of differences of standardized slopes.

est

Vector of differences of standardized slopes.

Author(s)

Ivan Jacob Agaloos Pesigan

See Also

Other Beta Delta Functions: BetaDelta()

Examples

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

Description

1982 National Academy of Sciences Doctoral Programs Data

Usage

nas1982

Format

Ratings of 46 doctoral programs in psychology in the USA with the following variables:

QUALITY

Program quality ratings.

NFACUL

Number of faculty members in the program.

NGRADS

Number of program graduates.

PCTSUPP

Percentage of program graduates who received support.

PCTGRT

Percent of faculty members holding research grants.

NARTIC

Number of published articles attributed to program faculty member.

PCTPUB

Percent of faculty with one or more published article.

References

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.


Print Method for an Object of Class betadelta

Description

Print Method for an Object of Class betadelta

Usage

## S3 method for class 'betadelta'
print(x, alpha = NULL, digits = 4, ...)

Arguments

x

Object of class betadelta.

alpha

Numeric vector. Significance level α\alpha. If alpha = NULL, use the argument alpha used in x.

digits

Digits to print.

...

additional arguments.

Value

Prints a matrix of standardized regression slopes, standard errors, test statistics, degrees of freedom, p-values, and confidence intervals.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaDelta(object)
print(std)

Print Method for an Object of Class deltamethod

Description

Print Method for an Object of Class deltamethod

Usage

## S3 method for class 'deltamethod'
print(x, alpha = NULL, digits = 4, ...)

Arguments

x

Object of class deltamethod.

alpha

Numeric vector. Significance level α\alpha. If alpha = NULL, use the argument alpha used in x.

digits

Digits to print.

...

additional arguments.

Value

Returns a matrix of coefficients, standard errors, test statistics, degrees of freedom (if z = FALSE), p-values, and confidence intervals.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

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)

Print Method for an Object of Class diffbetadelta

Description

Print Method for an Object of Class diffbetadelta

Usage

## S3 method for class 'diffbetadelta'
print(x, alpha = NULL, digits = 4, ...)

Arguments

x

Object of class diffbetadelta.

alpha

Numeric vector. Significance level α\alpha. If alpha = NULL, use the argument alpha used in x.

digits

Digits to print.

...

additional arguments.

Value

Prints a matrix of standardized regression slopes, standard errors, test statistics, degrees of freedom, p-values, and confidence intervals.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaDelta(object)
diff <- DiffBetaDelta(std)
print(diff)

Summary Method for an Object of Class betadelta

Description

Summary Method for an Object of Class betadelta

Usage

## S3 method for class 'betadelta'
summary(object, alpha = NULL, digits = 4, ...)

Arguments

object

Object of class betadelta.

alpha

Numeric vector. Significance level α\alpha. If alpha = NULL, use the argument alpha used in object.

digits

Digits to print.

...

additional arguments.

Value

Returns a matrix of standardized regression slopes, standard errors, test statistics, degrees of freedom, p-values, and confidence intervals.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaDelta(object)
summary(std)

Summary Method for an Object of Class deltamethod

Description

Summary Method for an Object of Class deltamethod

Usage

## S3 method for class 'deltamethod'
summary(object, alpha = NULL, digits = 4, ...)

Arguments

object

Object of class deltamethod.

alpha

Numeric vector. Significance level α\alpha. If alpha = NULL, use the argument alpha used in object.

digits

Digits to print.

...

additional arguments.

Value

Returns a matrix of standardized regression slopes, standard errors, test statistics, degrees of freedom, p-values, and confidence intervals.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

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)

Summary Method for an Object of Class diffbetadelta

Description

Summary Method for an Object of Class diffbetadelta

Usage

## S3 method for class 'diffbetadelta'
summary(object, alpha = NULL, digits = 4, ...)

Arguments

object

Object of class diffbetadelta.

alpha

Numeric vector. Significance level α\alpha. If alpha = NULL, use the argument alpha used in object.

digits

Digits to print.

...

additional arguments.

Value

Returns a matrix of standardized regression slopes, standard errors, test statistics, degrees of freedom, p-values, and confidence intervals.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaDelta(object)
diff <- DiffBetaDelta(std)
summary(diff)

Sampling Covariance Matrix of the Standardized Regression Slopes

Description

Sampling Covariance Matrix of the Standardized Regression Slopes

Usage

## S3 method for class 'betadelta'
vcov(object, ...)

Arguments

object

Object of class betadelta.

...

additional arguments.

Value

Returns a matrix of the variance-covariance matrix of standardized slopes.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaDelta(object)
vcov(std)

Sampling Covariance Matrix

Description

Sampling Covariance Matrix

Usage

## S3 method for class 'deltamethod'
vcov(object, ...)

Arguments

object

Object of class deltamethod.

...

additional arguments.

Value

Returns a matrix of the variance-covariance matrix.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

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

Description

Sampling Covariance Matrix of Differences of Standardized Regression Slopes

Usage

## S3 method for class 'diffbetadelta'
vcov(object, ...)

Arguments

object

Object of class diffbetadelta.

...

additional arguments.

Value

Returns a matrix of the variance-covariance matrix of differences of standardized regression slopes.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaDelta(object)
diff <- DiffBetaDelta(std)
vcov(diff)