*! version 1.1.3 15dec2022

Title

cir -- Confidence Interval for Pearson and Spearman Correlation

Syntax for cir

cir varnameY varnameX [if] [in] [, options]

Immediate command

ciri #rho1 #n1 [#rho0 #n0] [, options]

pearson calculate confidence interval for Pearson correlation; the default

spearman calculate confidence interval for Spearman correlation

by(varname) binary variable that defines two groups (not available in the immediate commad)

rho(#) hypothetical correlation to compare with

level(#) confidence level (%); default is level(95)

nst(string) name of the study (label)

by is allowed; see [D] by.

Description

Option pearson calculates the Pearson correlation
and computes the confidence interval, using Fisher's transformation. With option spearman, Spearman
correlation is calculated. It is possible to compare two correlations using the by() option to define
two groups in the dataset with a binary variable. Option rho() allows to compare to a hypothetical correlation.

ciri is the immediate form of cir; see immed. #rho1 and #n1 are the correlation coefficient
and the sample size of group 1. To compare two correlations, #rho0 and #n0 (correlation coefficient and
sample size of group 0) are needed. Option rho() allows to compare to a hypothetical correlation.

You can click here to pop up a dialog or type db cir. For the
immediate command, you can click here to pop up a dialog or type db ciri.

Execute net from http://metodo.uab.cat/stata for install.

It is important to keep the commands updated. Execute adoupdate cir, update to update the cir command.

Execute adoupdate, update to update all the user-written commands.

This command uses the correlate and spearman Stata commands.

If you find any bugs or want to suggest any improvements, please send an e-mail to: leam@uab.cat.

Examples

. use http://metodo.uab.cat/stata/CreaHemo.dta

. cir Creatin Hemoglo, pearson

. cir Creatin Hemoglo, spearman rho(-0.7)

. cir Creatin Hemoglo, pearson by(Tratamiento) level(90)

. ciri 0.7700 50, spearman

. ciri 0.4869 47, rho(0.30) level(90)

. ciri 0.65 84 0.40 101

Stored results

The command stores the following scalars in r():

r(level) confidence level of confidence intervals

One correlation

r(rho) rho

r(lb_rho) lower bound of rho confidence interval

r(ub_rho) upper bound of rho confidence interval

r(p) significance

r(N) number of observations

Comparing a correlation to a hypotetical value

r(rho) rho

r(lb_rho) lower bound of rho confidence interval

r(ub_rho) upper bound of rho confidence interval

r(rd) difference

r(rb_rho) lower bound of difference confidence interval

r(rb_rho) upper bound of difference confidence interval

r(p) significance (two-sided)

r(N) number of observations

Comparing two correlations

r(rho1) rho (sample 1)

r(lb_rho1) lower bound of rho confidence interval (sample 1)

r(ub_rho1) upper bound of rho confidence interval (sample 1)

r(N1) number of observations (sample 1)

r(rho0) rho (sample 0)

r(lb_rho0) lower bound of rho confidence interval (sample 0)

r(ub_rho0) upper bound of rho confidence interval (sample 0)

r(N0) number of observations (sample 0)

r(rd) difference

r(rb_rho) lower bound of difference confidence interval

r(rb_rho) upper bound of difference confidence interval

r(p) significance (two-sided)

Version

Version 1.1.3 -- 15 December 2022

Authors

JM.Doménech

Programmer: R.Sesma

Laboratori d'Estadística Aplicada

Universitat Autònoma de Barcelona

leam@uab.cat

Vancouver reference

Doménech JM. Confidence Interval for Pearson and Spearman Correlation: User-written command cir for Stata [computer program].

V1.1.3. Bellaterra: Universitat Autònoma de Barcelona; 2022.

Available executing from Stata: net from http://metodo.uab.cat/stata

References

Altman DG, Machin D, Bryant TN, Gardner MJ. Statistics with confidence. Confidence intervals and
statistical guidelines. 2ª ed. London: BMJ Books; 2000.

Doménech JM. Fundamentos de Diseño y Estadística. UD 13. Correlación y regresión lineal. 15ª ed. Barcelona: Signo; 2014.