Skip to content
Prev 167078 / 398502 Next

Precision in R

Hi,
I attached the files I'm using, it may help.
I'm using Windows XP
R version 2.6.0 (2007-10-03) 
i386-pc-mingw32 
locale: LC_COLLATE=English_New Zealand.1252;LC_CTYPE=English_New
Zealand.1252;LC_MONETARY=English_New
Zealand.1252;LC_NUMERIC=C;LC_TIME=English_New Zealand.1252
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

Try for example: 
WB<-as.matrix(read.table("WB.dat"))
tcp1 <- tcrossprod(WB)
tcp2 <- crossprod(t(WB))
 
 solve(tcp1)
          [,1]      [,2]       [,3]
[1,] -41692.80  58330.89  -78368.17
[2,]  58330.89 -81608.66  109642.09
[3,] -78368.17 109642.09 -147305.32

solve(tcp2)
Error in solve.default(tcp2) : 
  system is computationally singular: reciprocal condition number =
2.17737e-17

Marlon.

-----Original Message-----
From: Charles C. Berry [mailto:cberry at tajo.ucsd.edu] 
Sent: Thursday, 15 January 2009 5:16 p.m.
To: dos Reis, Marlon
Cc: r-help at r-project.org
Subject: Re: [R] Precision in R


Marlon,

Are you using a current version of R? sessionInfo()?

It would help if you had something we could _fully_ reproduce.

Taking the _printed_ values you have below (WBtWB) and adding or 
subtracting what you have printed as the difference of the two visually 
equal matrices ( say Delta ) , I am able to run

 	solve( dat3 )
 	solve( WBtWB + Delta )
 	solve( WBtWB - Delta )
 	solve( WBtWB + 2*Delta )
 	solve( WBtWB - 2*Delta )

and get the results to agree to 3 significant digits. And perturbing 
things even more I still get solve() to return a value:
And I cannot get condition numbers anything like what you report:
[1] 5.917764e-11 3.350445e-09
So I am very curious that you got the results that you print below.

I suppose that it is possible that the difference between what you
report 
and what I see lies in the numerical libraries (LINPACK/LAPACK) that R 
calls upon.

This was done on a windows XP PC. Here is my sessionInfo()
R version 2.8.1 Patched (2008-12-22 r47296)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
HTH,

Chuck
On Thu, 15 Jan 2009, dos Reis, Marlon wrote:

            
=======================================================================
and...{{dropped:15}}
http://www.R-project.org/posting-guide.html
Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive
Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego
92093-0901



=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================