Re: [ojAlgo-user] covariance matrix
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Anders P. <an...@op...> - 2007-07-18 14:18:07
|
On 18 jul 2007, at 12.38, Dimitri Pourbaix wrote: > On Wed, 18 Jul 2007, Anders Peterson wrote: > >> Both QR and SVD do least squares fitting. Just call solve(?) and >> that's what you get. QR is faster and often good enough, but in >> some cases it could have numerical problems that the SVD probably >> will not have. > > Well, in my case, robustness is more important than speed. If accuracy is what you want perhaps you should try BigQR http://ojalgo.org/generated/org/ojalgo/matrix/decomposition/BigQR.html /Anders >> Exactly how do you calculate the parameter covariance matrix using >> the SVD? > > Starting with V and S the two matrices from SVD, Sv is the double[] > array > of S > > double[][] Sm2v = new double[dimModel][dimModel]; > for (int i=0;i<dimModel;i++) { > for (int j=0;j<dimModel;j++) { > Sm2v[i][j]=0.0; > } > Sm2v[i][i]=1.0; > } > for (int j = 0; j < dimModel; j++) { > Sm2v[j][j] /= (Sv[j] * Sv[j]); > } > Matrix Sm2 = new Matrix(Sm2v); > covMat = V.times(Sm2.times(V.transpose())); > > Regards, > Dim. > ---------------------------------------------------------------------- > ------ > Dimitri Pourbaix * > Institut d'Astronomie et d'Astrophysique * Don't worry, be happy > CP 226, office 2.N4.211, building NO * and CARPE DIEM. > Universite Libre de Bruxelles * > Boulevard du Triomphe * Tel : +32-2-650.35.71 > B-1050 Bruxelles * Fax : +32-2-650.42.26 > http://sb9.astro.ulb.ac.be/~pourbaix * > mailto:pou...@as... > > |