betaMC: Example Using the DiffBetaMC Function
Ivan Jacob Agaloos Pesigan
Source:vignettes/example-diff-beta-mc.Rmd
example-diff-beta-mc.Rmd
Confidence 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.
df <- betaMC::nas1982
Regression
Fit the regression model using the lm()
function.
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = df)
Monte Carlo Sampling Distribution of Parameters
Normal-Theory Approach
mvn <- MC(object, type = "mvn")
Asymptotic distribution-free Approach
adf <- MC(object, type = "adf")
Heteroskedasticity Consistent Approach (HC3)
hc3 <- MC(object, type = "hc3")
Differences of Standardized Regression Slopes
Normal-Theory Approach
mvn <- DiffBetaMC(mvn)
Asymptotic distribution-free Approach
adf <- DiffBetaMC(adf)
Heteroskedasticity Consistent Approach (HC3)
hc3 <- DiffBetaMC(hc3)
Methods
summary
Summary of the results of DiffBetaMC()
.
summary(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.1361 20000 -0.3471 -0.2551 -0.1697 0.3643 0.4454 0.5263
#> NARTIC-PCTSUPP 0.2319 0.1250 20000 -0.2087 -0.1023 -0.0209 0.4704 0.5335 0.6083
#> PCTGRT-PCTSUPP 0.1282 0.1232 20000 -0.2893 -0.1978 -0.1176 0.3669 0.4445 0.5213
summary(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.1210 20000 -0.3039 -0.2089 -0.1364 0.3384 0.4029 0.4843
#> NARTIC-PCTSUPP 0.2319 0.1185 20000 -0.1493 -0.0722 -0.0039 0.4561 0.5372 0.6326
#> PCTGRT-PCTSUPP 0.1282 0.1220 20000 -0.2650 -0.1937 -0.1153 0.3636 0.4389 0.5356
summary(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.1424 20000 -0.3560 -0.2571 -0.1764 0.3828 0.4762 0.5724
#> NARTIC-PCTSUPP 0.2319 0.1330 20000 -0.2191 -0.1250 -0.0381 0.4808 0.5710 0.6497
#> PCTGRT-PCTSUPP 0.1282 0.1373 20000 -0.3645 -0.2459 -0.1523 0.3902 0.4697 0.5624
vcov
Return the sampling covariance matrix.
vcov(mvn)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> NARTIC-PCTGRT 0.018519368 0.009487353 -0.009032015
#> NARTIC-PCTSUPP 0.009487353 0.015631706 0.006144353
#> PCTGRT-PCTSUPP -0.009032015 0.006144353 0.015176369
vcov(adf)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> NARTIC-PCTGRT 0.014645917 0.006907124 -0.007738793
#> NARTIC-PCTSUPP 0.006907124 0.014040403 0.007133279
#> PCTGRT-PCTSUPP -0.007738793 0.007133279 0.014872072
vcov(hc3)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> NARTIC-PCTGRT 0.020287327 0.009554342 -0.010732985
#> NARTIC-PCTSUPP 0.009554342 0.017678664 0.008124322
#> PCTGRT-PCTSUPP -0.010732985 0.008124322 0.018857307
confint
Return confidence intervals.
confint(mvn, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC-PCTGRT -0.16972827 0.3642998
#> NARTIC-PCTSUPP -0.02091966 0.4704287
#> PCTGRT-PCTSUPP -0.11764157 0.3668513
confint(adf, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC-PCTGRT -0.136387568 0.3384211
#> NARTIC-PCTSUPP -0.003906558 0.4561149
#> PCTGRT-PCTSUPP -0.115258217 0.3635661
confint(hc3, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC-PCTGRT -0.17643869 0.3827983
#> NARTIC-PCTSUPP -0.03814171 0.4808161
#> PCTGRT-PCTSUPP -0.15230472 0.3901834
References
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. (2023). 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