Title: | Zero Order vs (Semi) Partial Correlation Test and CI |
---|---|
Description: | Uses bootstrap to test zero order correlation being equal to a partial or semi-partial correlation (one or two tailed). Confidence intervals for the parameter (zero order minus partial) can also be determined. Implements the bias-corrected and accelerated bootstrap method as described in "An Introduction to the Bootstrap" Efron (1983) <0-412-04231-2>. |
Authors: | Dan Richard [aut, cre], Karen Buro [ctb], Wanhua Su [ctb] |
Maintainer: | Dan Richard <[email protected]> |
License: | GPL-2 |
Version: | 0.1.0 |
Built: | 2025-02-04 02:37:20 UTC |
Source: | https://github.com/djrichar92/zeroeqpart |
Calculate the statistical significance of a zero order correlation being equal to a partial or semi-partial correlation using the bias-corrected and accelerated bootstrap method from "An Introduction to the Bootstrap" Efron (1983) <0-412-04231-2>. Confidence intervals for the parameter (zero order minus partial) can also be determined.
The pzcor
function tests one of the following null
hypotheses:
(default)
See pzcor
for details.
The pzconf
function computes confidence intervals
for the parameter: . To be used with
pzcor
. See pzconf
for details.
Maintainer: Dan Richard [email protected]
Other contributors:
Karen Buro [email protected] [contributor]
Wanhua Su [email protected] [contributor]
Useful links:
Report bugs at https://github.com/djrichar92/zeroEQpart/issues
The pzconf
function calculates confidence intervals for a
zero order correlation minus a (semi) partial correlation (). It is intended to be used after the
pzcor
function.
pzconf(pzcor_obj, level = 0.9)
pzconf(pzcor_obj, level = 0.9)
pzcor_obj |
pzcor object (output from pzcor function). |
level |
numerical. Confidence level used to calculate the confidence interval. This may be a vector so multiple intervals can be determined. |
The pzconf
function calculates confidence intervals based on
the bootstrap distribution determined from the pzcor
function. See ?pzcor
for details.
The confidence interval(s) is(are) displayed in a dataframe with four columns: Level, Lower, Upper, and Warnings. Level refers to the confidence level of the interval. Lower and Upper are the respective lower and upper bounds of the interval. Warnings may say "Max Level Passed" to show that the specified confidence level exceeds the largest confidence interval that can be determined from the test. The largest confidence interval is shown in the last row (named "Max").
require(graphics) require(MASS) # data set.seed(1111) mu <- rep(0,4) Sigma <- matrix(.2, nrow=4, ncol=4) + diag(4)*.8 data <- mvrnorm(n=100, mu=mu, Sigma=Sigma) # p.(1,2) = p.(1,2)|(3,4) test test <- pzcor(data[,1], data[,2], data[,c(3,4)], k = 2000) hist(test$distribution) pzconf(test, c(0.9, 0.95, 0.99))
require(graphics) require(MASS) # data set.seed(1111) mu <- rep(0,4) Sigma <- matrix(.2, nrow=4, ncol=4) + diag(4)*.8 data <- mvrnorm(n=100, mu=mu, Sigma=Sigma) # p.(1,2) = p.(1,2)|(3,4) test test <- pzcor(data[,1], data[,2], data[,c(3,4)], k = 2000) hist(test$distribution) pzconf(test, c(0.9, 0.95, 0.99))
Compute a bootstrap test to determine whether zero order correlation is equal to partial or semi-partial correlation.
pzcor(x, y, z, semi = FALSE, k = 1000, method = "pearson", test = "eq")
pzcor(x, y, z, semi = FALSE, k = 1000, method = "pearson", test = "eq")
x |
a numeric vector. |
y |
a numeric vector. |
z |
a numeric vector (data.frame, matrix, etc.) |
semi |
logical. If |
k |
the number of bootstrap samples taken (default is 1000). |
method |
a character string indicating which correlation coefficient is to be computed. One of "pearson" (default), "kendall", or "spearman" can be abbreviated. |
test |
character string denoting the null hypothesis to be tested. Can be one of the three:
|
Uses the bias-corrected and accelerated (BCa) bootstrap method to
test if the difference is equal to, above, or
below zero where
is the zero order correlation between
variables
and
, and
is the (semi) partial
correlation between the respective variables after partialing out
variables represented by
.
If the bootstrap distribution of
is strictly above or below zero, then
the p-value provided is the most extreme value that can be determined
by the test. In the case of highly correlated variables, the
covariance matrix may be singular which will lead to
k_eff
being
less than k
(as would not be computed).
acceleration |
the acceleration used for the BCa method. |
alpha |
the proportion of the bootstrapped distribution below zero. |
bias |
the bias used for the BCa method. |
call |
shows the function call. |
difference |
calculated from the data. Same as |
distribution |
the estimated distribution of the difference as determined through bootstrapping. |
k_eff |
the number of successful bootstrap samples. Less than or equal
to |
method |
the method of correlation used. |
p.value |
significance level of the test. |
p.xy |
Zero order correlation between |
p.xy.z |
(semi) partial correlation between |
semi |
logical. If |
test |
shows the type of test performed. |
require(graphics) require(MASS) # data set.seed(1111) mu <- rep(0,4) Sigma <- matrix(.2, nrow=4, ncol=4) + diag(4)*.8 data <- mvrnorm(n=100, mu=mu, Sigma=Sigma) # p.(1,2) = p.(1,2)|(3,4) test test <- pzcor(data[,1], data[,2], data[,c(3,4)], k = 2000, semi = FALSE, test = 'eq') hist(test$distribution) test
require(graphics) require(MASS) # data set.seed(1111) mu <- rep(0,4) Sigma <- matrix(.2, nrow=4, ncol=4) + diag(4)*.8 data <- mvrnorm(n=100, mu=mu, Sigma=Sigma) # p.(1,2) = p.(1,2)|(3,4) test test <- pzcor(data[,1], data[,2], data[,c(3,4)], k = 2000, semi = FALSE, test = 'eq') hist(test$distribution) test