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.0659 20000 0.0339 0.0529 0.0739 0.3297 0.3903 0.4734
#> PCTGRT 0.1177 0.0502 20000 0.0146 0.0245 0.0376 0.2311 0.2838 0.3537
#> PCTSUPP 0.0569 0.0338 20000 0.0005 0.0048 0.0105 0.1392 0.1838 0.2408
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.3002 0.3580 0.4070
#> PCTGRT 0.1177 0.0472 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.0691 20000 0.0024 0.0173 0.0503 0.3238 0.3799 0.4504
#> PCTGRT 0.1177 0.0546 20000 0.0014 0.0100 0.0261 0.2375 0.2924 0.3875
#> PCTSUPP 0.0569 0.0372 20000 0.0000 0.0010 0.0063 0.1478 0.1916 0.2511
vcov
Return the sampling covariance matrix.
vcov(mvn)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.0043457242 -0.0006771919 -0.0003681941
#> PCTGRT -0.0006771919 0.0025166832 -0.0002208458
#> PCTSUPP -0.0003681941 -0.0002208458 0.0011444392
vcov(adf)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 3.379217e-03 5.175543e-05 -0.0001495936
#> PCTGRT 5.175543e-05 2.223189e-03 -0.0002040564
#> PCTSUPP -1.495936e-04 -2.040564e-04 0.0011010524
vcov(hc3)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 4.779979e-03 0.0001397646 -4.497515e-05
#> PCTGRT 1.397646e-04 0.0029825017 -1.664104e-04
#> PCTSUPP -4.497515e-05 -0.0001664104 1.381748e-03
confint
Return confidence intervals.
confint(mvn, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.07386667 0.3297093
#> PCTGRT 0.03760518 0.2311156
#> PCTSUPP 0.01048671 0.1392182
confint(adf, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.075226343 0.3001664
#> PCTGRT 0.037748937 0.2200020
#> PCTSUPP 0.009441678 0.1358586
confint(hc3, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.050254864 0.3237600
#> PCTGRT 0.026063453 0.2374537
#> PCTSUPP 0.006321508 0.1478487
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