betaMC: Example Using the PCorMC Function
Ivan Jacob Agaloos Pesigan
Source:vignettes/example-p-cor-mc.Rmd
example-p-cor-mc.Rmd
Confidence intervals for squared partial correlation coefficients are
generated using the PCorMC()
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")
Squared Partial Correlation Coefficients
Normal-Theory Approach
mvn <- PCorMC(mvn)
Asymptotic distribution-free Approach
adf <- PCorMC(adf)
Heteroskedasticity Consistent Approach (HC3)
hc3 <- PCorMC(hc3)
Methods
summary
Summary of the results of PCorMC()
.
summary(mvn)
#> Call:
#> PCorMC(object = mvn)
#>
#> Squared partial correlations
#> type = "mvn"
#> est se R 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> NARTIC 0.4874 0.1049 20000 0.1034 0.1848 0.2440 0.6505 0.7072 0.7681
#> PCTGRT 0.3757 0.1082 20000 0.0492 0.0985 0.1443 0.5657 0.6284 0.7117
#> PCTSUPP 0.2254 0.0991 20000 0.0023 0.0171 0.0459 0.4272 0.5040 0.6135
summary(adf)
#> Call:
#> PCorMC(object = adf)
#>
#> Squared partial correlations
#> type = "adf"
#> est se R 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> NARTIC 0.4874 0.0982 20000 0.0497 0.1669 0.2446 0.6273 0.6845 0.7390
#> PCTGRT 0.3757 0.0999 20000 0.0448 0.0942 0.1504 0.5374 0.5903 0.6624
#> PCTSUPP 0.2254 0.1040 20000 0.0003 0.0108 0.0353 0.4361 0.5104 0.6065
summary(hc3)
#> Call:
#> PCorMC(object = hc3)
#>
#> Squared partial correlations
#> type = "hc3"
#> est se R 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> NARTIC 0.4874 0.1197 20000 0.0090 0.0790 0.1751 0.6493 0.7096 0.7874
#> PCTGRT 0.3757 0.1155 20000 0.0074 0.0452 0.1043 0.5530 0.6153 0.6901
#> PCTSUPP 0.2254 0.1126 20000 0.0000 0.0047 0.0254 0.4569 0.5346 0.6370
vcov
Return the sampling covariance matrix.
vcov(mvn)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.0110123181 0.0006788020 0.0004072997
#> PCTGRT 0.0006788020 0.0116981645 0.0002504233
#> PCTSUPP 0.0004072997 0.0002504233 0.0098156649
vcov(adf)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.009636431 0.0024215917 0.0019630480
#> PCTGRT 0.002421592 0.0099823353 0.0007595656
#> PCTSUPP 0.001963048 0.0007595656 0.0108131386
vcov(hc3)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.014330661 0.004035119 0.002836184
#> PCTGRT 0.004035119 0.013344289 0.001024676
#> PCTSUPP 0.002836184 0.001024676 0.012672581
confint
Return confidence intervals.
confint(mvn, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.24398002 0.6505411
#> PCTGRT 0.14431654 0.5657123
#> PCTSUPP 0.04590714 0.4271904
confint(adf, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.24459215 0.6272720
#> PCTGRT 0.15036268 0.5374011
#> PCTSUPP 0.03525408 0.4360711
confint(hc3, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.17513963 0.6492983
#> PCTGRT 0.10431428 0.5530302
#> PCTSUPP 0.02542185 0.4568997
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