Roger Newson <[email protected]> notes that extremely large (near
machine precision) numbers on the diagonal of a matrix can lead to matrices
that are displayed as symmetric, when indeed they are not. Roger wants to use
such near-infinite values because he has infinities to store.
He gives the nice example,
> . matrix def matti=(1,2\3,4)
>
> . matrix list matti
>
> matti[2,2]
> c1 c2
> r1 1 2
> r2 3 4
>
> . matrix def matti[2,2]=c(maxdouble)
>
> . matrix list matti
>
> symmetric matti[2,2]
> c1 c2
> r1 1
> r2 3 8.99e+307
Jean Salvati <[email protected]> notes,
> This seems to be a display issue:
and demonstrates this with,
> . di matti[1,2]
> 2
Jean is right, Roger's matrix is undamaged and -matrix list- is basically
informing Roger that for the purposes of computation, e.g. inversion, his
matrix is considered symmetric. Stata needs a tolerance to tiny discrepancies
from symmetry, because matrix computations that should lead to symmetric
results can result in slight asymmetry due to the limits of numerical
precision.
In Roger's case, we might look and say, "Gee, 3 and 2 sure like like very
different numbers, how can that be symmetric." Given the astronomically large
8.99e+307 on their shared diagonal, they both indeed look the same for matrix
inversion. Stata's tolerance for asymmetry has been carefully tuned to
double-precision computations and -matrix list- is showing us that Stata
considers the matrix symmetric for some of those computations.
If Roger wants to see his matrix in Stata, unfiltered by Stata's definition of
numerical symmetry, he can use -matlist-, rather than -matrix list-.
-matlist- also has many more options for controlling how the matrix is
displayed.
Roger notes that -mata- seems to treat the same matrix differently,
> This feature has got me worried. Unsurprisingly, it does not seem to
> be found in Mata matrices, [...]
What Roger is seeing is strictly a display issue. Mata has many more matrix
functions that does -matrix- and as such is not willing to impose a specific
tolerance for symmetry. Instead, Mata jumps entirely the other way when
displaying a matrix, and insists on exact symmetry before showing the matrix
as symmetric.
We could argue that exact symmetry would be a better criterion for -matrix
list- as well, but if nothing else, the current behaviour has history on its
side. Moreover, we can always use -matlist- if we prefer to see our matrices
unfiltered.
-- Vince
[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/