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

Mehdi.Kheloufi-Trabaud at moodys.com Mehdi.Kheloufi-Trabaud at moodys.com
Wed Apr 19 19:36:38 CEST 2006


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]]



More information about the R-devel mailing list