[R] ginv vs. solve

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Aug 7 13:49:46 CEST 2003


Uwe Ligges wrote:

> Angel wrote:
> 
>> Why do
>> x<-b%*%ginv(A)
>

> Why should it be the same???
> Here, you are calculating  (A+ is G-Inverse)
> 
>   x = b * A+

Let me add: More exactly, you are calculating

x = b' * A+

because b * A+ doesn't fit and R is somehow "intelligent" here and 
transposes b for you instead of complaining ...

Uwe

>> and
>> x<-solve(A,b)
> 
> 
> Here, you are calculating (A- is Inverse of A)
> 
>   A * x = b  <=> A- * A * x = A- * b <=>
>   x = A- * b
> 
> So you have to compare, e.g.:
> 
>  ginv(A) %*% b
>  solve(A, b)
> 
> Uwe Ligges
> 
> 
>> 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
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list