conditional_Spearman {PResiduals} | R Documentation |
Conditional Partial Spearman's Rank Correlation
Description
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’.
Usage
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
)
Arguments
formula |
an object of class |
conditional.by |
the name of the variable on which the partial Spearman's correlation is conditional. See ‘Details’. |
data |
an optional data frame, list or environment (or object
coercible by |
conditional.method |
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. |
conditional.formula |
the formula to be used when ‘conditional.method’ is specified as ‘lm’. |
kernel.function |
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’. |
kernel.bandwidth |
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. |
fit.x , fit.y |
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). |
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’, ‘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. |
Details
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.
Value
object of ‘conditional_Spearman’ class.
References
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.
See Also
print.conditional_Spearman
,print.conditional_Spearman
Examples
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)