Learn R Programming

miscor (version 0.1-0)

par.cor: Partial and semipartial correlation

Description

This function computes the partial or semipartial correlation coefficient between two vaiables. In addition, this function can test the partial or semipartial correlation coefficient for H0: $\rho .p = \rho$0, so that any value for $\rho$0 can be specified.

Usage

par.cor(x = NULL, y = NULL, p.xy = NULL, p.x = NULL, p.y = NULL, sig = FALSE, rho = 0, alternative = c("two.sided", "less", "greater"), reduced = FALSE, conf.level = 0.95, digits = 3, output = TRUE)

Arguments

x
a numeric vector.
y
a numeric vector.
p.xy
a numeric vector or data.frame, varialbe(s) residualized from x and y.
p.x
a numeric vector or data.frame, varialbe(s) residualized only from x.
p.y
a numeric vector or data.frame, varialbe(s) residualized only from y.
sig
logical: if TRUE, statistical significance test is conducted.
rho
a number indicating $\rho$0, the value under the null hypothesis.
alternative
a character string describing the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".
reduced
logical: if TRUE, compuatation is based on the reduced formula.
conf.level
confidence level of the interval.
digits
integer indicating the number of decimal places to be displayed.
output
logical: if TRUE, output is shown.

Value

Returns an object of class par.cor with following entries:
call
function call
dat
list with data for x.resid (x residualized), y.resid (y residualized), x, y, p.xy, p.y, and p.x
spec
specification of function argument method
res
list with results, i.e., t or z (test statistic), df (degree of freedom) pval (significance value), r.p (partial or semipartial correlation coefficient), n (sample size), lower (lower limit of CI), upper (upper limit of CI)

Details

Partial correlation is the correlation of x and y while statistically controlling for third variables specified in the argument p.xy. These variables are residualized from x and y using (multiple) regression models. Semipartial correlation is the correlation of x and y while statistically controlling for third variables only for x (specified in the argument p.x) or y (specified in the argument p.y). These variables are residualized from x or y using a (multiple) regression model.

References

Rasch, D., Kubinger, K. D., & Yanagida, T. (2011). Statistics in psychology - Using R and SPSS. New York: John Wiley & Sons.

See Also

test.cor, conf.cor, comptest.cor, seqtest.cor

Examples

Run this code
dat <- data.frame(x = c(4, 6, 8, 8, 9, 4),
                  y = c(3, 7, 9, 8, 9, 3),
                  z = c(1, 3, 4, 4, 5, 2))

#--------------------------------------
# Partial correlation

par.cor(dat$x, dat$y, p.xy = dat$z)

#--------------------------------------
# Semipartial correlation
# remove z from x

par.cor(dat$x, dat$y, p.x = dat$z)

#--------------------------------------
# Semipartial correlation
# remove z from y

par.cor(dat$x, dat$y, p.y = dat$y)

#--------------------------------------
# Partial correlation: Two-sided test
# H0: rho.p == 0, H1: rho.p != 0

par.cor(dat$x, dat$y, p.xy = dat$z, sig = TRUE)

#--------------------------------------
# Partial correlation: One-sided test
# H0: rho.p <= 0.2, H1: rho.p > 0.2

par.cor(dat$x, dat$y, p.xy = dat$z,
        sig = TRUE, rho = 0.4, alternative = "less")

Run the code above in your browser using DataLab