Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: bug un makematrix ?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: bug un makematrix ?
Date   Mon, 13 Oct 2003 13:53:27 +0100

Nicola Tommasi

> >I believe there is a bug in the makematrix command.
> >
> >Evidence of bug :
> >
> >. summ d09a_rc d09b_rc d09c_rc d09d_rc score_9;
> >
> >     Variable |       Obs        Mean    Std. Dev.       
> Min        Max
> >-------------+---------------------------------------------
> -----------
> >      d09a_rc |      1478    .7814614    .9512177         
> -2          2
> >      d09b_rc |      1442    .9036061    .9401232         
> -2          2
> >      d09c_rc |      1529    1.204709     .875393         
> -2          2
> >      d09d_rc |      1493    1.139317    1.007686         
> -2          2
> >      score_9 |      1584    1.000053    .7941874         
> -2          2
> >
> >. makematrix tab9tot, from( r(N) r(mean) r(sd) r(min) 
> r(max) ): su d09a_rc 
> >d09b_rc d09c_rc d09d_rc score_9;
> >
> >tab9tot[5,5]
> >                  N       mean         sd        min        max
> >d09a_rc       1351  .78756477  .94986591         -2          2
> >d09b_rc       1351  .92376018  .94168773         -2          2
> >d09c_rc       1351  1.2398224  .85734195         -2          2
> >d09d_rc       1351  1.1591414   .9980665         -2          2
> >score_9       1351  1.0275722  .77329762         -2          2
> >

-makematrix- is a user-written command available 
on SSC. 

I see no bug here; the issue is documented in the 
help for the command and in any case is fairly clear from 
the output. 

-summarize-, given several variables, cycles through 
those variables one by one and uses as many observations 
as it can, namely all those observations specified 
for which non-missing values are available for
_each_ variable. 

In Nicola's data, there are lots of missing 
values and the pattern of missing values is not 
the same for each variable. 

-makematrix- uses the opposite default, namely 
that it uses the observations specified for 
which _all_ variables specified are non-missing. 

The rationale for this is to ensure consistency 
of results, so that for example a correlation "matrix"
so produced really is a correlation matrix worthy 
of the name, with the correct eigenproperties etc. 

Nicola wants the -listwise- option: 

-listwise- specifies that the results of cmd should be 
determined for as many observations as possible.  
Note that as a consequence the number of observations used
in each calculation may differ. By default casewise deletion 
is used to ensure consistency in observations selected.

. makematrix tab9tot, from( r(N) r(mean) r(sd) r(min) r(max) ), 
listwise: su d09a_rc d09b_rc d09c_rc d09d_rc score_9 

Nick 
[email protected] 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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