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
partial_Spearman(
formula,
data,
fit.x = "orm",
fit.y = "orm",
link.x = c("logit", "probit", "cloglog", "loglog", "cauchit", "logistic"),
link.y = c("logit", "probit", "cloglog", "loglog", "cauchit", "logistic"),
subset,
na.action = getOption("na.action"),
fisher = TRUE,
conf.int = 0.95
)object of partial_Spearman class.
an object of class Formula (or
one that can be coerced to that class): a symbolic description of the
model to be fitted. The details of model specification are given
under ‘Details’.
an optional data frame, list or environment (or object
coercible by as.data.frame to a data frame) containing
the variables in the model. If not found in data, the
variables are taken from environment(formula), typically the
environment from which partial_Spearman is called.
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.
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.
an optional vector specifying a subset of observations to be used in the fitting process.
action to take when NA present in data.
logical indicating whether to apply fisher transformation to compute confidence intervals and p-values for the correlation.
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.
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.
print.partial_Spearman
data(PResidData)
library(rms)
#### 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 )
Run the code above in your browser using DataLab