Dear Peter, > -----Original Message----- > From: peter dalgaard [mailto:pda...@gmail.com] > Sent: Thursday, December 10, 2015 11:09 AM > To: Stefano Sofia > Cc: Fox, John; r-help@r-project.org > Subject: Re: [R] matrix which results singular but at the same time > positive definite > > Looks like the ill-conditioning is almost entirely due to scaling, e.g.
Yes, that's my point. Sorry I didn't make it clearer. Best, John > > > eigen(cov2cor(m)) > $values > [1] 1.7234899 1.3380701 0.6619299 0.2765101 > ... > > This is an annoyance in several parts of numerical linear algebra: > Routines assume that R^n has all coordinates on a similar scale and > therefore think that anything on the order of 1e-7 or so is effectively > zero. > > Condition numbers do this too: > > > kappa(m) > [1] 1.066582e+13 > > kappa(cov2cor(m)) > [1] 5.489243 > > > -pd > > On 10 Dec 2015, at 16:41 , Stefano Sofia > <stefano.so...@regione.marche.it> wrote: > > > Dear John, > > thank you for your considerations. > > This matrix (which is a variance matrix) is part of an algorithm for > forward-filtering and backward-sampling of Dynamic Linear Models (West > and Harrison, 1997), applied to DLM representation of ARIMA processes > (Petris, Petrone, Campagnoli). It is therefore very difficult to > explain why this variance matrix becomes so ill conditioned. This > already happens at the first iteration of the algorithm. I will try to > work on initial conditions and some fixed parameters. > > > > Thank you again > > Stefano > > > > > > ________________________________________ > > Da: Fox, John [j...@mcmaster.ca] > > Inviato: giovedì 10 dicembre 2015 14.41 > > A: Stefano Sofia; r-help@r-project.org > > Oggetto: RE: matrix which results singular but at the same time > positive definite > > > > Dear Stefano, > > > > You've already had a couple of informative responses directly > addressing your question, but are you aware how ill-conditioned the > matrix is (one of the responses alluded to this)? > > > >> kappa(X, exact=TRUE) > > [1] 7.313338e+12 > > > >> eigen(X)$values > > [1] 4.964711e+00 9.356881e-01 4.863392e-12 6.788344e-13 > > > > Two of the variables have variances around 10^0 and the other two > around 10^-12. Of course, you haven't said anything about the context, > but does it really make sense to analyze the data on these scales? > > > > Best, > > John > > > > ----------------------------- > > John Fox, Professor > > McMaster University > > Hamilton, Ontario > > Canada L8S 4M4 > > Web: socserv.mcmaster.ca/jfox > > > > > > > > > >> -----Original Message----- > >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > Stefano Sofia > >> Sent: December 10, 2015 5:08 AM > >> To: r-help@r-project.org > >> Subject: [R] matrix which results singular but at the same time > positive definite > >> > >> Dear list users, > >> through the "matrixcalc" package I am performing some checks of > variance > >> matrices (which must be positive definite). > >> In this example, it happens that the matrix A here reported is > singular but > >> positive definite. Is it possible? > >> > >> [,1] [,2] [,3] [,4] > >> [1,] 1.904255e-12 -1.904255e-12 -8.238960e-13 -1.240294e-12 [2,] - > >> 1.904255e-12 3.637979e-12 1.364242e-12 1.818989e-12 [3,] - > 8.238960e-13 > >> 1.364242e-12 4.809988e+00 7.742369e-01 [4,] -1.240294e-12 > 1.818989e-12 > >> 7.742369e-01 1.090411e+00 > >> > >> print(is.non.singular.matrix(A, tol = 1e-18)) FALSE > print(is.positive.definite(A, > >> tol=1e-18)) TRUE > >> > >> Is there something wrong with this matrix? > >> Any comment will be appreciated. > >> Stefano > >> > >> > >> ________________________________ > >> > >> AVVISO IMPORTANTE: Questo messaggio di posta elettronica può > contenere > >> informazioni confidenziali, pertanto è destinato solo a persone > autorizzate alla > >> ricezione. I messaggi di posta elettronica per i client di Regione > Marche > >> possono contenere informazioni confidenziali e con privilegi legali. > Se non si è il > >> destinatario specificato, non leggere, copiare, inoltrare o > archiviare questo > >> messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo > al mittente > >> ed eliminarlo completamente dal sistema del proprio computer. Ai > sensi > >> dell'art. 6 della DGR n. 1394/2008 si segnala che, in caso di > necessità ed > >> urgenza, la risposta al presente messaggio di posta elettronica può > essere > >> visionata da persone estranee al destinatario. > >> IMPORTANT NOTICE: This e-mail message is intended to be received only > by > >> persons entitled to receive the confidential information it may > contain. E-mail > >> messages to clients of Regione Marche may contain information that is > >> confidential and legally privileged. Please do not read, copy, > forward, or store > >> this message unless you are an intended recipient of it. If you have > received > >> this message in error, please forward it to the sender and delete it > completely > >> from your computer system. > >> > >> [[alternative HTML version deleted]] > >> > >> ______________________________________________ > >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >> https://stat.ethz.ch/mailman/listinfo/r-help > >> PLEASE do read the posting guide http://www.R-project.org/posting- > >> guide.html > >> and provide commented, minimal, self-contained, reproducible code. > > > > ________________________________ > > > > AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere > informazioni confidenziali, pertanto è destinato solo a persone > autorizzate alla ricezione. I messaggi di posta elettronica per i client > di Regione Marche possono contenere informazioni confidenziali e con > privilegi legali. Se non si è il destinatario specificato, non leggere, > copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto > questo messaggio per errore, inoltrarlo al mittente ed eliminarlo > completamente dal sistema del proprio computer. Ai sensi dell'art. 6 > della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, > la risposta al presente messaggio di posta elettronica può essere > visionata da persone estranee al destinatario. > > IMPORTANT NOTICE: This e-mail message is intended to be received only > by persons entitled to receive the confidential information it may > contain. E-mail messages to clients of Regione Marche may contain > information that is confidential and legally privileged. Please do not > read, copy, forward, or store this message unless you are an intended > recipient of it. If you have received this message in error, please > forward it to the sender and delete it completely from your computer > system. > > > > ______________________________________________ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > > and provide commented, minimal, self-contained, reproducible code. > > -- > Peter Dalgaard, Professor, > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Office: A 4.23 > Email: pd....@cbs.dk Priv: pda...@gmail.com > > > > > > > > ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.