[R] ginv vs. solve
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Thu Aug 7 13:57:26 CEST 2003
"Angel" <angel_lul at hotmail.com> writes:
> 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
[ginv() is from MASS, please remember to tell us]
Your b is on the wrong side, try ginv(A)%*%b (possibly put it within
drop() to convert it to vector).
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list