betaMC: Example Using the DeltaRSqMC Function
Ivan Jacob Agaloos Pesigan
Source:vignettes/example-delta-r-sq-mc.Rmd
example-delta-r-sq-mc.Rmd
Confidence intervals for improvement in R-squared are generated using
the DeltaRSqMC()
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")
Improvement in R-squared
Normal-Theory Approach
mvn <- DeltaRSqMC(mvn)
Asymptotic distribution-free Approach
adf <- DeltaRSqMC(adf)
Heteroskedasticity Consistent Approach (HC3)
hc3 <- DeltaRSqMC(hc3)
Methods
summary
Summary of the results of DeltaRSqMC()
.
summary(mvn)
#> Call:
#> DeltaRSqMC(object = mvn)
#>
#> Improvement in R-squared
#> type = "mvn"
#> est se R 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> NARTIC 0.1859 0.0663 20000 0.0324 0.0510 0.0725 0.3283 0.3904 0.4682
#> PCTGRT 0.1177 0.0511 20000 0.0141 0.0244 0.0382 0.2365 0.2914 0.3703
#> PCTSUPP 0.0569 0.0338 20000 0.0007 0.0049 0.0103 0.1402 0.1785 0.2342
summary(adf)
#> Call:
#> DeltaRSqMC(object = adf)
#>
#> Improvement in R-squared
#> type = "adf"
#> est se R 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> NARTIC 0.1859 0.0581 20000 0.0097 0.0489 0.0752 0.3004 0.3580 0.4070
#> PCTGRT 0.1177 0.0471 20000 0.0046 0.0221 0.0377 0.2200 0.2664 0.3187
#> PCTSUPP 0.0569 0.0332 20000 0.0001 0.0027 0.0094 0.1359 0.1750 0.2280
summary(hc3)
#> Call:
#> DeltaRSqMC(object = hc3)
#>
#> Improvement in R-squared
#> type = "hc3"
#> est se R 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> NARTIC 0.1859 0.0688 20000 0.0027 0.0179 0.0505 0.3209 0.3819 0.4615
#> PCTGRT 0.1177 0.0546 20000 0.0013 0.0101 0.0255 0.2365 0.2908 0.3680
#> PCTSUPP 0.0569 0.0380 20000 0.0000 0.0007 0.0059 0.1510 0.1985 0.2629
vcov
Return the sampling covariance matrix.
vcov(mvn)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.0043967507 -0.0007416671 -0.0003426080
#> PCTGRT -0.0007416671 0.0026073591 -0.0002438695
#> PCTSUPP -0.0003426080 -0.0002438695 0.0011398590
vcov(adf)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 3.381355e-03 5.123872e-05 -0.0001508241
#> PCTGRT 5.123872e-05 2.222587e-03 -0.0002035564
#> PCTSUPP -1.508241e-04 -2.035564e-04 0.0011004900
vcov(hc3)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.0047367411 0.0001959008 -0.0000798251
#> PCTGRT 0.0001959008 0.0029764821 -0.0002064454
#> PCTSUPP -0.0000798251 -0.0002064454 0.0014451600
confint
Return confidence intervals.
confint(mvn, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.07254217 0.3283306
#> PCTGRT 0.03821573 0.2365150
#> PCTSUPP 0.01033739 0.1402019
confint(adf, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.075226344 0.3003562
#> PCTGRT 0.037748936 0.2199960
#> PCTSUPP 0.009441678 0.1358586
confint(hc3, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.050497720 0.3208681
#> PCTGRT 0.025510234 0.2364756
#> PCTSUPP 0.005882481 0.1510148
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