[Rd] allow NAs in upper tri for eigen(x,symmetric=TRUE)?

Dan Davison davison at stats.ox.ac.uk
Wed Feb 20 20:04:13 CET 2008


Thanks for acting on my original quibble; I had never questioned whether the diagonal
was part of the lower triangle. However, I'm afraid I now have another related quibble.

Seeing as ?eigen says that if(symmetric) 'only its lower triangle is used', it's seems a
bit unfair of it to complain when there are NAs in the upper triangle. For example, when 
computing a covariance/distance matrix between a large number of individuals, one might
be tempted to only compute the lower.tri values and leave the upper.tri NA.

Do you see any justification for changing eigen() along the lines of

will.use <- if(symmetric) lower.tri(x, diag=TRUE) else TRUE
if (any(!is.finite(x[will.use])))
        stop("infinite or missing values in 'x'")
?

Thanks,

Dan

On Thu, Nov 29, 2007 at 05:46:38PM +0100, Martin Maechler wrote:
> >>>>> "DD" == Dan Davison <davison at stats.ox.ac.uk>
> >>>>>     on Thu, 29 Nov 2007 11:34:18 +0000 writes:
> 
>     DD> from ?eigen
>     DD> symmetric: if 'TRUE', the matrix is assumed to be symmetric (or
>     DD> Hermitian if complex) and only its lower triangle is used. If
>     DD> 'symmetric' is not specified, the matrix is inspected for
>     DD> symmetry.
> 
> 
>     DD> I think that could mislead a naive reader as it suggests that, with symmetric=TRUE,
>     DD> the result of eigen() (vectors and values) depends only on the lower-triangular values, 
>     DD> and thus not on the values on the diagonal (that's not true for the eigenvalues).
> 
> Well, that all depends on what you think when you read 
> "lower triangle".
> 
> For many of us, this can include the diagonal or not, and we
> don't know if it is not specified further.
> 
> ?lower.tri  -- shows the option to include the diagonal.
> 
> Consequently, I'd suggest to replace
> 
>        "only its lower triangle is used"
> with   "only its lower triangle (diagonal included) is used"
> 
> Martin Maechler, ETH Zurich
> 
>     DD> I suggest that changing it to 
> 
>     DD> "... and only its lower triangle is used when computing the eigenvectors."
> 
>     DD> would be more accurate, perhaps even with a reminder about the trace - sum of eigenvalues
>     DD> relationship.
> 
>     DD> Dan
> 
>     DD> ______________________________________________
>     DD> R-devel at r-project.org mailing list
>     DD> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list