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.1056 20000 0.1215 0.1809 0.2439 0.6515 0.7070 0.7729
#> PCTGRT 0.3757 0.1069 20000 0.0502 0.0972 0.1474 0.5596 0.6226 0.6930
#> PCTSUPP 0.2254 0.0992 20000 0.0040 0.0204 0.0467 0.4290 0.5044 0.5855
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.0997 20000 0.0381 0.1502 0.2411 0.6329 0.6893 0.7518
#> PCTGRT 0.3757 0.1004 20000 0.0334 0.0880 0.1460 0.5378 0.5936 0.6666
#> PCTSUPP 0.2254 0.1029 20000 0.0005 0.0094 0.0368 0.4335 0.5047 0.5897
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.1182 20000 0.0107 0.0703 0.1823 0.6484 0.7049 0.7693
#> PCTGRT 0.3757 0.1155 20000 0.0120 0.0432 0.1042 0.5552 0.6156 0.6809
#> PCTSUPP 0.2254 0.1129 20000 0.0001 0.0045 0.0247 0.4573 0.5384 0.6394
vcov
Return the sampling covariance matrix.
vcov(mvn)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.0111487115 0.0006724485 0.0004536990
#> PCTGRT 0.0006724485 0.0114185368 0.0001269709
#> PCTSUPP 0.0004536990 0.0001269709 0.0098353123
vcov(adf)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.009937808 0.0024649569 0.0020029526
#> PCTGRT 0.002464957 0.0100806859 0.0007876848
#> PCTSUPP 0.002002953 0.0007876848 0.0105864956
vcov(hc3)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.013963218 0.003683862 0.002837285
#> PCTGRT 0.003683862 0.013341058 0.001040909
#> PCTSUPP 0.002837285 0.001040909 0.012740569
confint
Return confidence intervals.
confint(mvn, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.24389871 0.6515232
#> PCTGRT 0.14737337 0.5596304
#> PCTSUPP 0.04666183 0.4290453
confint(adf, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.24105542 0.6329125
#> PCTGRT 0.14596278 0.5377823
#> PCTSUPP 0.03683088 0.4334947
confint(hc3, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.18231145 0.6483509
#> PCTGRT 0.10422425 0.5552033
#> PCTSUPP 0.02474608 0.4573151
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