Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# RE: st: RE: How to implement ranktest of matrix

 From "Schaffer, Mark E" To Subject RE: st: RE: How to implement ranktest of matrix Date Thu, 8 Jul 2010 14:07:17 +0100

```Austin,

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of
> Austin Nichols
> Sent: Thursday, July 08, 2010 1:29 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: st: RE: How to implement ranktest of matrix
>
> Mark--
> The poster might have wanted a statistical test of the rank of the dgp
> of the matrix (or a comparison of the two matrices), which is what
> -ranktest- does, right?

Right.  Say our hypothesis is that the scalar Y is mean zero (so we don't worry about the constant term) and is generated by a linear DGP using 3 Xs.  The coefficient vector beta is 1x3.  -ranktest- is a test of the column rank of beta.

> But how can an N by 1 matrix have rank
> greater than 1?

Whoops!  Quite right.  I should have assumed in Komi's example that there are one or two Y variables, and he should put these in and the Zs in ()s:

ranktest (Y1 Y2) (dqdZ1 dqdz2)

or

ranktest Y1 (dqdZ1 dqdz2)

The ()s are optional if there's only one element in the list.

But we don't know where Komi's 6x2 matrix comes from, so this is just an indicative guess at best.

--Mark

>
> On Wed, Jul 7, 2010 at 7:39 PM, Schaffer, Mark E
> <M.E.Schaffer@hw.ac.uk> wrote:
> > Komi,
> >
> >> -----Original Message-----
> >> From: owner-statalist@hsphsun2.harvard.edu
> >> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of
> >> Komi Agbemavi Mati
> >> Sent: 07 July 2010 20:43
> >> To: statalist@hsphsun2.harvard.edu
> >> Subject: st: How to implement ranktest of matrix
> >>
> >> I  need to test whether the following matrix have rank 0, 1
> >> or 2. I am trying to use     ranktest in stata but i don't
> >> know what to put in Y and what
> >>  to put in Z as described in the help file.
> >>
> >>                                    dqdZ1           dqdz2
> >>                                 .0002178      .0000277
> >>                                  .0003644      .0000637
> >>                                .0022189     -.0004827
> >>                                .0012441      .0000804
> >>                                -.0182371    -.0013471
> >>                                .0026022      .0008305
> >>
> >>  When I try the following command
> >>  ranktest  dqdZ1        dqdz2,
> >
> > If you want to know the rank of a Stata matrix like the one
> above, you
> > can use, say, the Mata function rank() (see help mf_rank).
> You would
> > move the matrix from Stata into Mata and then use the
> rank() function.
> >
> > -ranktest- is different.  (Mea culpa - on re-reading the
> help file, I
> > think this could be clearer.)  It is for testing the rank
> of a matrix of
> > correlations or regression parameters.
> >
> > When you say
> >
> > ranktest dqdZ1 dqdz2
> >
> > what is happening is basically the same thing as regressing dqdZ1 on
> > dqdz2 and testing whether the regression parameter is nonzero (i.e.,
> > rank>0).  I suspect this isn't what you want, and instead
> you want the
> > rank of the Stata matrix above, but perhaps I'm wrong here.
> >
> > Hope this helps.
> >
> > Cheers,
> > Mark
> >
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

--
Heriot-Watt University is a Scottish charity
registered under charity number SC000278.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```