biVar is a generic function that accepts a formula and usual
na.action parameters plus a
statinfo that specifies a function of two variables to
compute along with information about labeling results for printing and
plotting. The function is called separately with each right hand side
variable and the same left hand variable. The result is a matrix of
bivariate statistics and the
statinfo list that drives printing
and plotting. The plot method draws a dot plot with x-axis values by
default sorted in order of one of the statistics computed by the function.
spearman2 computes the square of Spearman's rho rank correlation
and a generalization of it in which
x can relate
y. This is done by computing the Spearman
multiple rho-squared between
(rank(x), rank(x)^2) and
x is categorical, a different kind of Spearman correlation
used in the Kruskal-Wallis test is computed (and
spearman2 can do
the Kruskal-Wallis test). This is done by computing the ordinary
k-1 dummy variables and
also be a formula, in which case each predictor is correlated separately
y, using non-missing observations for that predictor.
biVar is used to do the looping and bookkeeping. By default the
plot shows the adjusted
rho^2, using the same formula used for
the ordinary adjusted
F test uses the unadjusted
spearman computes Spearman's rho on non-missing values of two
spearman.test is a simple version of
chiSquare is set up like
spearman2 except it is intended
for a categorical response variable. Separate Pearson chi-square tests
are done for each predictor, with optional collapsing of infrequent
categories. Numeric predictors having more than
g levels are
g quantile groups.
biVar(formula, statinfo, data=NULL, subset=NULL, na.action=na.retain, exclude.imputed=TRUE, ...) ## S3 method for class 'biVar' print(x, ...) ## S3 method for class 'biVar' plot(x, what=info$defaultwhat, sort.=TRUE, main, xlab, vnames=c('names','labels'), ...) spearman2(x, ...) ## Default S3 method: spearman2(x, y, p=1, minlev=0, na.rm=TRUE, exclude.imputed=na.rm, ...) ## S3 method for class 'formula' spearman2(formula, data=NULL, subset, na.action=na.retain, exclude.imputed=TRUE, ...) spearman(x, y) spearman.test(x, y, p=1) chiSquare(formula, data=NULL, subset=NULL, na.action=na.retain, exclude.imputed=TRUE, ...)
a formula with a single left side variable
the usual options for models. Default for
other arguments that are passed to the function used to
compute the bivariate statistics or to
logical; delete NA values?
a numeric matrix with at least 5 rows and at least 2 columns (if
a numeric vector
for numeric variables, specifies the order of the Spearman
minimum relative frequency that a level of a categorical predictor
should have before it is pooled with other categories (see
specifies which statistic to plot. Possibilities include the column names that appear with the print method is used.
main title for plot. Default title shows the name of the response variable.
x-axis label. Default constructed from
Uses midranks in case of ties, as described by Hollander and Wolfe.
P-values for Spearman, Wilcoxon, or Kruskal-Wallis tests are
approximated by using the
function that is called for a single
x, i.e., when there is no
formula) returns a vector of statistics for the variable.
chiSquare return a
matrix with rows corresponding to predictors.
Department of Biostatistics
Hollander M. and Wolfe D.A. (1973). Nonparametric Statistical Methods. New York: Wiley.
Press WH, Flannery BP, Teukolsky SA, Vetterling, WT (1988): Numerical Recipes in C. Cambridge: Cambridge University Press.
x <- c(-2, -1, 0, 1, 2) y <- c(4, 1, 0, 1, 4) z <- c(1, 2, 3, 4, NA) v <- c(1, 2, 3, 4, 5) spearman2(x, y) plot(spearman2(z ~ x + y + v, p=2)) f <- chiSquare(z ~ x + y + v) f
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.