similar to: a simple question about a matrix

Displaying 20 results from an estimated 80000 matches similar to: "a simple question about a matrix"

2003 May 08
3
Avoiding loops to spare time and memory
Is it possible to avoid the loop in the following function (or make the function otherwise more efficient) and can someone point me to a possible solution? (It would be great if hours could be reduced to seconds :-). # --------------------------------------------- RanEigen=function(items=x,cases=y,sample=z) { X=matrix(rnorm(cases*items),nrow=cases,byrow=F) S=crossprod(X-rep(1,cases) %*%
2015 Mar 10
3
Notes on building a gcc toolchain for Rtools (but not multilib)
Hi Duncan, On Mon, Mar 9, 2015 at 10:40 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > On 09/03/2015 11:07 AM, Hsiu-Khuern Tang wrote: >> >> On Mon, Mar 9, 2015 at 3:50 AM, Duncan Murdoch <murdoch.duncan at gmail.com> >> wrote: >> > On 08/03/2015 10:02 PM, Hsiu-Khuern Tang wrote: >> >> Hi, >> >> >> >> [This
2007 Jan 24
1
Matrix question: obtaining the square root of a positive definite matrix?
I want to compute B=A^{1/2} such that B*B=A. For example a=matrix(c(1,.2,.2,.2,1,.2,.2,.2,1),ncol=3) so > a [,1] [,2] [,3] [1,] 1.0 0.2 0.2 [2,] 0.2 1.0 0.2 [3,] 0.2 0.2 1.0 > a%*%a [,1] [,2] [,3] [1,] 1.08 0.44 0.44 [2,] 0.44 1.08 0.44 [3,] 0.44 0.44 1.08 > b=a%*%a i have tried to use singular value decomposion > c=svd(b) > c$u%*%diag(sqrt(c$d))
2012 Mar 11
2
Matrix negative fraction power
Dear list, I understand that to raise matrix A to power (-1/2) we should use something like this: eigen(A)$vectors%*%diag(1/sqrt(eigen(A)$values))%*%t(eigen(A)$vectors) [from previous discussions: http://r.789695.n4.nabble.com/matrix-power-td900335.html] But this will only do it for negative sqrt of the matrix not for other fraction powers like (-3/2). Seeing that these things be can done
2011 Sep 06
1
repeatable segfault
Hi. macosx 10.6.8 With R-2.13.1 and also revision 56948 I get the following repeatable segfault: wt118:~% R --vanilla --quiet > R.Version() $platform [1] "x86_64-apple-darwin9.8.0" $arch [1] "x86_64" $os [1] "darwin9.8.0" $system [1] "x86_64, darwin9.8.0" $status [1] "" $major [1] "2" $minor [1] "13.1" $year [1]
2006 Jun 09
1
X'W in Matrix
Hi! I have used the Matrix package (Version: 0.995-10) successfully to obtain the OLS solution for a problem where the design matrix X is 44000x6000. X is very sparse (about 80000 non-zeros elements). Now I want to do WLS: (X'WX)^-1X'Wy I tried W=Diagonal(length(w),w) and wX=solve(X,W) but after various minutes R gives a not enough memory error (Im using a 64bit machine with 16Gigs
2008 May 01
4
efficient code - yet another question
Dear list members; The code given below corresponds to the PCA-NIPALS (principal component analysis) algorithm adapted from the nipals function in the package chemometrics. The reason for using NIPALS instead of SVD is the ability of this algorithm to handle missing values, but that's a different story. I've been trying to find a way to improve (if possible) the efficiency of the code,
2009 Jan 24
1
Help with dudi.pca
Dear R-helpers, I have two data frames, op and em4: > str(op) 'data.frame': 37 obs. of 5 variables: $ m : num 0.202 0.336 0.122 0.139 0.14 ... $ lln : num 0.798 0.643 0.863 0.835 0.823 ... $ rrn : num 0.789 0.702 0.894 0.895 0.923 ... $ asym2: num 0.177 0.304 0.108 0.187 0.274 ... $ asym3: num 0.0755 0.0975 0.0818 0.0651 0.13 ... > str(rownames(op)) chr
2013 Jun 18
1
eigen(symmetric=TRUE) for complex matrices
R-3.0.1 rev 62743, binary downloaded from CRAN just now; macosx 10.8.3 Hello, eigen(symmetric=TRUE) behaves strangely when given complex matrices. The following two lines define 'A', a 100x100 (real) symmetric matrix which theoretical considerations [Bochner's theorem] show to be positive definite: jj <- matrix(0,100,100) A <- exp(-0.1*(row(jj)-col(jj))^2) A's being
2007 Dec 12
2
Matrix Inversion
I got the following error: a = read.csv("mat.csv") b = as.matrix(a) tb = t(b) bb = tb %*% b dim(bb) ibb = solve(bb) bb %*% ibb > ibb = solve(bb) Error in solve.default(bb) : system is computationally singular: reciprocal condition number = 1.77573e-19 > Are there any ways to find more information about why it is singular? Thanks.
2008 Oct 20
1
Zero mean correlation Matrix
Hi,, I want to use the existing cor function in R but with a different way to compute the correlation method.. basically zero mean correlation. The forumula I have is 'D' <- function(c1, c2) sum(c1*c2, na.rm=T)/(sqrt(sum(c1*c1, na.rm=T))*sqrt(sum(c2*c2, na.rm=T))) I am not sure how i can modify the method cor computes its square roots and covariance matrixes? I only need to add
2011 Mar 20
2
Why unique(sample) decreases the performance ?
Hi, I' am interested in differences between sample's result when samples consist of full elements and consist of only distinct elements. When sample consist of full elements it take about 120 sec., but when consist of only distinct elements it take about 4.5 or 5 times more sec. I expected that opposite of this result, because unique(sample) has less elements than full sample. Code as
2009 Feb 17
2
Efficient matrix computations
Hi, I am looking for two ways to speed up my computations: 1. Is there a function that efficiently computes the 'sandwich product' of three matrices, say, ZPZ' 2. Is there a function that efficiently computes the determinant of a positive definite symmetric matrix? Thanks, S.A. [[alternative HTML version deleted]]
2010 Nov 16
2
Integrating functions / vector arithmetic
Hello, I was trying to build some functions which I would like to integrate over an interval using the function 'integrate' from the 'stats' package. As an example, please consider the function h(u)=sin(pi*u) + sqrt(2)*sin(pi*2*u) + sqrt(3)*sin(pi*3*u) + 2*sin(pi*4*u) Two alternative ways to 'build' this function are as in f and g below: coeff<-sqrt(1:4)
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
2007 Jan 23
3
[fixed] vectorized nested loop: apply a function that takes two rows
(Extremely sorry, disregard previous email as I hit send before pasting the latest version of the example; this one is smaller too) Dear R users, I want to apply a function that takes two vectors as input to all pairs (combinations (nrow(X), 2))of matrix rows in a matrix. I know that ideally, one should avoid loops in R, but after reading the docs for do.call, apply, etc, I still don't know
2007 Jan 23
3
[fixed] vectorized nested loop: apply a function that takes two rows
(Extremely sorry, disregard previous email as I hit send before pasting the latest version of the example; this one is smaller too) Dear R users, I want to apply a function that takes two vectors as input to all pairs (combinations (nrow(X), 2))of matrix rows in a matrix. I know that ideally, one should avoid loops in R, but after reading the docs for do.call, apply, etc, I still don't know
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
2011 Jan 17
1
Problem about for loop
Hi everyones, my function like; e <- rnorm(n=50, mean=0, sd=sqrt(0.5625)) x0 <- c(rep(1,50)) x1 <- rnorm(n=50,mean=2,sd=1) x2 <- rnorm(n=50,mean=2,sd=1) x3 <- rnorm(n=50,mean=2,sd=1) x4 <- rnorm(n=50,mean=2,sd=1) y <- 1+ 2*x1+4*x2+3*x3+2*x4+e x2[1] = 10 #influential observarion y[1] = 10 #influential observarion data.x <- matrix(c(x0,x1,x2,x3,x4),ncol=5) data.y
2007 Dec 09
2
Large determinant problem
I thought I would have another try at explaining my problem. I think that last time I may have buried it in irrelevant detail. This output should explain my dilemma: > dim(S) [1] 1455 269 > summary(as.vector(S)) Min. 1st Qu. Median Mean 3rd Qu. Max. -1.160e+04 0.000e+00 0.000e+00 -4.132e-08 0.000e+00 8.636e+03 > sum(as.vector(S)==0)/(1455*269) [1]