/
example-p-cor-mc.Rmd
145 lines (109 loc) · 2.15 KB
/
example-p-cor-mc.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
---
title: "betaMC: Example Using the PCorMC Function"
author: "Ivan Jacob Agaloos Pesigan"
output: rmarkdown::html_vignette
bibliography: "vignettes.bib"
csl: https://raw.githubusercontent.com/citation-style-language/styles/master/apa.csl
nocite: |
@Pesigan-Cheung-2023
@Dudgeon-2017
vignette: >
%\VignetteIndexEntry{betaMC: Example Using the PCorMC Function}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
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](example-beta-mc.html).
```{r}
#| message = FALSE
library(betaMC)
```
```{r}
#| echo = FALSE
if (!exists("nas1982")) {
try(
data(
"nas1982",
package = "betaMC"
),
silent = TRUE
)
}
df <- nas1982
```
```{r}
#| eval = FALSE
df <- betaMC::nas1982
```
### Regression
Fit the regression model using the `lm()` function.
```{r}
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = df)
```
### Monte Carlo Sampling Distribution of Parameters
#### Normal-Theory Approach
```{r}
mvn <- MC(object, type = "mvn")
```
#### Asymptotic distribution-free Approach
```{r}
adf <- MC(object, type = "adf")
```
#### Heteroskedasticity Consistent Approach (HC3)
```{r}
hc3 <- MC(object, type = "hc3")
```
### Squared Partial Correlation Coefficients
#### Normal-Theory Approach
```{r}
mvn <- PCorMC(mvn)
```
#### Asymptotic distribution-free Approach
```{r}
adf <- PCorMC(adf)
```
#### Heteroskedasticity Consistent Approach (HC3)
```{r}
hc3 <- PCorMC(hc3)
```
## Methods
### summary
Summary of the results of `PCorMC()`.
```{r}
summary(mvn)
summary(adf)
summary(hc3)
```
### coef
Return the vector of estimates.
```{r}
coef(mvn)
coef(adf)
coef(hc3)
```
### vcov
Return the sampling covariance matrix.
```{r}
vcov(mvn)
vcov(adf)
vcov(hc3)
```
### confint
Return confidence intervals.
```{r}
confint(mvn, level = 0.95)
confint(adf, level = 0.95)
confint(hc3, level = 0.95)
```
## References