[R] Matlab inv() and R solve() differences

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Fri Jan 30 14:12:41 CET 2009


Berend Hasselman wrote:
> 
> 
> Joseph P Gray wrote:
>> I submit the following matrix to both MATLAB and R
>>
>> x=  0.133 0.254 -0.214 0.116
>>     0.254 0.623 -0.674 0.139
>>    -0.214 -0.674 0.910 0.011
>>     0.116 0.139  0.011 0.180
>>
>> MATLAB's inv(x) provides the following
>>  137.21 -50.68 -4.70 -46.42
>> -120.71  27.28 -8.94 62.19
>> -58.15   6.93  -7.89  36.94
>>   8.35   11.17 10.42 -14.82
>>
>> R's solve(x) provides:
>> 261.94 116.22 150.92 -267.78
>> 116.22 344.30 286.68 -358.30
>> 150.92 286.68 252.96 -334.09
>> -267.78 =358.30 -334.09 475.22
>>
>>
> 
> The matrix x is clearly symmetric. Therefore I expect a symmetric inverse of
> x.
> The result of Matlab's inv(x) is clearly not symmetric.
> R's result is symmetric.
> 
> I find  what is shown as Matlab's result difficult to believe.

Yes. See my earlier post. (Well. I believe it, but not with the same input!)

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907




More information about the R-help mailing list