Description Usage Arguments Details Value References See Also Examples
View source: R/partial_Spearman.R
partial_Spearman
computes the partial Spearman's rank correlation between variable X and variable Y adjusting for other variables, Z.
The basic approach involves fitting a specified model of X on Z, a specified model of Y on Z, obtaining the probability-scale residuals from both models, and then calculating their Pearson's correlation.
X and Y can be any orderable variables, including continuous or discrete variables.
By default, partial_Spearman
uses cumulative probability models (also referred as cumulative link models in literature) for both X on Z and Y on Z to preserve the rank-based nature of Spearman's correlation, since the model fit of cumulative probability models only depends on the order information of variables. However, for some specific types of variables, options of fitting parametric models are also available. See details in fit.x and fit.y
1 2 3 4 5 6 7 8 9 10 11 12 |
formula |
an object of class |
data |
an optional data frame, list or environment (or object
coercible by |
fit.x, fit.y |
the fitting functions used for the models of X or Y on Z. The default function is orm, which fits cumulative probability models for continuous or discrete ordinal variables. Other options include lm, which fits linear regression models and obtains the probability-scale residuals by assuming normality; lm.emp, which fits linear regression models and obtains the probability-scale residuals by empirical ranking; poisson, which fits Poisson models for count variables; nb, which fits negative binomial models for count variables; and logistic, which fits logistic regression models for binary variables. |
link.x, link.y |
the link family to be used for the ordinal model of X on Z. Defaults to logit. Other options are probit, cloglog, loglog, cauchit and logistic (equivalent with logit). Used only when fit.x is orm. |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
na.action |
action to take when |
fisher |
logical indicating whether to apply fisher transformation to compute confidence intervals and p-values for the correlation. |
conf.int |
numeric specifying confidence interval coverage. |
To compute the partial Spearman's rank correlation between X and Y adjusting for Z, formula is specified as X | Y ~ Z
.
This indicates that models of X ~ Z
and
Y ~ Z
will be fit.
object of partial_Spearman class.
Li C and Shepherd BE (2012) A new residual for ordinal outcomes. Biometrika. 99: 473–480.
Shepherd BE, Li C, Liu Q (2016) Probability-scale residuals for continuous, discrete, and censored data. The Canadian Jouranl of Statistics. 44:463–476.
Liu Q, Shepherd BE, Wanga V, Li C (2018) Covariate-Adjusted Spearman's Rank Correlation with Probability-Scale Residuals. Biometrics. 74:595–605.
1 2 3 4 5 6 | data(PResidData)
#### fitting cumulative probability models for both Y and W
partial_Spearman(c|w ~ z,data=PResidData)
#### fitting a cumulative probability model for W and a poisson model for c
partial_Spearman(c|w~z, fit.x="poisson",data=PResidData)
partial_Spearman(c|w~z, fit.x="poisson", fit.y="lm.emp", data=PResidData )
|
est stderr p lower CI upper CI
partial Spearman -0.1663307 0.06629574 0.0138016 -0.2927075 -0.03424278
Fisher Transform: TRUE
Confidence Interval: 95%
Number of Observations: 200
est stderr p lower CI upper CI
partial Spearman -0.1776834 0.06945729 0.01228052 -0.3096528 -0.03899789
Fisher Transform: TRUE
Confidence Interval: 95%
Number of Observations: 200
est stderr p lower CI upper CI
partial Spearman -0.1748246 0.06939862 0.01360643 -0.306743 -0.03631602
Fisher Transform: TRUE
Confidence Interval: 95%
Number of Observations: 200
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.