help spearman, help ktau dialogs: spearman ktau
-------------------------------------------------------------------------------
Title
[R] spearman -- Spearman's and Kendall's correlations
Syntax
Spearman's rank correlation coefficients
spearman [varlist] [if] [in] [, spearman_options]
Kendall's rank correlation coefficients
ktau [varlist] [if] [in] [, ktau_options]
spearman_options description
-------------------------------------------------------------------------
Main
stats(spearman_list) list of statistics; select up to three
statistics; default is stats(rho)
print(#) significance level for displaying coefficients
star(#) significance level for displaying with a star
bonferroni use Bonferroni-adjusted significance level
sidak use Sidak-adjusted significance level
pw calculate all pairwise correlation coefficients
by using all available data
matrix display output in matrix form
-------------------------------------------------------------------------
ktau_options description
-------------------------------------------------------------------------
Main
stats(ktau_list) list of statistics; select up to six
statistics; default is stats(taua)
print(#) significance level for displaying coefficients
star(#) significance level for displaying with a star
bonferroni use Bonferroni-adjusted significance level
sidak use Sidak-adjusted significance level
pw calculate all pairwise correlation coefficients
by using all available data
matrix display output in matrix form
-------------------------------------------------------------------------
by is allowed with spearman and ktau; see [D] by.
where the elements of spearman_list may be
rho correlation coefficient
obs number of observations
p significance level
and the elements of ktau_list may be
taua correlation coefficient tau_a
taub correlation coefficient tau_b
score score
se standard error of score
obs number of observations
p significance level
Menu
ssbf spearman
Statistics > Nonparametric analysis > Tests of hypotheses >
Spearman's rank correlation
ktau
Statistics > Nonparametric analysis > Tests of hypotheses > Kendall's
rank correlation
Description
spearman displays Spearman's rank correlation coefficients for all pairs
of variables in varlist or, if varlist is not specified, for all the
variables in the dataset.
ktau displays Kendall's rank correlation coefficients between the
variables in varlist or, if varlist is not specified, for all the
variables in the dataset. ktau is intended for use on small- and
moderate-sized datasets; it requires considerable computation time for
larger datasets.
Options for spearman
+------+
----+ Main +-------------------------------------------------------------
stats(spearman_list) specifies the statistics to be displayed in the
matrix of output. stats(rho) is the default. Up to three statistics
may be specified; stats(rho obs p) would display the correlation
coefficient, number of observations, and significance level. If
varlist contains only two variables, all statistics are shown in
tabular form, and stats(), print(), and star() have no effect unless
the matrix option is specified.
print(#) specifies the significance level of correlation coefficients to
be printed. Correlation coefficients with larger significance levels
are left blank in the matrix. Typing spearman, print(.10) would list
only those correlation coefficients that are significant at the 10%
level or lower.
star(#) specifies the significance level of correlation coefficients to
be marked with a star. Typing spearman, star(.05) would "star" all
correlation coefficients significant at the 5% level or lower.
bonferroni makes the Bonferroni adjustment to calculated significance
levels. This adjustment affects printed significance levels and the
print() and star() options. Thus spearman, print(.05) bonferroni
prints coefficients with Bonferroni-adjusted significance levels of
0.05 or less.
sidak makes the Sidak adjustment to calculated significance levels. This
adjustment affects printed significance levels and the print() and
star() options. Thus spearman, print(.05) sidak prints coefficients
with Sidak-adjusted significance levels of 0.05 or less.
pw specifies that correlations be calculated using pairwise deletion of
observations with missing values. By default, spearman uses casewise
deletion, where observations are ignored if any of the variables in
varlist are missing.
matrix forces spearman to display the statistics as a matrix, even if
varlist contains only two variables. matrix is implied if more than
two variables are specified.
Options for ktau
+------+
----+ Main +-------------------------------------------------------------
stats(ktau_list) specifies the statistics to be displayed in the matrix
of output. stats(tau) is the default. Up to six statistics may be
specified. stats(taua taub score se obs p) would display the tau_a,
tau_b, score, standard error of score, number of observations, and
significance level. If varlist contains only two variables, all
statistics are shown in tabular form and stats(), print(), and star()
have no effect unless the matrix option is specified.
print(#) specifies the significance level of correlation coefficients to
be printed. Correlation coefficients with larger significance levels
are left blank in the matrix. Typing ktau, print(.10) would list
only those correlation coefficients that are significant at the 10%
level or lower.
star(#) specifies the significance level of correlation coefficients to
be marked with a star. Typing ktau, star(.05) would "star" all
correlation coefficients significant at the 5% level or lower.
bonferroni makes the Bonferroni adjustment to calculated significance
levels. This adjustment affects printed significance levels and the
print() and star() options. Thus ktau, print(.05) bonferroni prints
coefficients with Bonferroni-adjusted significance levels of 0.05 or
less.
sidak makes the Sidak adjustment to calculated significance levels. This
adjustment affects printed significance levels and the print() and
star() options. Thus ktau, print(.05) sidak prints coefficients with
Sidak-adjusted significance levels of 0.05 or less.
pw specifies that correlations be calculated using pairwise deletion of
observations with missing values. By default, ktau uses casewise
deletion, where observations are ignored if any of the variables in
varlist are missing.
matrix forces ktau to display the statistics as a matrix, even if varlist
contains only two variables. matrix is implied if more than two
variables are specified.
Examples
---------------------------------------------------------------------------
Setup
. webuse states2
Spearman's rank correlation coefficients; correlation coefficients
displayed by default
. spearman mrgrate divorce_rate medage
Spearman's rank correlation coefficients; correlation coefficients and
significance levels displayed
. spearman mrgrate divorce_rate medage, stats(rho p)
Kendall's rank correlations; tau_a, tau_b, and significance levels
displayed
. ktau mrgrate divorce_rate medage, stats(taua taub p)
---------------------------------------------------------------------------
Setup
. sysuse auto
Two variables; output displayed in tabular form by default
. spearman mpg rep78
Two variables; output displayed in matrix form
. spearman mpg rep78, matrix
Use all nonmissing observations between a pair of variables
. spearman mpg price rep78, pw
Star all correlation coefficients significant at the 5% level or lower
. spearman mpg price rep78, pw star(.05)
Kendall's rank correlations; tau_a, tau_b, score, standard error of
score, and Bonferroni-adjusted significance level displayed
. ktau mpg price rep78, stats(taua taub score se p) bonferroni
---------------------------------------------------------------------------
Saved results
spearman saves the following in r():
Scalars
r(N) number of observations (last variable pair)
r(rho) rho (last variable pair)
r(p) two-sided p-value (last variable pair)
Matrices
r(Nobs) number of observations
r(Rho) rho
r(P) two-sided p-value
ktau saves the following in r():
Scalars
r(N) number of observations (last variable pair)
r(tau_a) tau_a (last variable pair)
r(tau_b) tau_b (last variable pair)
r(score) Kendall's score (last variable pair)
r(se_score) standard error of score (last variable pair)
r(p) two-sided p-value (last variable pair)
Matrices
r(Nobs) number of observations
r(Tau_a) tau_a
r(Tau_b) tau_b
r(Score) Kendall's score
r(Se_Score) standard error of score
r(P) two-sided p-value
Also see
Manual: [R] spearman
Help: [R] correlate, [R] nptrend