As mentioned in the title. Could anyone teach me to calculate the product of eigenvalues of a matrix? It is ok to use any R function or package. Thanks.
Asked
Active
Viewed 855 times
-4
-
1Maybe the results of this search: [`[r] eigenvalue matrix`](http://stackoverflow.com/search?q=[r]+eigenvalue+matrix) will help – Jaap Apr 04 '14 at 18:56
-
1Any question in general should have at least an example of what you have tried. – romants Apr 04 '14 at 18:59
-
1Welcome to Stack Overflow. Please inform yourself on how to ask a [good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducable example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Jaap Apr 04 '14 at 19:02
2 Answers
1
How much effort did you put into solving this one yourself?
It's very basic to calculate the product of the eigenvalues of a matrix.
I'll leave the explanations for you to find in the documentation files ?matrix
, ?eigen
, and ?prod
.
> m <- matrix(rnorm(25, 5, 10), 5, 5)
> m
[,1] [,2] [,3] [,4] [,5]
[1,] -6.068987 5.657092 16.106767 11.701708 6.060705
[2,] 2.574272 7.420419 9.871342 6.049024 -5.930012
[3,] -10.549236 23.885948 -7.187153 9.084914 -4.843331
[4,] 17.815534 3.348587 1.925881 -3.900034 10.506535
[5,] -10.143544 13.401505 11.022406 5.437238 17.646310
> eigen(m)$values
[1] 20.720634+0.000000i -15.994616+9.683080i -15.994616-9.683080i
[4] 9.589576+6.645961i 9.589576-6.645961i
> prod(eigen(m)$values)
[1] 986078.9-0i

Rich Scriven
- 97,041
- 11
- 181
- 245
0
??eigenvalue
points you to eigen()
. Reading the help page via ?eigen
tells you how to extract the eigenvalues (instead of the eigenvectors). Interestingly enough, ??product
does not point you to prod()
, but now you know about this function. So:
> foo <- matrix(runif(9),3,3)
> prod(eigen(foo)$values)
[1] -0.07673157

Stephan Kolassa
- 7,953
- 2
- 28
- 48