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.1357 20000 -0.3469 -0.2507 -0.1652 0.3649 0.4450 0.5439
#> NARTIC-PCTSUPP 0.2319 0.1251 20000 -0.2136 -0.0942 -0.0219 0.4703 0.5357 0.6068
#> PCTGRT-PCTSUPP 0.1282 0.1227 20000 -0.2852 -0.1902 -0.1155 0.3659 0.4363 0.5280
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.3385 0.4034 0.4865
#> NARTIC-PCTSUPP 0.2319 0.1185 20000 -0.1493 -0.0720 -0.0038 0.4561 0.5370 0.6326
#> PCTGRT-PCTSUPP 0.1282 0.1220 20000 -0.2671 -0.1939 -0.1154 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.1435 20000 -0.3560 -0.2623 -0.1770 0.3839 0.4728 0.5558
#> NARTIC-PCTSUPP 0.2319 0.1322 20000 -0.2109 -0.1131 -0.0352 0.4794 0.5682 0.6552
#> PCTGRT-PCTSUPP 0.1282 0.1364 20000 -0.3257 -0.2256 -0.1470 0.3879 0.4653 0.5499
vcov
Return the sampling covariance matrix.
vcov(mvn)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> NARTIC-PCTGRT 0.018423956 0.009506506 -0.008917450
#> NARTIC-PCTSUPP 0.009506506 0.015647252 0.006140746
#> PCTGRT-PCTSUPP -0.008917450 0.006140746 0.015058197
vcov(adf)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> NARTIC-PCTGRT 0.014645573 0.006896037 -0.007749536
#> NARTIC-PCTSUPP 0.006896037 0.014030954 0.007134917
#> PCTGRT-PCTSUPP -0.007749536 0.007134917 0.014884453
vcov(hc3)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> NARTIC-PCTGRT 0.020595223 0.009730846 -0.010864377
#> NARTIC-PCTSUPP 0.009730846 0.017474893 0.007744048
#> PCTGRT-PCTSUPP -0.010864377 0.007744048 0.018608424
confint
Return confidence intervals.
confint(mvn, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC-PCTGRT -0.16520875 0.364853
#> NARTIC-PCTSUPP -0.02193225 0.470267
#> PCTGRT-PCTSUPP -0.11550774 0.365932
confint(adf, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC-PCTGRT -0.136359460 0.3384644
#> NARTIC-PCTSUPP -0.003803225 0.4560676
#> PCTGRT-PCTSUPP -0.115396599 0.3635661
confint(hc3, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC-PCTGRT -0.17699199 0.3838620
#> NARTIC-PCTSUPP -0.03519803 0.4794462
#> PCTGRT-PCTSUPP -0.14699925 0.3879036
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