[R] matrix which results singular but at the same time positive definite

Fox, John jfox at mcmaster.ca
Thu Dec 10 16:52:01 CET 2015


Dear Stefano,

I don't really know anything about your application, but my point is about the scaling of the variables. Can't you rescale some or all of the variables so their variances aren't so different? For example, the correlation matrix among these four variables isn't ill-conditioned.

Best,
 John

> -----Original Message-----
> From: Stefano Sofia [mailto:stefano.sofia at regione.marche.it]
> Sent: Thursday, December 10, 2015 10:42 AM
> To: Fox, John; r-help at r-project.org
> Subject: RE: matrix which results singular but at the same time positive
> definite
> 
> 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 [jfox at mcmaster.ca]
> Inviato: giovedì 10 dicembre 2015 14.41
> A: Stefano Sofia; r-help at 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-bounces at r-project.org] On Behalf Of
> Stefano Sofia
> > Sent: December 10, 2015 5:08 AM
> > To: r-help at 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 at 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.



More information about the R-help mailing list