View source: R/partial_Spearman.R
| partial_Spearman | R Documentation |
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
)
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.
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 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.