Herbert_Desson@jltgroup.com
2004-Dec-13 17:19 UTC
[R] Re: Help : generating correlation matrix with a particula r
************************************************************ Important: We would draw your attention to the notices at the bottom of this e-mail, particularly before opening and reviewing any file attachment(s). ************************************************************ Martin, Thank you for letting us know about posdefify. It does do exactly what the Rebonato paper recommended and gives the same result as our code, but it will be much better behaved in the wild than ours will. BTW Troels Ring [tring at gvdnet.dk] found the Rebonato paper at http://www.quarchome.com/correlationmatrix.pdf Thank you Troels. Best regards, Herb Herbert G. Desson, ACAS, MAAA Actuary JLT Risk Solutions 6 Crutched Friars London EC3N 2PH phone: +44 (0)20 7528 4702 fax: +44 (0)20 7558 3785 -----Original Message----- ************************************************************ JLT Risk Solutions Ltd 6 Crutched Friars, London EC3N 2PH. Co Reg No 1536540 Tel: (44) (0)20 7528 4000 Fax: (44) (0)20 7528 4500 http://www.jltgroup.com Lloyd's Broker. Regulated by the General Insurance Standards Council ------------------------------------------------------------ The content of this e-mail (including any attachments) as received may not be the same as sent. If you consider that the content is material to the formation or performance of a contract or you are otherwise relying upon its accuracy, you should consider requesting a copy be sent by facsimile or normal mail. In any event, please check this message and any identified file attachment(s) upon receipt and notify the sender immediately if there is any manifest transmission error, omission or corruption. This does not change or reduce any party's duty of utmost good faith when contracting for insurance or reinsurance. The information in this e-mail is confidential and may be legally privileged. If you are not the intended recipient, please notify the sender immediately and then delete this e-mail entirely - you must not retain, copy, distribute or use this e-mail for any purpose or disclose any of its content to others. Opinions, conclusions and other information in this e-mail that do not relate to the official business of JLT Risk Solutions Ltd shall be understood as neither given nor endorsed by it. Please note we intercept and monitor incoming / outgoing e-mail and therefore you should neither expect nor intend any e-mail to be private in nature. We have checked this e-mail for viruses and other harmful components and believe but not guarantee it virus-free prior to leaving our computer system. However, you should satisfy yourself that it is free from harmful components, as we do not accept responsibility for any loss or damage it may cause to your computer systems. ************************************************************ From: Martin Maechler [mailto:maechler at stat.math.ethz.ch] Sent: 13 December 2004 16:04 To: Herbert_Desson at jltgroup.com Cc: r-help at stat.math.ethz.ch Subject: Re: [R] Re: Help : generating correlation matrix with a particular>>>>> "Herbert" == Herbert Desson <Herbert_Desson at jltgroup.com> >>>>> on Mon, 13 Dec 2004 12:24:10 -0000 writes:Herbert> Here is some code we have used. Herbert> a<-array(c(1,.9,.7,.9,1,.3,.7,.3,1),dim=c(3,3)) Herbert> a Herbert> s<-eigen(a)$vectors Herbert> l<-diag(eigen(a)$values) Herbert> l[l<0]<-0 Herbert> b<-s%*%sqrt(l) Herbert> for(i in 1:nrow(b)){b[i,]<-b[i,]/sqrt(sum(b[i,]^2))} Herbert> ap<-b%*%t(b) Herbert> ap This code does the same thing as my (simplistic, but slightly more general) function posdefify() in package "sfsmisc" : a <- matrix(c(1,.9,.7,.9,1,.3,.7,.3,1), 3) install.packages("sfsmisc") library(sfsmisc) posdefify(a) gives [,1] [,2] [,3] [1,] 1.0000000 0.8940242 0.6963190 [2,] 0.8940242 1.0000000 0.3009691 [3,] 0.6963190 0.3009691 1.0000000 Herbert> It is based on a paper by Rebonato etal that formerly was at Herbert> www.rebonato.com/correlationmatrix.pdf. Herbert> Unfortunately the website has disappeared. The idea is very simple and has been re-invented many times as far as I know. More sophisticated methods for "posdefiying" a matrix exist in other places. Given symmetrix matrix A, they try to find the matrix Ap, positive definite, such ||A - Ap|| is minimal. The eigen-value based simple solution that you've used above and I've also coded in posdefify(), is not the same one would get for `usual' matrix norms || . || [[NB: posdefify() also has a 2nd method the implementation of which has an embarassing bug. The next version of sfsmisc, due in a day or two, will have it fixed. ]] Does anyone know of rigorous mathematical results in this regard? Martin Maechler, ETH Zurich