Calculates Spearmans's rho, Kendall's tau, or Pearson's r with confidence intervals by bootstrap
spearmanRho(
formula = NULL,
data = NULL,
x = NULL,
y = NULL,
method = "spearman",
ci = FALSE,
conf = 0.95,
type = "perc",
R = 1000,
histogram = FALSE,
digits = 3,
reportIncomplete = FALSE,
...
)
A single statistic, rho, tau, or r. Or a small data frame consisting of rho, tau, or r, and the lower and upper confidence limits.
A formula indicating the two paired variables,
e.g. ~ x + y
. The variables should be
vectors of the same length.
The data frame to use.
If no formula is given, the values for one variable.
The values for the other variable.
One of "spearman", "kendall", or "pearson".
Passed to cor
.
If TRUE
, returns confidence intervals by bootstrap.
May be slow.
The level for the confidence interval.
The type of confidence interval to use.
Can be any of "norm
", "basic
",
"perc
", or "bca
".
Passed to boot.ci
.
The number of replications to use for bootstrap.
If TRUE
, produces a histogram of bootstrapped values.
The number of significant digits in the output.
If FALSE
(the default),
NA
will be reported in cases where there
are instances of the calculation of the statistic
failing during the bootstrap procedure.
Additional arguments passed to the cor
function.
Salvatore Mangiafico, mangiafico@njaes.rutgers.edu
This function is a wrapper for stats::cor
with the addition of confidence intervals.
The input should include either formula
and data
;
or x
, and y
.
Currently, the function makes no provisions for NA
values in the data. It is recommended that NA
s be removed
beforehand.
When the returned statistic is close to -1 or close to 1, or with small sample size, the confidence intervals determined by this method may not be reliable, or the procedure may fail.
data(Catbus)
spearmanRho( ~ Steps + Rating, data=Catbus)
Run the code above in your browser using DataLab