search for: ginv

Displaying 20 results from an estimated 79 matches for "ginv".

Did you mean: gini
2003 Aug 07
3
ginv vs. solve
Why do x<-b%*%ginv(A) and x<-solve(A,b) give different results?. It seems that I am missing some basic feature of matrix indexing. e.g.: A<-matrix(c(0,-4,4,0),nrow=2,ncol=2) b<-c(-16,0) x<-b%*%ginv(A);x x<-solve(A,b);x Thanks in advance, Angel
2009 Feb 04
1
reference for ginv
?ginv provides 'Modern Applied Statistics with S' (MASS), 3rd, by Venables and Ripley as the sole reference. I happen to have this book (4th ed) on loan from our library, and as far as I can see, ginv is mentioned there twice, and it is *used*, not *explained* in any way. (It is used on p. 148 i...
2004 Mar 25
1
g-inverse question
I am using the ginv function from MASS and have run across this problem that I do not understand. If I define the matrix A as below, its g-inverse does not satisfy the Moore-Penrose condition A %*% ginv(A) %*% A = A. The matrix A is X'WX in a quadratic regression using some very large dollar values. The muc...
2010 Jul 05
1
if using ginv function, does it mean there is no need to use solve function any more?
since ginv can deal with both singular and non-singular conditions, is there any other difference between them? if I use ginv only, will be any problem? thanks [[alternative HTML version deleted]]
2005 Oct 15
1
solve() versus ginv()
Dear All, While inverting a matrix the following error appears on my console: Error in solve.default(my_matrix) : Lapack routine dgesv: system is exactly singular With this respect, I have been replacing the solve() function with ginv(): the Moore-Penrose generalized inverse of a matrix. These are the questions I would like to ask you: 1. Would you also replace solve() with ginv() in these scenarios and using R? 2. Or is there something I should take care by using ginv() you would suggest me please? Many thanks in advan...
2008 Feb 23
1
ginv and matlab's pinv give different results
Dear all; I'm kind of confused with the results obtained using the ginv function from package MASS and pinv function from Matlab. Accroding to the documentation both functions performs a Moore-Penrose generalized inverse of a matrix X. The problem is when I change the tolerance value, say to 1E-3. Here is some output from ginv 195.2674402 235.6758714 335.0830253 8.977...
2004 Feb 06
1
How to get the pseudo left inverse of a singular squarem atrix?
...ed inverse is something >like: If A is a >non-null matrix, and G satisfy AGA = A, then G is >called a generalized >inverse of A. This is not unique, but a unique one >that satisfy some >additional properties is the Moore-Penrose inverse. I >don't know if this is >what ginv() in MASS returns, as I have not used it >before. Andy The inverse of a Matrix A is defined as a Matrix B such that B*A=A*B=I and not just B*A=I. But there are matrices B for singular matrices A such that B*A=I but A*B != I, therefore there exist "left-inverses" (or "right-inve...
2011 Mar 07
1
a numeric problem
...09, 129.14899, 63.273005, 158.531662, 256.1531 ),7,7,byrow=T) ####both of these two matrix are non-singular so their inverse should be exists###### ####while KK <- t(A)%*%solve(S)%*%A det(KK) ###12553.48 which is not 0, but solve() function refuse to work now. ## So I try to use ginv() instead### ginv(KK) ### It is expected that A%*%ginv(t(A)%*%solve(S)%*%A)%*%t(A) ### should equal to solve(S)###### solve(S) ### but it is not!!! ### So I am wondering in such situation, do you have any suggestion? ### I have tried the argument "tol = sqrt(.Machine$double.eps))&quot...
2013 Jan 14
1
ginv / LAPACK-SVD causes R to segfault on a large matrix.
...you help in reproducing a problem I am having That is only reproducible on a large-memory machine. Whenever I run the following lines, get a segfault listed below: *** caught segfault *** address 0x7f092cc46e40, cause 'invalid permissions' Traceback: 1: La.svd(x, nu, nv) 2: svd(X) 3: ginv(bigmatrix) Here is the code that I run: require(MASS) l=30000 w=30000 x=rpois(l*w,0.00126) bigmatrix=matrix(x,nrow=l,ncol=w) inverted=ginv(bigmatrix) I have tried this both with OMP_NUM_THREADS=1 and greater than 1, and the resulting is always a segfault. The max memory used in around 40G. I am...
2005 Apr 22
1
Required Packages etiquette
...ackage if one wants to use a specific function of MYPKG that produces a MCMC chain. What is the best way to require the package? Inside the function that request it? The relation between the third class of packages and MYPKG is very tricky. For example, from the MASS package MYPKG only uses "ginv" to get the generalized inverse. "ginv" is an important function, i.e. it is used in many functions. Do I have to require MASS? Or should I just include only "ginv" in the package? Thank you for patience. Giuseppe ---------------------------------------------------------...
2001 Oct 18
1
AW: General Matrix Inverse
...ippe Grosjean > Cc: r-help at stat.math.ethz.ch > Betreff: RE: [R] General Matrix Inverse > > > > > I use solve(x) to find the inverse of a matrix (don't know what a > "general > > inverse" is). By the way, what is better: solve(x), qr.solve(x) or > ginv(x)? > > ginv(x) seems to give results for matrices where solve and qr.solve > return > > an error: > > > > > x <- matrix(1:9, 3, 3) > > > x > > [,1] [,2] [,3] > > [1,] 1 4 7 > > [2,] 2 5 8 > > [3,] 3 6...
2007 Aug 06
0
KMO sampling adequacy and SPSS -- partial solution
...2 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: gkerns at ysu.edu http://www.cc.ysu.edu/~gjkerns/ # KMO Kaiser-Meyer-Olkin Measure of Sampling Adequacy kmo = function( data ){ library(MASS) X <- cor(as.matrix(data)) iX <- ginv(X) S2 <- diag(diag((iX^-1))) AIS <- S2%*%iX%*%S2 # anti-image covariance matrix IS <- X+AIS-2*S2 # image covariance matrix Dai <- sqrt(diag(diag(AIS))) IR <- ginv(Dai)%*%IS%*%ginv(Dai) # image correlation matrix AIR &lt...
2005 Jan 27
2
svd error
Hi, I met a probem recently and need your help. I would really appreciate it. I kept receiving the following error message when running a program: 'Error in svd(X) : infinite or missing values in x'. However, I did not use any svd function in this program though I did include the function pseudoinverse. Is the problem caused by doing pseudoinverse? Best regards, Tongtong
2004 Sep 01
0
not positive definite D matrix in quadprog
...lues #the last value is negative D.values [1] 4.609489e+04 2.458166e+03 8.232288e+01 1.961199e+00 5.976441e-01 [6] 2.810968e-01 1.253157e-09 -2.685763e-08 D.quad <- matrix(0,8,8) diag(D.quad) <- D.values #checking that the eigenvalue decomposition works fine D.vectors%*%D.quad%*%ginv(D.vectors) D.quad[8,8] [1] -2.685763e-08 D.quad[8,8] <- 0.0 #checking; nothing changes too much D.vectors%*%D.quad%*%ginv(D.vectors) #now all eigenvalues are positive: D.values.new <- eigen(D.vectors%*%D.quad%*%ginv(D.vectors),only.values=F)$values D.values.new [1] 4.609489e+04 2.45816...
2009 Feb 06
1
Linear model: contrasts
...0,0,0,0,1,1); X[,9]=c(1, 0, 1, 0, 1, 0,1, 0); X[,10]=c(0, 1, 0, 1, 0, 1, 0, 1); X[,11]=c(1, 0, 1, 0,0, 0, 0, 0); X[,12]=c( 0, 1, 0, 1,0, 0, 0, 0); X[,13]=c( 0, 0, 0, 0, 1, 0, 1, 0) X[,14]=c(0, 0, 0, 0, 0, 1, 0, 1) X[,15]=c(1,1,1,1,1,1,1,1) #y data Y=c(1.2,5.1,1.7,7,6.1,8,1.1,2.5) library(MASS) ginv() B=(ginv(t(X)%*%X) %*% t(X)) %*% Y #contrast c1=rep(0,15) c1[1]=1 c1[c(5,6,11,12)]=1/2 c2=rep(0,15) c2[2]=-1 c2[c(7,8,13,14)]=-1/2 #Group effect mean(Y[1:4])-mean(Y[5:8]) c1%*%B+c2%*%B -- -- Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL f?r nur 17,95 Euro/mtl.!* http://dsl....
2004 Jul 06
2
Generate a matrix Q satisfying t(Q)%*%Q=Z and XQ=W
...e.g: m=6, p=2 r=3 Z=matrix(c(1,.2,.5,.2,1,.45,.5,.45,1),3,3) X=matrix(c(.1,.3,.5,.6,.2,.1,.8,1,.4,.2,.2,.9),2,6) W=matrix(c(0,.8,.4,.6,.2,0),2,3) #Create a matrix satisfying (1) is easy: A=matrix(runif(18),6,3) Q1=svd(A)$u%*%chol(Z) #For the second condition (2), a solution is given by Q2=A%*%ginv(X%*%A)%*%W I do not know how to create a matrix Q that satisfies the two conditions. I have try to construct an iterative procedure without success (no convergence): eps=10 i=0 while(eps>.5) { Q1=svd(Q2)$u%*%chol(Z) Q2=Q1%*%ginv(X%*%Q1)%*%W eps=sum(abs(Q1-Q2)) cat(i,":",eps,&q...
2002 May 16
1
foreign library - negative integers??
I am having a problem with the foreign library correctly reading some integer data. Specifically, d _ read.dta('aptaa.dta') > d[1:5,] scenario metcode yr ginv cons gocc abs dvac gmre gmer 1 1 AA 2002 0.007 1377 -0.071 51710 0.071 -0.011 -0.127 2 1 AA 2003 0.000 0 -0.016 62568 0.014 -0.043 -0.538 3 1 AA 2004 0.000 0 -0.002 65122 0.002 -0.090 -0.338 4 1 AA 2005 0.000 0 0.000 65528 0.00...
2008 Jun 05
1
Limit distribution of continuous-time Markov process
...multiplier is "t" in the PDF whose URL is above.) Is there a known way to get this to converge? Thank you. ---------------R script:-------------- # The rate matrix: Q <- matrix(c(-1, 1, 0, 1, -2, 1, 0, 1, -1), ncol=3, byrow=T); M <- eigen(Q)$vectors # diagonalizer matrix D <- ginv(eigen(Q)$vectors) %*% Q %*% eigen(Q)$vectors # Diagonalized form Sum <- matrix(c(rep(0, 9)), ncol=3, byrow=T); for (i in 0:60) { # Naive, Taylor series summation: Temp <- D; diag(Temp) <- (4 * diag(D)) ^ i; # ** =4 Sum <- Sum + Temp / factorial(i); } Answer <- M %*% Sum %*% ginv...
2001 Oct 18
0
General Matrix Inverse
...> I use solve(x) to find the inverse of a matrix (don't know what a "general > inverse" is). By the way, what is better: solve(x), qr.solve(x) or ginv(x)? > ginv(x) seems to give results for matrices where solve and qr.solve return > an error: > > > x <- matrix(1:9, 3, 3) > > x > [,1] [,2] [,3] > [1,] 1 4 7 > [2,] 2 5 8 > [3,] 3 6 9 > > solve(x) > Error in solve.default(...
2009 Aug 31
2
Problem in matrix definition?
...qrt(L[k,r]) if (k < n) L[(k+1):n,r] <- L[(k+1):n,r]/L[k,r] } else r <- r-1 } L <- L[,1:r] M <- solve(crossprod(L)) if (tr == 1) Y <- t(x)%*%L%*%M%*%M%*%t(L) else Y <- L%*%M%*%M%*%t(L)%*%t(x) return(Y) } # Perfect result! This result is identical of the function ginv! library(MASS) mp <- 10 np <- 5 a <- matrix(c(1:mp*np),mp,np) dim(a) # 10,5 geninv(a) ginv(a) # Problem a <- matrix(c(1:50),mp,np) # The difference is the vector (1:50) dim(a) # 10,5 geninv(a) Error in L[k:n, 1:(r - 1)] %*% (t(L[k, 1:(r - 1)])) : arguments are not compatible The...