Displaying 20 results from an estimated 2000 matches similar to: "problem to solve a matrix"
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
2010 Nov 21
3
Can't invert matrix
Hi,
I'm trying to use the solve() function in R to invert a matrix. I get
the following error, "Lapack routine dgesv: system is exactly singular"
However, My matrix doesn't appear to be singular.
[,1] [,2] [,3] [,4]
[1,] 0.99252358 0.93715047 0.7540535 0.4579895
[2,] 0.01607797 0.09616267 0.2452471 0.3088614
[3,] 0.09772828 0.58451468 1.4907090
2012 Dec 11
2
Catching errors from solve() with near-singular matrices
Dear all,
The background is that I'm trying to fix this bug in the geometry
package:
https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1993&group_id=1149&atid=4552
Boiled down, the problem is that there exists at least one matrix X for
which det(X) != 0 and for which solve(X) fails giving the error "system
is computationally singular: reciprocal condition
2011 May 22
2
Finding solution set of system of linear equations.
I have a simple system of linear equations to solve for X, aX=b:
> a
[,1] [,2] [,3] [,4]
[1,] 1 2 1 1
[2,] 3 0 0 4
[3,] 1 -4 -2 -2
[4,] 0 0 0 0
> b
[,1]
[1,] 0
[2,] 2
[3,] 2
[4,] 0
(This is ex Ch1, 2.2 of Artin, Algebra).
So, 3 eqs in 4 unknowns. One can easily use row-reductions to find a
homogeneous solution(b=0) of:
X_1
2012 Feb 28
1
Error in solve.default(res$hessian * n.used) :Lapack routine dgesv: system is exactly singular
Hi there!
I´m a noob when it comes to R and I´m using it to run statisc analysis.
With the code for ARIMA below I´m getting this error: Error in
solve.default(res$hessian * n.used) :Lapack routine dgesv: system is
exactly singular
The code is:
> s.ts <- ts(x[,7], start = 2004, fre=12)
> get.best.arima <- function (x.ts, maxord=c(1,1,1,1,1,1))
+ {
+ best.aic <- 1e8
+ n <-
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
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]]
2015 Mar 25
4
F77_CALL/NAME problem
Dear R-devel,
I am trying to use Fortran DGESV subroutine into C. Here it is the relevant
part of the C file I am currently writing
#include<stdio.h>
#include<R.h>
#include<Rmath.h>
#include<math.h>
void F77_NAME(DGESV)( int*, int*, double*, int*, int*, double*, int*, int*);
void solve( int *p, double *A, double *Ainv)
{
...
F77_CALL(DGESV)(p, p, Ain, p, ipiv,
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 much simpler matrix B does satisfy the MP condition. Am I doing
something wrong? Is
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 in the 4th edition.)
ginv does not appear in the index of MASS. ginv is an implementation of
2011 Mar 07
1
a numeric problem
### An numeric problem in R ########
###I have two matrix one is##########
A <- matrix(c(21.97844, 250.1960, 2752.033, 29675.88, 316318.4, 3349550,
35336827,
24.89267, 261.4211, 2691.009, 27796.02, 288738.7, 3011839,
31498784,
21.80384, 232.3765, 2460.495, 25992.77, 274001.6, 2883756,
30318645,
39.85801, 392.2341, 3971.349, 40814.22, 423126.2,
2010 Jul 19
1
Calculation of Covariance Matrix Calculation
Hi,
Excuse me for asking this silly question. But I really couldn't understand
why cov() and ccov() don't work for my calculation of covariance matrix.
a <- matrix(1:8, 2, 4)
a
[,1] [,2] [,3] [,4]
[1,] 1 3 5 7
[2,] 2 4 6 8
> ccov(a)
Error in solve.default(cov, ...) :
Lapack routine dgesv: system is exactly singular
I also tried colume bind, but it
2005 Apr 22
1
Required Packages etiquette
Dear friends,
I am writing a package that I think may be of interest to many people so I
am in the process to build-check-write-thedocumentation for it.
I have some questions regarding the "rules" that a package
should abide in order to be consistent with the other packages on CRAN.
I have read and reread the Writing R extension manual and googled the
mailing list and I have found
2001 Oct 18
1
AW: General Matrix Inverse
Thorsten is right. There is a direct formula for computing the Moore-Penrose
inverse
using the singular value composition of a matrix. This is incorporated in
the following:
mpinv <- function(A, eps = 1e-13) {
s <- svd(A)
e <- s$d
e[e > eps] <- 1/e[e > eps]
return(s$v %*% diag(e) %*% t(s$u))
}
Hope it helps.
Dietrich
2004 Feb 06
1
How to get the pseudo left inverse of a singular squarem atrix?
>I'm rusty, but not *that* rusty here, I hope.
>
>If W (=Z*Z' in your case) is singular, it can not
have >inverse, which by
>definition also mean that nothing multiply by it will
>produce the identity
>matrix (for otherwise it would have an inverse and
>thus nonsingular).
>
>The definition of a generalized inverse is something
>like: If A is a
>non-null
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.977515484 -291.7798965
2003 Aug 14
2
How to get the pseudo left inverse of a singular square matrix?
Dear R-listers,
I have a dxr matrix Z, where d > r.
And the product Z*Z' is a singular square matrix.
The problem is how to get the left inverse U of this
singular matrix Z*Z', such that
U*(Z*Z') = I?
Is there any to figure it out using matrix decomposition method?
Thanks a lot for your help.
Fred
2008 Apr 10
1
Computing time when calling C functions - why does an extra function call induce such an overhead?
Dear list,
I am a little puzzled by computing time in connection with calling C functions. With the function mysolve1 given below I solve Ax=B, where the actual matrix operation takes place in mysolve2. Doing this 5000 times takes 3.51 secs. However, if I move the actual matrix inversion part into mysolve1 (by uncommenting the two commented lines and skip the call to mysolve2) then the
2009 Feb 06
1
Linear model: contrasts
Hey,
I am modelling a linear regression Y=X*B+E. To compute the effect of ?group? the B-values of the regressors/columns that code the interaction effects (col. 5-8 and col. 11-14, see below) have to be weighted with non-zero elements within the contrast "Group 1" minus "Group 2" (see below). My first understanding was that the interaction effects add up to zero in each group.
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