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.1355 20000 -0.3799 -0.2534 -0.1678 0.3636 0.4346 0.5345
#> NARTIC-PCTSUPP 0.2319 0.1246 20000 -0.1961 -0.1027 -0.0190 0.4657 0.5407 0.6256
#> PCTGRT-PCTSUPP 0.1282 0.1221 20000 -0.2617 -0.1915 -0.1132 0.3660 0.4493 0.5222
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.1207 20000 -0.2849 -0.2066 -0.1348 0.3366 0.4053 0.4826
#> NARTIC-PCTSUPP 0.2319 0.1183 20000 -0.1761 -0.0821 -0.0077 0.4590 0.5321 0.6219
#> PCTGRT-PCTSUPP 0.1282 0.1212 20000 -0.2860 -0.1928 -0.1145 0.3616 0.4366 0.5067
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.1418 20000 -0.3656 -0.2617 -0.1736 0.3791 0.4652 0.5684
#> NARTIC-PCTSUPP 0.2319 0.1331 20000 -0.2243 -0.1275 -0.0378 0.4826 0.5576 0.6612
#> PCTGRT-PCTSUPP 0.1282 0.1372 20000 -0.3286 -0.2347 -0.1464 0.3871 0.4649 0.5444
vcov
Return the sampling covariance matrix.
vcov(mvn)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> NARTIC-PCTGRT 0.018354660 0.009483257 -0.008871403
#> NARTIC-PCTSUPP 0.009483257 0.015525729 0.006042472
#> PCTGRT-PCTSUPP -0.008871403 0.006042472 0.014913875
vcov(adf)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> NARTIC-PCTGRT 0.014559232 0.006928914 -0.007630318
#> NARTIC-PCTSUPP 0.006928914 0.013983955 0.007055041
#> PCTGRT-PCTSUPP -0.007630318 0.007055041 0.014685360
vcov(hc3)
#> NARTIC-PCTGRT NARTIC-PCTSUPP PCTGRT-PCTSUPP
#> NARTIC-PCTGRT 0.020097625 0.009489245 -0.010608380
#> NARTIC-PCTSUPP 0.009489245 0.017709672 0.008220427
#> PCTGRT-PCTSUPP -0.010608380 0.008220427 0.018828807
confint
Return confidence intervals.
confint(mvn, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC-PCTGRT -0.16780803 0.3636429
#> NARTIC-PCTSUPP -0.01895561 0.4657480
#> PCTGRT-PCTSUPP -0.11322481 0.3659768
confint(adf, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC-PCTGRT -0.134830802 0.3365734
#> NARTIC-PCTSUPP -0.007664018 0.4590029
#> PCTGRT-PCTSUPP -0.114513106 0.3615672
confint(hc3, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC-PCTGRT -0.17359895 0.3790514
#> NARTIC-PCTSUPP -0.03776915 0.4826152
#> PCTGRT-PCTSUPP -0.14637956 0.3870592
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. https://doi.org/10.3758/s13428-023-02114-4