conditional_Spearman computes the partial Spearman's rank
correlation between variable X and variable Y adjusting for
variable Z conditional on Zc. X and Y can be any
orderable variables, including continuous and discrete
variables. Covariate Z can be multidimensional. X, Y,
and Z are specified by the argument formula. Zc is a
one-dimensional covariate, specified by the argument
conditional.by. The basic approach involves fitting a specified
model of X on Z, a specified model of Y on Z,
obtaining the probability-scale residuals, Xres and Yres, from
both models, and then modeling their Pearson's correlation conditional on
Zc. Different methods are provided to model the Pearson's
correlation between the two sets of probability-scale residuals. See
details in conditional.method. As in partial.Spearman, by
default conditional_Spearman uses cumulative link models for both
continous and discrete ordinal variables X and Y to preserve
the rank-based nature of Spearman's correlation. For some specific types
of variables, options of fitting parametric models are also available. See
details in fit.x and fit.y.
conditional_Spearman(
formula,
conditional.by,
data,
conditional.method = c("lm", "kernel", "stratification"),
conditional.formula = paste("~", conditional.by, sep = ""),
kernel.function = c("normal", "gaussian", "triweight", "quartic", "biweight",
"epanechnikov", "uniform", "triangle"),
kernel.bandwidth = "silverman",
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 conditional_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’.
the name of the variable on which the partial Spearman's correlation is conditional. See ‘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 conditional_Spearman is called.
the method to be used for modeling conditional correlation between probability-scale residuals. The default option is lm, which fits linear regression models for XresYres on Zc, Xres^2 on Zc, and Yres^2 on Zc, and then uses the fitted values to compute the Pearson's correlation between Xres and Yres conditional on Zc. Other options include kernel, which computes correlation between Xres and Yres conditional on Zc using a kernel weighted method, and stratification, which computes the correlation between Xres and Yres seperately for each value of Zc.
the formula to be used when conditional.method is specified as lm.
the kernel function to be used when conditional.method is specified as kernel. Defaults to normal. Other options are triweight, quartic, biweight, epanechnikov, uniform, and triangle.
the kernel bandwidth to be used when conditional.method is specified as kernel. The default value is calculated using Silverman' rule. Users can also specify a positive numeric value.
the fitting functions used for the model of X or Y on Z. The default function is orm, which fits cumulative link models for continuous or discrete ordinal variables. Other options include lm (fit linear regression models and obtain the probability-scale residuals by assuming normality), lm.emp (fit linear regression and obtain the probability-scale residuals by empirical ranking), poisson (fit Poisson models for count variables), nb (fit negative binomial models for count variables), and logistic (fit 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, 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 conditional on Zc, formula is
specified as X | Y ~ Z and conditional.by
is specified as Zc. This indicates that models of X ~
Z and Y ~ Z will be fit, and the correlation
between the probability-scale residuals from these two models will be
modeled conditional on Zc.
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.conditional_Spearman,print.conditional_Spearman
data(PResidData)
library(rms)
#### fitting cumulative link models for both Y and W
result <- conditional_Spearman(c|y~ x + w, conditional.by="w",
conditional.method="lm", conditional.formula="~rcs(w)",
fit.x="poisson",fit.y="orm",
data=PResidData, fisher=TRUE)
plot(result)
Run the code above in your browser using DataLab