similar to: loop

Displaying 20 results from an estimated 20000 matches similar to: "loop"

2003 Jul 03
2
SVD and spectral decompositions of a hermitian matrix
Hi: I create a hermitian matrix and then perform its singular value decomposition. But when I put it back, I don't get the original hermitian matrix. I am having the same problem with spectral value decomposition as well. I am using R 1.7.0 on Windows. Here is my code: X <- matrix(rnorm(16)+1i*rnorm(16),4) X <- X + t(X) X[upper.tri(X)] <- Conj(X[upper.tri(X)]) Y <-
2007 Jun 29
2
Spectral Decomposition
All of my resources for numerical analysis show that the spectral decomposition is A = CBC' Where C are the eigenvectors and B is a diagonal matrix of eigen values. Now, using the eigen function in R # Original matrix aa <- matrix(c(1,-1,-1,1), ncol=2) ss <- eigen(aa) # This results yields back the original matrix according to the formula above ss$vectors %*% diag(ss$values) %*%
2006 Mar 03
1
NA in eigen()
Hi, I am using eigen to get an eigen decomposition of a square, symmetric matrix. For some reason, I am getting a column in my eigen vectors (the 52nd column out of 601) that is a column of all NAs. I am using the option, symmetric=T for eigen. I just discovered that I do not get this behavior when I use the option EISPACK=T. With EISPACK=T, the 52nd eigenvector is (up to rounding error) a
2010 Jun 25
2
Forcing scalar multiplication.
I am trying to check the results from an Eigen decomposition and I need to force a scalar multiplication. The fundamental equation is: Ax = lx. Where 'l' is the eigen value and x is the eigen vector corresponding to the eigenvalue. 'R' returns the eigenvalues as a vector (e <- eigen(A); e$values). So in order to 'check' the result I would multiply the eigenvalues
2012 Apr 19
2
Is the eigen-value decomposition in R generally stable/reliable for large matrix?
Say a matrix of size of thousands? I am looking for an eigen-value decomposition algo in R to give good eigenvalues... Is that a hopeful thing? Thank you! [[alternative HTML version deleted]]
2003 Feb 06
6
Confused by SVD and Eigenvector Decomposition in PCA
Hey, All In principal component analysis (PCA), we want to know how many percentage the first principal component explain the total variances among the data. Assume the data matrix X is zero-meaned, and I used the following procedures: C = covriance(X) %% calculate the covariance matrix; [EVector,EValues]=eig(C) %% L = diag(EValues) %%L is a column vector with eigenvalues as the elements percent
2009 Nov 23
1
R: Re: chol( neg.def.matrix ) WAS: Re: Choleski and Choleski with pivoting of matrix fails
It works! But Once I have the square root of this matrix, how do I convert it to a real (not imaginary) matrix which has the same property? Is that possible? Best, Simon >----Messaggio originale---- >Da: p.dalgaard at biostat.ku.dk >Data: 21-nov-2009 18.56 >A: "Charles C. Berry"<cberry at tajo.ucsd.edu> >Cc: "simona.racioppi at
2005 Jul 13
2
Efficient testing for +ve definiteness
Dear R-users, Is there a preferred method for testing whether a real symmetric matrix is positive definite? [modulo machine rounding errors.] The obvious way of computing eigenvalues via "E <- eigen(A, symmetric=T, only.values=T)$values" and returning the result of "!any(E <= 0)" seems less efficient than going through the LU decomposition invoked in
2011 Feb 04
2
always about positive definite matrix
1. Martin Maechler's comments should be taken as replacements for anything I wrote where appropriate. Any apparent conflict is a result of his superior knowledge. 2. 'eigen' returns the eigenvalue decomposition assuming the matrix is symmetric, ignoring anything in m[upper.tri(m)]. 3. The basic idea behind both posdefify and nearPD is to compute the
2013 Jan 31
1
Using eigen() for extracting only few major eigenpairs
Hi everyone, I am using eigen() to extract the 2 major eigenpairs from a large real square symmetric matrix. The procedure is already rather efficient, but becomes somehow slow for real time needs with moderately large matrices (few thousand lines). The R implementation statically extracts all eigenvalues (and optionally associated eigenvectors). I heard about optimizations of the eigen
2009 Apr 24
1
the puzzle of eigenvector and eigenvalue
Dear all I am so glad the R can provide the efficient calculate about eigenvector and eigenvalue. However, i have some puzzle about the procedure of eigen. Fristly, what kind of procedue does the R utilize such that the eigen are obtained? For example, A=matrix(c(1,2,4,3),2,2) we can define the eigenvalue lamda, such as det | 1-lamda 4 | =0 | 2 3-lamda | then
2008 May 16
1
Dimensions of svd V matrix
Hi, I'm trying to do PCA on a n by p wide matrix (n < p), and I'd like to get more principal components than there are rows. However, svd() only returns a V matrix of with n columns (instead of p) unless the argument nv=p is set (prcomp calls svd without setting it). Moreover, the eigenvalues returned are always min(n, p) instead of p, even if nv is set: > x <-
2009 Nov 25
1
R: Re: R: Re: chol( neg.def.matrix ) WAS: Re: Choleski and Choleski with pivoting of matrix fails
Dear Peter, thank you very much for your answer. My problem is that I need to calculate the following quantity: solve(chol(A)%*%Y) Y is a 3*3 diagonal matrix and A is a 3*3 matrix. Unfortunately one eigenvalue of A is negative. I can anyway take the square root of A but when I multiply it by Y, the imaginary part of the square root of A is dropped, and I do not get the right answer. I tried
2003 Apr 03
2
Matrix eigenvectors in R and MatLab
Dear R-listers Is there anyone who knows why I get different eigenvectors when I run MatLab and R? I run both programs in Windows Me. Can I make R to produce the same vectors as MatLab? #R Matrix PA9900<-c(11/24 ,10/53 ,0/1 ,0/1 ,29/43 ,1/24 ,27/53 ,0/1 ,0/1 ,13/43 ,14/24 ,178/53 ,146/244 ,17/23 ,15/43 ,2/24 ,4/53 ,0/1 ,2/23 ,2/43 ,4/24 ,58/53 ,26/244 ,0/1 ,5/43) #R-syntax
2006 Nov 01
1
gamm(): degrees of freedom of the fit
I wonder whether any of you know of an efficient way to calculate the approximate degrees of freedom of a gamm() fit. Calculating the smoother/projection matrix S: y -> \hat y and then its trace by sum(eigen(S))$values is what I've been doing so far- but I was hoping there might be a more efficient way than doing the spectral decomposition of an NxN-matrix. The degrees of freedom
2003 Dec 22
1
La.eigen hangs R when NaN is present (PR#6003)
Full_Name: Sundar Dorai-Raj Version: 1.8.1 OS: Windows 2000 Professional Submission from: (NULL) (12.64.199.173) I discovered this problem when trying to use princomp in package:mva when a column in my matrix was all zeros and I set cor = TRUE (thus division by 0). Doing so hangs R, never to return. I have to shut down Rterm in the Task Manager and lose all work from the current image. I tracked
2008 Jun 18
2
highest eigenvalues of a matrix
DeaR list, I happily use eigen() to compute the eigenvalues and eigenvectors of a fairly large matrix (200x200, say), but it seems over-killed as its rank is limited to typically 2 or 3. I sort of remember being taught that numerical techniques can find iteratively decreasing eigenvalues and corresponding orthogonal eigenvectors, which would provide a nice alternative (once I have the
2009 Mar 08
2
prcomp(X,center=F) ??
I do not understand, from a PCA point of view, the option center=F of prcomp() According to the help page, the calculation in prcomp() "is done by a singular value decomposition of the (centered and possibly scaled) data matrix, not by using eigen on the covariance matrix" (as it's done by princomp()) . "This is generally the preferred method for numerical accuracy"
2009 Mar 10
5
Cholesky Decomposition in R
Hi everyone: I try to use r to do the Cholesky Decomposition,which is A=LDL',so far I only found how to decomposite A in to LL' by using chol(A),the function Cholesky(A) doesnt work,any one know other command to decomposte A in to LDL' My r code is: library(Matrix) A=matrix(c(1,1,1,1,5,5,1,5,14),nrow=3) > chol(A) [,1] [,2] [,3] [1,] 1 1 1 [2,] 0 2 2
2004 Oct 19
3
matrix of eigenvalues
I thought that the function eigen(A) will return a matrix with eigenvectors that are independent of each other (thus forming a base and the matrix being invertible). This seems not to be the case in the following example A=matrix(c(1,2,0,1),nrow=2,byrow=T) eigen(A) ->ev solve(ev$vectors) note that I try to get the upper triangular form with eigenvalues on the diagonal and (possibly) 1 just