parCor {TripleR} | R Documentation |
partial correlation
Description
Performs partial correlations between x and y, controlled for z.
Usage
parCor(x,y,z)
Arguments
x |
First variable |
y |
Second variable |
z |
Control variable. This variable is coerced into a factor; in the TripleR context z usually is the group id. |
Details
Performs partial correlations between x and y, controlled for z. The control variable is coerced into a factor; in the TripleR context z usually is the group id. Do not use this function with a continuous control variable - results will be wrong! Degrees of freedom for the t test are reduced by g - 1 (g is the number of groups).
Value
par.cor |
partial correlation |
df |
degrees of freedom for the t test |
t.value |
t value |
p |
p value |
See Also
Examples
data(multiGroup)
data(multiNarc)
# the function 'head' shows the first few lines of a data structure:
head(multiNarc)
# calculate SRA effects for extraversion ratings
RR.style("p")
RR1 <- RR(ex ~ perceiver.id * target.id | group.id, multiGroup, na.rm=TRUE)
# merge variables to one data set
dat <- merge(RR1$effects, multiNarc, by="id")
# We now have a combined data set with SRA effects and external self ratings:
head(dat)
# function parCor(x, y, z) computes partial correlation between x and y,
# controlled for group membership z
d1 <- parCor(dat$ex.t, dat$narc, dat$group.id)
d1
# disattenuate for target effect reliability
parCor2 <- d1$par.cor * (1/sqrt(attr(RR1$effects$ex.t, "reliability")))
parCor2
[Package TripleR version 1.5.4 Index]