Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Reduced Correlation Matrix

From   Nick Cox <>
Subject   Re: st: Reduced Correlation Matrix
Date   Thu, 4 Oct 2012 14:26:13 +0100

You can do some of this with -cpcorr- from SSC (except that any
LaTeXing is completely up to you).

. ssc desc cpcorr

package cpcorr from

      'CPCORR': module for correlations for each row vs each column variable


      cpcorr produces a matrix of correlations for rowvarlist versus
      colvarlist. cpspear does the same for Spearman correlations. This
      matrix may thus be oblong, and need not be square. Both also
      allow a single varlist.

      Author: Nicholas J. Cox, University of Durham
      Support: email

      Distribution-Date: 20010423

INSTALLATION FILES                               (type net install cpcorr)
(type -ssc install cpcorr- to install)

That said, -cpcorr- dates from a time long before Mata. You could get
a correlation matrix in Mata and extract a block without using any
loops. However, you would also need to label rows and columns.

You can also some of this using -corrci- (SJ). The way to do it would
be to save results to a separate data set and then reformat.

SJ-10-4 pr0041_1  . . . . . . . . . . . . . . . . . Software update for corrci
        (help corrci, corrcii if installed) . . . . . . . . . . . .  N. J. Cox
        Q4/10   SJ 10(4):691
        update to fix corrci so that it always saves r-class results

SJ-8-3  pr0041  .  Speaking Stata: Corr. with confidence, Fisher's z revisited
        (help corrci, corrcii if installed) . . . . . . . . . . . .  N. J. Cox
        Q3/08   SJ 8(3):413--439
        reviews Fisher's z transformation and its inverse, the
        hyperbolic tangent, and reviews their use in inference
        with correlations

I don't know what you mean by standard deviations here. Do you mean
"standard errors"? -corrci- as above supports confidence intervals, as
the name implies.

Sorry. but none of my programs ever supports significance starring, in
my view a practice more suited to restaurant or movie reviews than to


On Thu, Oct 4, 2012 at 2:05 PM, Meulemann  Max <> wrote:
> I´m having a problem creating a Correlation table of 6 variables from which I only want a reduced 3x3 correlation matrix to be exported to LaTeX.
> I´ve been trying to find a stata program to do this directly without using any loop or something handmade, but it seems that there is no program that I can find.
> I am using Stata 11.2 for Windows.
> So let us say I have 6 variables from which I would get a 6x6 correlation matrix. For some reasons, I only like to have the correlation of 3 (row) variables with 3 (column) variables.
> I picture it somewhat to be like this:
>                            Var 4                      Var5                       Var6
> Var1                   Cor(1,4)                Cor(1,5)                Cor(1,6)
> Var2                   Cor(2,4)                Cor(2,5)                Cor(3,6)
> Var3                   Cor(3,4)                Cor(3,5)                Cor(1,6)
> added with standard deviation and asterixes for significance.
> So far I have only come up with a solution to get at least the 3x3 matrix as a stata matrix, which would also work with the standard deviation.
> mat corr=J(3,3,0)
> forv i=1(1)3{
>             forv j=4(1)6{
>                         quietly corr var`i' var`j'
>                         mat c=r(C)
>                         local cc=c[2,1]
>                         mat corr[`i',`j'-3]=`cc'
>             }
> }
> mat list corr
> Is anybody aware of a program or code that would do that, maybe also able to export it to LaTeX?

*   For searches and help try:

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