Package 'betaSandwich'

Title: Robust Confidence Intervals for Standardized Regression Coefficients
Description: Generates robust confidence intervals for standardized regression coefficients using heteroskedasticity-consistent standard errors for models fitted by lm() as described in Dudgeon (2017) <doi:10.1007/s11336-017-9563-z>. The package can also be used to generate confidence intervals for R-squared, adjusted R-squared, and differences of standardized regression coefficients. 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.7.9000
Built: 2024-11-21 05:51:12 UTC
Source: https://github.com/jeksterslab/betaSandwich

Help Index


Estimate Standardized Regression Coefficients and the Corresponding Sampling Covariance Matrix Using the Asymptotic Distribution-Free Approach

Description

Estimate Standardized Regression Coefficients and the Corresponding Sampling Covariance Matrix Using the Asymptotic Distribution-Free Approach

Usage

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

Arguments

object

Object of class lm.

alpha

Numeric vector. Significance level α\alpha.

Details

Note that while the calculation in BetaADF() is different from betaDelta::BetaDelta() with type = "adf", the results are numerically equivalent. BetaADF() is appropriate when sample sizes are moderate to large (n > 250). BetaHC() is recommended in most situations.

Value

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

call

Function call.

args

Function arguments.

lm_process

Processed lm object.

gamma_n

Asymptotic covariance matrix of the sample covariance matrix assuming multivariate normality.

gamma_hc

Asymptotic covariance matrix HC correction.

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

Browne, M. W. (1984). Asymptotically distribution-free methods for the analysis of covariance structures. British Journal of Mathematical and Statistical Psychology, 37(1), 62–83. doi:10.1111/j.2044-8317.1984.tb00789.x

Dudgeon, P. (2017). Some improvements in confidence intervals for standardized regression coefficients. Psychometrika, 82(4), 928–951. doi:10.1007/s11336-017-9563-z

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

See Also

Other Beta Sandwich Functions: BetaHC(), BetaN(), DiffBetaSandwich(), RSqBetaSandwich()

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaADF(object)
# Methods -------------------------------------------------------
print(std)
summary(std)
coef(std)
vcov(std)
confint(std, level = 0.95)

Estimate Standardized Regression Coefficients and the Corresponding Robust Sampling Covariance Matrix Using the Heteroskedasticity Consistent Approach

Description

Estimate Standardized Regression Coefficients and the Corresponding Robust Sampling Covariance Matrix Using the Heteroskedasticity Consistent Approach

Usage

BetaHC(
  object,
  type = "hc3",
  alpha = c(0.05, 0.01, 0.001),
  g1 = 1,
  g2 = 1.5,
  k = 0.7
)

Arguments

object

Object of class lm.

type

Character string. Correction type. Possible values are "hc0", "hc1", "hc2", "hc3", "hc4", "hc4m", and "hc5".

alpha

Numeric vector. Significance level α\alpha.

g1

Numeric. g1 value for type = "hc4m".

g2

Numeric. g2 value for type = "hc4m".

k

Numeric. Constant k for type = "hc5" 0k10 \leq k \leq 1.

Value

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

call

Function call.

args

Function arguments.

lm_process

Processed lm object.

gamma_n

Asymptotic covariance matrix of the sample covariance matrix assuming multivariate normality.

gamma_hc

Asymptotic covariance matrix HC correction.

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

Dudgeon, P. (2017). Some improvements in confidence intervals for standardized regression coefficients. Psychometrika, 82(4), 928–951. doi:10.1007/s11336-017-9563-z

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

See Also

Other Beta Sandwich Functions: BetaADF(), BetaN(), DiffBetaSandwich(), RSqBetaSandwich()

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaHC(object)
# Methods -------------------------------------------------------
print(std)
summary(std)
coef(std)
vcov(std)
confint(std, level = 0.95)

Estimate Standardized Regression Coefficients and the Corresponding Sampling Covariance Matrix Assuming Multivariate Normality

Description

Estimate Standardized Regression Coefficients and the Corresponding Sampling Covariance Matrix Assuming Multivariate Normality

Usage

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

Arguments

object

Object of class lm.

alpha

Numeric vector. Significance level α\alpha.

Details

Note that while the calculation in BetaN() is different from betaDelta::BetaDelta() with type = "mvn", the results are numerically equivalent. BetaN() assumes multivariate normality. BetaHC() is recommended in most situations.

Value

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

call

Function call.

args

Function arguments.

lm_process

Processed lm object.

gamma_n

Asymptotic covariance matrix of the sample covariance matrix assuming multivariate normality.

gamma_hc

Asymptotic covariance matrix HC correction.

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

Dudgeon, P. (2017). Some improvements in confidence intervals for standardized regression coefficients. Psychometrika, 82(4), 928–951. doi:10.1007/s11336-017-9563-z

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

See Also

