[Rd] Probable Numeric Bugs in svd function (PR#8781)

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Apr 20 08:28:52 CEST 2006


This is unreadable, but getting as far as the first couple of lines it 
seems to be unreproducible (what are Sp5 and Region?).

You have also not told us the version of R, platform, and crucial details 
such as what BLAS was used.

Can you please use the web interface to R-bugs to add (use this PR in the 
subject line) a complete, readable and reproducible example?


On Wed, 19 Apr 2006, Mehdi.Kheloufi-Trabaud at moodys.com wrote:

> Hello,=0D
> =0D
> I just noticed that the "svd" function does not work properly for some=0D
> sparse matrices.=0D
> When I replace the 0 by very small noises (let's say 10^-16), it then=0D
> works.=0D
> The test I've performed is to compared the singular values to the eigen=0D
> values (as I work with squarred matrices).=0D
> =0D
> Here is the code (I may be wrong!):=0D
> =0D
> usHigh<-(Sp5>=3D300 & Region=3D=3D1)=0D
> usLow<-(Sp5<300 & Region=3D=3D1)=0D
> euHigh<-(Sp5>=3D200 & Region=3D=3D2)=0D
> euLow<-(Sp5<200 & Region=3D=3D2)=0D
> sigmas<-c(13.71,162.71,8.78,103.83,5.29,77.08,3.42,41.04)=0D
> temp1<-sigmas[1]*usLow+sigmas[2]*usHigh+sigmas[5]*euLow+sigmas[6]*euHigh=0D
> temp10<-sigmas[3]*usLow+sigmas[4]*usHigh+sigmas[7]*euLow+sigmas[8]*euHig=0D
> h=0D
> CorrEU<-0.89=0D
> CorrUS<-0.82=0D
> =0D
> CorrR<-matrix(0,2*SN.nb,2*SN.nb)=0D
> diag(CorrR)<-c(temp1^2,temp10^2)=0D
> =0D
> temp<-ifelse(Region=3D=3D1,CorrUS,CorrEU)=0D
> tempMat<-matrix(0,SN.nb,SN.nb)=0D
> diag(tempMat)<-temp*temp1*temp10=0D
> CorrR[(SN.nb+1):(2*SN.nb),1:SN.nb]<-tempMat=0D
> CorrR[1:SN.nb,(SN.nb+1):(2*SN.nb)]<-tempMat=0D
> =0D
> CorrR is positive definite but "svd" returns negative singular values!=0D
> When replacing 0s by very week noises, the error disppears.=0D
> =0D
> Hope I'm not saying stupid things.=0D
> =0D
> Rgds,=0D
> =0D
> Mehdi=0D
> =0D
> =0D
> =0D
> =0D
> =0D
> =0D
> -----------------------------------------=0D
> The information contained in this e-mail message, and any=0D
> attachment thereto, is confidential and may not be disclosed=0D
> without our express permission. If you are not the intended=0D
> recipient or an employee or agent responsible for delivering this=0D
> message to the intended recipient, you are hereby notified that you=0D
> have received this message in error and that any review,=0D
> dissemination, distribution or copying of this message, or any=0D
> attachment thereto, in whole or in part, is strictly prohibited. If=0D
> you have received this message in error, please immediately notify=0D
> us by telephone, fax or e-mail and delete the message and all of=0D
> its attachments. Thank you. Every effort is made to keep our=0D
> network free from viruses. You should, however, review this e-mail=0D
> message, as well as any attachment thereto, for viruses. We take no=0D
> responsibility and have no liability for any computer virus which=0D
> may be transferred via this e-mail message.=0D
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list