betaMC: Example Using the DiffBetaMC Function
Ivan Jacob Agaloos Pesigan
Source:vignettes/example-diff-beta-mc.Rmd
example-diff-beta-mc.RmdConfidence intervals for differences of standardized regression
slopes are generated using the DiffBetaMC() function from
the betaMC package. In this example, we use the data set
and the model used in betaMC: Example
Using the BetaMC Function.
library(package = betaMC)
df <- betaMC::nas1982Regression
Fit the regression model using the lm() function.
object <- stats::lm(formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = df)Monte Carlo Sampling Distribution of Parameters
Normal-Theory Approach
mvn <- MC(object = object, type = "mvn")Asymptotic distribution-free Approach
adf <- MC(object = object, type = "adf")Heteroskedasticity Consistent Approach (HC3)
hc3 <- MC(object = object, type = "hc3")Differences of Standardized Regression Slopes
Normal-Theory Approach
mvn <- DiffBetaMC(object = mvn)Asymptotic distribution-free Approach
adf <- DiffBetaMC(object = adf)Heteroskedasticity Consistent Approach (HC3)
hc3 <- DiffBetaMC(object = hc3)Methods
summary
Summary of the results of DiffBetaMC().
summary(object = mvn)
#> Call:
#> DiffBetaMC(object = mvn)
#>
#> Differences of standardized regression slopes
#> type = "mvn"
#> est se R 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> NARTIC-PCTGRT 0.1037 0.1351 20000 -0.3368 -0.2458 -0.1660 0.3599 0.4408 0.5212
#> NARTIC-PCTSUPP 0.2319 0.1256 20000 -0.2108 -0.1123 -0.0244 0.4658 0.5339 0.6137
#> PCTGRT-PCTSUPP 0.1282 0.1232 20000 -0.2861 -0.1958 -0.1181 0.3670 0.4460 0.5409
summary(object = adf)
#> Call:
#> DiffBetaMC(object = adf)
#>
#> Differences of standardized regression slopes
#> type = "adf"
#> est se R 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> NARTIC-PCTGRT 0.1037 0.1214 20000 -0.3019 -0.2029 -0.1354 0.3362 0.4209 0.4922
#> NARTIC-PCTSUPP 0.2319 0.1187 20000 -0.1507 -0.0786 -0.0044 0.4589 0.5342 0.6095
#> PCTGRT-PCTSUPP 0.1282 0.1203 20000 -0.2767 -0.1899 -0.1112 0.3568 0.4293 0.5259
summary(object = hc3)
#> Call:
#> DiffBetaMC(object = hc3)
#>
#> Differences of standardized regression slopes
#> type = "hc3"
#> est se R 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> NARTIC-PCTGRT 0.1037 0.1425 20000 -0.3684 -0.2564 -0.1796 0.3794 0.4763 0.5672
#> NARTIC-PCTSUPP 0.2319 0.1325 20000 -0.2452 -0.1259 -0.0384 0.4793 0.5539 0.6471
#> PCTGRT-PCTSUPP 0.1282 0.1373 20000 -0.3529 -0.2364 -0.1518 0.3869 0.4706 0.5737coef
Return the vector of estimates.
stats::coef(object = mvn)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> 0.1036564 0.2318974 0.1282410
stats::coef(object = adf)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> 0.1036564 0.2318974 0.1282410
stats::coef(object = hc3)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> 0.1036564 0.2318974 0.1282410vcov
Return the sampling covariance matrix.
stats::vcov(object = mvn)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> NARTIC-PCTGRT 0.018249644 0.009426601 -0.008823043
#> NARTIC-PCTSUPP 0.009426601 0.015783701 0.006357100
#> PCTGRT-PCTSUPP -0.008823043 0.006357100 0.015180143
stats::vcov(object = adf)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> NARTIC-PCTGRT 0.014734517 0.007174868 -0.007559649
#> NARTIC-PCTSUPP 0.007174868 0.014086683 0.006911815
#> PCTGRT-PCTSUPP -0.007559649 0.006911815 0.014471464
stats::vcov(object = hc3)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> NARTIC-PCTGRT 0.02030680 0.009507770 -0.010799027
#> NARTIC-PCTSUPP 0.00950777 0.017556262 0.008048492
#> PCTGRT-PCTSUPP -0.01079903 0.008048492 0.018847519confint
Return confidence intervals.
stats::confint(object = mvn, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC-PCTGRT -0.16597827 0.3599059
#> NARTIC-PCTSUPP -0.02442948 0.4657819
#> PCTGRT-PCTSUPP -0.11814942 0.3669940
stats::confint(object = adf, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC-PCTGRT -0.135427123 0.3361984
#> NARTIC-PCTSUPP -0.004370207 0.4589016
#> PCTGRT-PCTSUPP -0.111175117 0.3568019
stats::confint(object = hc3, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC-PCTGRT -0.17964282 0.3793686
#> NARTIC-PCTSUPP -0.03836701 0.4792582
#> PCTGRT-PCTSUPP -0.15183553 0.3868603References
Dudgeon, P. (2017). Some improvements in confidence intervals for
standardized regression coefficients. Psychometrika,
82(4), 928–951. https://doi.org/10.1007/s11336-017-9563-z
Pesigan, I. J. A., & Cheung, S. F. (2024). Monte Carlo
confidence intervals for the indirect effect with missing data.
Behavior Research Methods, 56(3), 1678–1696. https://doi.org/10.3758/s13428-023-02114-4