Other Beta Sandwich Functions: BetaADF(), BetaHC(), DiffBetaSandwich(), RSqBetaSandwich()

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaN(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 'betasandwich'
coef(object, ...)

Arguments

object

Object of class betasandwich.

...

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 <- BetaHC(object)
coef(std)

Differences of Standardized Regression Slopes

Description

Differences of Standardized Regression Slopes

Usage

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

Arguments

object

Object of class diffbetasandwich.

...

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 <- BetaHC(object)
diff <- DiffBetaSandwich(std)
coef(diff)

Multiple Correlation Coefficients (R-Squared and Adjusted R-Squared)

Description

Multiple Correlation Coefficients (R-Squared and Adjusted R-Squared)

Usage

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

Arguments

object

Object of class rsqbetasandwich.

...

additional arguments.

Value

Returns a vector of multiple correlation coefficients (R-squared and adjusted R-squared)

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

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

Confidence Intervals for Standardized Regression Slopes

Description

Confidence Intervals for Standardized Regression Slopes

Usage

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

Arguments

object

Object of class betasandwich.

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 <- BetaHC(object)
confint(std, 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 'diffbetasandwich'
confint(object, parm = NULL, level = 0.95, ...)

Arguments

object

Object of class diffbetasandwich.

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 <- BetaHC(object)
diff <- DiffBetaSandwich(std)
confint(diff, level = 0.95)

Confidence Intervals for Multiple Correlation Coefficients (R-Squared and Adjusted R-Squared)

Description

Confidence Intervals for Multiple Correlation Coefficients (R-Squared and Adjusted R-Squared)

Usage

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

Arguments

object

Object of class rsqbetasandwich.

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 <- BetaHC(object)
rsq <- RSqBetaSandwich(std)
confint(rsq, level = 0.95)

Estimate Differences of Standardized Slopes and the Corresponding Sampling Covariance Matrix

Description

Estimate Differences of Standardized Slopes and the Corresponding Sampling Covariance Matrix

Usage

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

Arguments

object

Object of class betasandwich, that is, the output of the BetaHC(), BetaN(), or BetaADF() functions.

alpha

Numeric vector. Significance level α\alpha.

Value

Returns an object of class diffbetasandwich 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 Sandwich Functions: BetaADF(), BetaHC(), BetaN(), RSqBetaSandwich()

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaHC(object)
diff <- DiffBetaSandwich(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 betasandwich

Description

Print Method for an Object of Class betasandwich

Usage

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

Arguments

x

Object of class betasandwich.

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 <- BetaHC(object)
print(std)

Print Method for an Object of Class diffbetasandwich

Description

Print Method for an Object of Class diffbetasandwich

Usage

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

Arguments

x

Object of class diffbetasandwich.

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 differences 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 <- BetaHC(object)
diff <- DiffBetaSandwich(std)
print(diff)

Print Method for an Object of Class rsqbetasandwich

Description

Print Method for an Object of Class rsqbetasandwich

Usage

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

Arguments

x

Object of class rsqbetasandwich.

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 multiple correlation coefficients (R-squared and adjusted R-squared), 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 <- BetaHC(object)
rsq <- RSqBetaSandwich(std)
print(rsq)

Estimate Multiple Correlation Coefficients (R-squared and adjusted R-squared) and the Corresponding Sampling Covariance Matrix

Description

Estimate Multiple Correlation Coefficients (R-squared and adjusted R-squared) and the Corresponding Sampling Covariance Matrix

Usage

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

Arguments

object

Object of class betasandwich, that is, the output of the BetaHC(), BetaN(), or BetaADF() functions.

alpha

Numeric vector. Significance level α\alpha.

Value

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

call

Function call.

fit

The argument object.

args

Function arguments.

vcov

Sampling covariance matrix of multiple correlation coefficients (R-squared and adjusted R-squared).

est

Vector of multiple correlation coefficients (R-squared and adjusted R-squared).

Author(s)

Ivan Jacob Agaloos Pesigan

See Also

Other Beta Sandwich Functions: BetaADF(), BetaHC(), BetaN(), DiffBetaSandwich()

Examples

object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
std <- BetaHC(object)
rsq <- RSqBetaSandwich(std)
# Methods -------------------------------------------------------
print(rsq)
summary(rsq)
coef(rsq)
vcov(rsq)
confint(rsq, level = 0.95)

Summary Method for an Object of Class betasandwich

Description

Summary Method for an Object of Class betasandwich

Usage

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

Arguments

object

Object of class betasandwich.

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 <- BetaHC(object)
summary(std)

Summary Method for an Object of Class diffbetasandwich

Description

Summary Method for an Object of Class diffbetasandwich

Usage

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

Arguments

object

Object of class diffbetasandwich.

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 differences 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 <- BetaHC(object)
diff <- DiffBetaSandwich(std)
summary(diff)

Summary Method for an Object of Class rsqbetasandwich

Description

Summary Method for an Object of Class rsqbetasandwich

Usage

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

Arguments

object

Object of class rsqbetasandwich.

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 multiple correlation coefficients (R-squared and adjusted R-squared), 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 <- BetaHC(object)
rsq <- RSqBetaSandwich(std)
summary(rsq)

Sampling Covariance Matrix of the Standardized Regression Slopes

Description

Sampling Covariance Matrix of the Standardized Regression Slopes

Usage

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

Arguments

object

Object of class betasandwich.

...

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 <- BetaHC(object)
vcov(std)

Sampling Covariance Matrix of Differences of Standardized Regression Slopes

Description

Sampling Covariance Matrix of Differences of Standardized Regression Slopes

Usage

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

Arguments

object

Object of class diffbetasandwich.

...

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 <- BetaHC(object)
diff <- DiffBetaSandwich(std)
vcov(diff)

Sampling Covariance Matrix of Multiple Correlation Coefficients (R-Squared and Adjusted R-Squared)

Description

Sampling Covariance Matrix of Multiple Correlation Coefficients (R-Squared and Adjusted R-Squared)

Usage

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

Arguments

object

Object of class rsqbetasandwich.

...

additional arguments.

Value

Returns a matrix of the variance-covariance matrix of multiple correlation coefficients (R-squared and adjusted R-squared).

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

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