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.0657 20000 0.0309 0.0503 0.0729 0.3272 0.3875 0.4620
#> PCTGRT 0.1177 0.0513 20000 0.0124 0.0242 0.0374 0.2361 0.2942 0.3851
#> PCTSUPP 0.0569 0.0336 20000 0.0005 0.0036 0.0102 0.1387 0.1781 0.2372
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.0576 20000 0.0156 0.0473 0.0733 0.2982 0.3477 0.4108
#> PCTGRT 0.1177 0.0472 20000 0.0091 0.0221 0.0368 0.2211 0.2645 0.3248
#> PCTSUPP 0.0569 0.0336 20000 0.0001 0.0026 0.0085 0.1392 0.1774 0.2291
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.0694 20000 0.0019 0.0187 0.0499 0.3235 0.3834 0.4516
#> PCTGRT 0.1177 0.0543 20000 0.0016 0.0097 0.0250 0.2349 0.2903 0.3713
#> PCTSUPP 0.0569 0.0378 20000 0.0000 0.0012 0.0062 0.1509 0.1971 0.2649
vcov
Return the sampling covariance matrix.
vcov(mvn)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.0043117575 -0.0007205239 -0.0003511529
#> PCTGRT -0.0007205239 0.0026351662 -0.0002277555
#> PCTSUPP -0.0003511529 -0.0002277555 0.0011261206
vcov(adf)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 3.320267e-03 4.865638e-05 -0.0001492849
#> PCTGRT 4.865638e-05 2.226633e-03 -0.0002002510
#> PCTSUPP -1.492849e-04 -2.002510e-04 0.0011304740
vcov(hc3)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 4.818180e-03 0.0001916846 -7.574705e-05
#> PCTGRT 1.916846e-04 0.0029536297 -2.033832e-04
#> PCTSUPP -7.574705e-05 -0.0002033832 1.429807e-03
confint
Return confidence intervals.
confint(mvn, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.07287122 0.3271884
#> PCTGRT 0.03740188 0.2360502
#> PCTSUPP 0.01015960 0.1386579
confint(adf, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.073287742 0.2981932
#> PCTGRT 0.036769602 0.2210690
#> PCTSUPP 0.008535517 0.1391668
confint(hc3, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.049939802 0.3235255
#> PCTGRT 0.025049155 0.2348550
#> PCTSUPP 0.006151335 0.1509104
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