betaSandwich: Example
Ivan Jacob Agaloos Pesigan
Source:vignettes/betaSandwich.Rmd
betaSandwich.Rmd
In this example, a multiple regression model is fitted using program
quality ratings (QUALITY
) as the regressand/outcome
variable and number of published articles attributed to the program
faculty members (NARTIC
), percent of faculty members
holding research grants (PCTGRT
), and percentage of program
graduates who received support (PCTSUPP
) as
regressor/predictor variables using a data set from 1982 ratings of 46
doctoral programs in psychology in the USA National Research Council (1982). Robust
confidence intervals for the standardized regression coefficients are
generated using the BetaHC()
function from the
betaSandwich
package following Dudgeon (2017).
df <- betaSandwich::nas1982
Fit the regression model using the lm()
function.
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = df)
Estimate the standardized regression slopes and the corresponding robust sampling covariance matrix.
BetaHC(object, type = "hc3")
#> Call:
#> BetaHC(object = object, type = "hc3")
#>
#> Standardized regression slopes with HC3 standard errors:
#> est se t p 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> NARTIC 0.4951 0.0786 6.3025 0.0000 0.2172 0.2832 0.3366 0.6537 0.7071 0.7731
#> PCTGRT 0.3915 0.0818 4.7831 0.0000 0.1019 0.1707 0.2263 0.5567 0.6123 0.6810
#> PCTSUPP 0.2632 0.0855 3.0786 0.0037 -0.0393 0.0325 0.0907 0.4358 0.4940 0.5658
Methods
out <- BetaHC(object, type = "hc3")
summary
Summary of the results of BetaHC()
.
summary(out)
#> Call:
#> BetaHC(object = object, type = "hc3")
#>
#> Standardized regression slopes with HC3 standard errors:
#> est se t p 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> NARTIC 0.4951 0.0786 6.3025 0.0000 0.2172 0.2832 0.3366 0.6537 0.7071 0.7731
#> PCTGRT 0.3915 0.0818 4.7831 0.0000 0.1019 0.1707 0.2263 0.5567 0.6123 0.6810
#> PCTSUPP 0.2632 0.0855 3.0786 0.0037 -0.0393 0.0325 0.0907 0.4358 0.4940 0.5658
coef
Calculate the standardized regression slopes.
coef(out)
#> NARTIC PCTGRT PCTSUPP
#> 0.4951451 0.3914887 0.2632477
vcov
Calculate the robust sampling covariance matrix of the standardized regression slopes.
vcov(out)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.006172168 -0.003602529 -0.001943469
#> PCTGRT -0.003602529 0.006699155 -0.002443584
#> PCTSUPP -0.001943469 -0.002443584 0.007311625
confint
Generate robust confidence intervals for standardized regression slopes.
confint(out, level = 0.95)
#> 2.5% 97.5%
#> NARTIC 0.33659828 0.6536920
#> PCTGRT 0.22631203 0.5566654
#> PCTSUPP 0.09068548 0.4358099