Stata 15 help for correlate

[R] correlate -- Correlations of variables

Syntax

Display correlation matrix or covariance matrix

correlate [varlist] [if] [in] [weight] [, correlate_options]

Display all pairwise correlation coefficients

pwcorr [varlist] [if] [in] [weight] [, pwcorr_options]

correlate_options Description ------------------------------------------------------------------------- Options means display means, standard deviations, minimums, and maximums with matrix noformat ignore display format associated with variables covariance display covariances wrap allow wide matrices to wrap -------------------------------------------------------------------------

pwcorr_options Description ------------------------------------------------------------------------- Main obs print number of observations for each entry sig print significance level for each entry listwise use listwise deletion to handle missing values casewise synonym for listwise 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 -------------------------------------------------------------------------

varlist may contain time-series operators; see tsvarlist. by is allowed with correlate and pwcorr; see [D] by. aweights and fweights are allowed; see weight.

Menu

correlate

Statistics > Summaries, tables, and tests > Summary and descriptive statistics > Correlations and covariances

pwcorr

Statistics > Summaries, tables, and tests > Summary and descriptive statistics > Pairwise correlations

Description

The correlate command displays the correlation matrix or covariance matrix for a group of variables. If varlist is not specified, the matrix is displayed for all variables in the dataset.

pwcorr displays all the pairwise correlation coefficients between the variables in varlist or, if varlist is not specified, all the variables in the dataset.

Options for correlate

+---------+ ----+ Options +----------------------------------------------------------

means displays summary statistics (means, standard deviations, minimums, and maximums) with the matrix.

noformat displays the summary statistics requested by the means option in g format, regardless of the display formats associated with the variables.

covariance displays the covariances rather than the correlation coefficients.

wrap requests that no action be taken on wide correlation matrices to make them readable. It prevents Stata from breaking wide matrices into pieces to enhance readability. You might want to specify this option if you are displaying results in a window wider than 80 characters. Then you may need to set linesize to however many characters you can display across a line; see [R] log.

Options for pwcorr

+------+ ----+ Main +-------------------------------------------------------------

obs adds a line to each row of the matrix reporting the number of observations used to calculate the correlation coefficient.

sig adds a line to each row of the matrix reporting the significance level of each correlation coefficient.

listwise handles missing values through listwise deletion, meaning that the entire observation is omitted from the estimation sample if any of the variables in varlist is missing for that observation. By default, pwcorr handles missing values by pairwise deletion; all available observations are used to calculate each pairwise correlation without regard to whether variables outside that pair are missing.

correlate uses listwise deletion. Thus listwise allows users of pwcorr to mimic correlate's treatment of missing values while retaining access to pwcorr's features.

casewise is a synonym for listwise.

print(#) specifies the significance level of correlation coefficients to be printed. Correlation coefficients with larger significance levels are left blank in the matrix. Typing pwcorr, print(.10) would list only correlation coefficients significant at the 10% level or better.

star(#) specifies the significance level of correlation coefficients to be starred. Typing pwcorr, star(.05) would star all correlation coefficients significant at the 5% level or better.

bonferroni makes the Bonferroni adjustment to calculated significance levels. This option affects printed significance levels and the print() and star() options. Thus pwcorr, 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 option affects printed significance levels and the print() and star() options. Thus pwcorr, print(.05) sidak prints coefficients with Sidak-adjusted significance levels of 0.05 or less.

Examples

--------------------------------------------------------------------------- Setup . webuse census13

Estimate correlation matrix . correlate mrgrate dvcrate medage

Estimate covariance matrix; use population as analytic weight . correlate mrgrate dvcrate medage [aweight=pop], covariance

--------------------------------------------------------------------------- Setup . sysuse auto

Estimate all pairwise correlations . pwcorr price headroom mpg displacement

Add significance level to each entry . pwcorr price headroom mpg displacement, sig

Add stars to correlations significant at the 1% level after Bonferroni adjustment . pwcorr price headroom mpg displacement, star(.01) bonferroni

---------------------------------------------------------------------------

Video example

Pearson's correlation coefficient in Stata

Stored results

correlate stores the following in r():

Scalars r(N) number of observations r(rho) rho (first and second variables) r(cov_12) covariance (covariance only) r(Var_1) variance of first variable (covariance only) r(Var_2) variance of second variable (covariance only) r(sum_w) sum of weights

Matrices r(C) correlation or covariance matrix

pwcorr stores the following in r():

Scalars r(N) number of observations (first and second variables) r(rho) rho (first and second variables)

Matrices r(C) pairwise correlation matrix r(sig) significance level of each correlation coefficient


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index