Description Usage Arguments Details Value Note Author(s) References See Also Examples

Computes the semi-partial association between a response variable and an explanatory variable, after controlling for a control variable.

1 |

`Y` |
the response variable, a vector or column from a dataset |

`X` |
the explanatory variable, a vector or column from a dataset |

`C` |
the control variable, a vector or column from a dataset |

A semi-partial association (possibly nonlinear) is computed via:

` ma(cbind(C,X,Y))$A - ma(cbind(C,Y))$A `

.

Inspired by the linear semi-partial correlation given by:

` spcor.test(Y,X,C) `

from the `ppcor`

package.

Returns a real number in the range [0,1].

The parameters Y, X and C must be vectors of the same length.

Ben Murrell, Dan Murrell & Hugh Murrell.

Discovering general multidimensional associations, http://arxiv.org/abs/1303.1828

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 | ```
# When the association between Y and X is entirely explained by C
C <- rnorm(1000)
X <- C+rnorm(1000)*0.5
Y <- C+rnorm(1000)*0.5
# See the relationship without controlling for C
ma(cbind(X,Y))$A
# See the relationship with C as a covariate (should be close to 0)
spa(Y,X,C)
# if you have ppcor then you can verify that
# the linear semi-partial correlation is similar,
# as these associations are all linear
# spcor.test(Y,X,C)$estimate^2
#
# When the association between Y and X is only partially explained by C
C <- rnorm(1000)
X <- C+rnorm(1000)*0.5
Y <- X+rnorm(1000)*0.5
# See the relationship without controlling for C
ma(cbind(X,Y))$A
# See the relationship with C as a covariate
# (should be lower than the uncontrolled one, but not as low as 0)
spa(Y,X,C)
# if you have ppcor then you can verify that
# the linear semi-partial correlation is similar,
# as these associations are all linear
# spcor.test(Y,X,C)$estimate^2
#
#
# if you have rgl you can plot the data
# library(rgl)
# plot3d(X,C,Y)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.