How to calculate a precision matrix

956 views
Skip to first unread message

Linh Nguyen

unread,
Jul 31, 2013, 4:34:31 AM7/31/13
to r-inla-disc...@googlegroups.com
Dear All,

I am thinking how to calculate a precision matrix in a spatial model.
For example, in Gaussian Process, we can calculate a covariance matrix of unobserved locations, given observations.
Equivalently, can we compute such precision matrix in Gaussian Markov Random Field?

Thank you for your attention!

Finn Lindgren

unread,
Jul 31, 2013, 4:59:51 AM7/31/13
to Linh Nguyen, r-inla-disc...@googlegroups.com
When working with precision matrices and spatial models, things are done a bit differently than when working with covariance matrices.  I r-inla, the precision for the basis weights in a spatial spde model can be obtained from inla.spde.precision().  Calling that precision Qx, a linear Gaussian model with observation model y_i=(A x)_i + epsilon_i can be written as

X~N(mu, Qx)
Y|X=x ~ N(A x, Qeps)

The posterior distribution for X given Y=y is then given by

X|Y=y ~ N(mupost, Qpost)

Where

Qpost = Qx + A' Qeps A
mupost = mu + Qpost^-1 A' Qeps (y - A mu)

The basis weights in mupost can then be used to evaluate the posterior mean at any location of the field.  (The standard deviations require a bit more work and I don't have time to write all that in this email...)

All of this happens internally in r-inla and so it's not usually something one needs to do manually (except possibly when predicting onto more locations than inla can handle simultaneously)

So this only partially answered your question.  Other versions of the answer depends on _why_ you would want to have that precision matrix!

Finn



Thank you for your attention!

--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
To post to this group, send an email to r-inla-disc...@googlegroups.com.
Visit this group at http://groups.google.com/group/r-inla-discussion-group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Message has been deleted

Linh Nguyen

unread,
Jul 31, 2013, 5:41:32 AM7/31/13
to r-inla-disc...@googlegroups.com, Linh Nguyen
Dear Finn,

Thank you for your kind answer!

Actually I would calculate the entropy at unobserved locations given observations. In GP, I can do that based on covariance matrix. That's why I need your help.

Can you explain more please?
A is an observation matrix?
How about Qeps? Can I get Qeps from INLA?

Thanks!


On Wednesday, July 31, 2013 6:59:51 PM UTC+10, Finn Lindgren wrote:
On 31 Jul 2013, at 09:34, Linh Nguyen <linh.vaw...@gmail.com> wrote:

Dear All,

I am thinking how to calculate a precision matrix in a spatial model.
For example, in Gaussian Process, we can calculate a covariance matrix of unobserved locations, given observations.
Equivalently, can we compute such precision matrix in Gaussian Markov Random Field?

When working with precision matrices and spatial models, things are done a bit differently than when working with covariance matrices.  I r-inla, the precision for the basis weights in a spatial spde model can be obtained from inla.spde.precision().  Calling that precision Qx, a linear Gaussian model with observation model y_i=(A x)_i + epsilon_i can be written as

X~N(mu, Qx)
Y|X=x ~ N(A x, Qeps)

The posterior distribution for X given Y=y is then given by

X|Y=y ~ N(mupost, Qpost)

Where

Qpost = Qx + A' Qeps A
mupost = mu + Qpost^-1 A' Qeps (y - A mu)

The basis weights in mupost can then be used to evaluate the posterior mean at any location of the field.  (The standard deviations require a bit more work and I don't have time to write all that in this email...)

All of this happens internally in r-inla and so it's not usually something one needs to do manually (except possibly when predicting onto more locations than inla can handle simultaneously)

So this only partially answered your question.  Other versions of the answer depends on _why_ you would want to have that precision matrix!

Finn



Thank you for your attention!

--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsub...@googlegroups.com.

Finn Lindgren

unread,
Jul 31, 2013, 5:54:10 AM7/31/13
to r-inla-disc...@googlegroups.com, Linh Nguyen
On 31/07/13 10:41, Linh Nguyen wrote:
> Actually I would calculate the entropy at unobserved locations given
> observations. In GP, I can do that based on covariance matrix. That's
> why I need your help.
>
> Can you explain more please?

I'll send another email off-list...

> A is an observation matrix?

Yes.

> How about Qeps? Can I get Qeps from INLA?

No, Qeps you construct yourself; for independent observations with
common precision it's just an identity matrix scaled by the precision.
But how useful that is to you depends on exactly what you want to
calculate...

Finn

>
> Thanks!
>
> On Wednesday, July 31, 2013 6:59:51 PM UTC+10, Finn Lindgren wrote:
>
> On 31 Jul 2013, at 09:34, Linh Nguyen <linh.vaw...@gmail.com
>> r-inla-discussion...@googlegroups.com <javascript:>.
>> To post to this group, send an email to
>> r-inla-disc...@googlegroups.com <javascript:>.
>> <http://groups.google.com/group/r-inla-discussion-group>.
>> For more options, visit https://groups.google.com/groups/opt_out
>> <https://groups.google.com/groups/opt_out>.
>>
>>
> --
> You received this message because you are subscribed to the Google
> Groups "R-inla discussion group" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to r-inla-discussion...@googlegroups.com.

Finn Lindgren

unread,
Jul 31, 2013, 6:54:17 AM7/31/13
to r-inla-disc...@googlegroups.com
On 31/07/13 10:41, Linh Nguyen wrote:
> Actually I would calculate the entropy at unobserved locations given
> observations. In GP, I can do that based on covariance matrix. That's
> why I need your help.

Is this aimed at spatial design?
A quick google search took me to the book by Werner M�ller:

http://books.google.co.uk/books?id=ivyV9UpL8XkC&lpg=PA181&ots=-wEBz1gQzh&dq=entropy%20at%20unobserved%20locations&pg=PA181#v=onepage&q=entropy%20at%20unobserved%20locations&f=false

I'm not aware of any papers discussing how to this practically for GMRF
models, and certainly not for triangulated spde models; but in your
original email you didn't say precisely what type of gmrf models you
were interested in.

With some more details of precisely what you are trying to compute I may
be able to give some advice.

Finn

Linh Nguyen

unread,
Jul 31, 2013, 7:37:15 AM7/31/13
to r-inla-disc...@googlegroups.com


On Wednesday, July 31, 2013 8:54:17 PM UTC+10, Finn Lindgren wrote:
On 31/07/13 10:41, Linh Nguyen wrote:
> Actually I would calculate the entropy at unobserved locations given
> observations. In GP, I can do that based on covariance matrix. That's
> why I need your help.

Is this aimed at spatial design?
A quick google search took me to the book by Werner M�ller:

I am learning something regarding monitoring network design, particularly for spatial, spatio-temporal phenomena.

http://books.google.co.uk/books?id=ivyV9UpL8XkC&lpg=PA181&ots=-wEBz1gQzh&dq=entropy%20at%20unobserved%20locations&pg=PA181#v=onepage&q=entropy%20at%20unobserved%20locations&f=false

I'm not aware of any papers discussing how to this practically for GMRF
models, and certainly not for triangulated spde models; but in your
original email you didn't say precisely what type of gmrf models you
were interested in.

In continuous case, I used GP model for my issue, but I have not done with spatio-temporal GP model.
From your papers and some tutorials in r-inla.org I would like to use the SPDE models due to some advantages in computation.
 
With some more details of precisely what you are trying to compute I may
be able to give some advice.

I am trying to calculate conditional entropy that represents the uncertainty remained in random vectors in unobserved locations (perhaps including uncertainty of hyperparameters, but tough) given observations. Minimizing this entropy I can find optimal sampling paths.
Can you give me advice?

Finn

Linh Nguyen

unread,
Aug 7, 2013, 8:33:35 AM8/7/13
to r-inla-disc...@googlegroups.com, Linh Nguyen


On Wednesday, July 31, 2013 6:59:51 PM UTC+10, Finn Lindgren wrote:
On 31 Jul 2013, at 09:34, Linh Nguyen <linh.vaw...@gmail.com> wrote:

Dear All,

I am thinking how to calculate a precision matrix in a spatial model.
For example, in Gaussian Process, we can calculate a covariance matrix of unobserved locations, given observations.
Equivalently, can we compute such precision matrix in Gaussian Markov Random Field?

When working with precision matrices and spatial models, things are done a bit differently than when working with covariance matrices.  I r-inla, the precision for the basis weights in a spatial spde model can be obtained from inla.spde.precision().  Calling that precision Qx, a linear Gaussian model with observation model y_i=(A x)_i + epsilon_i can be written as

In inla.spde.precision(), we need to define the parameters called "theta". These parameters can get from inla.spde2.result()? Are they log.tau, log.kappa or exp(log.tau), exp(log.kappa)?
 

X~N(mu, Qx)
Y|X=x ~ N(A x, Qeps)

The posterior distribution for X given Y=y is then given by

X|Y=y ~ N(mupost, Qpost)

Where

Qpost = Qx + A' Qeps A
mupost = mu + Qpost^-1 A' Qeps (y - A mu)

The basis weights in mupost can then be used to evaluate the posterior mean at any location of the field.  (The standard deviations require a bit more work and I don't have time to write all that in this email...)

All of this happens internally in r-inla and so it's not usually something one needs to do manually (except possibly when predicting onto more locations than inla can handle simultaneously)

So this only partially answered your question.  Other versions of the answer depends on _why_ you would want to have that precision matrix!

Finn



Thank you for your attention!

--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsub...@googlegroups.com.

Finn Lindgren

unread,
Aug 7, 2013, 8:58:05 AM8/7/13
to Linh Nguyen, r-inla-disc...@googlegroups.com, Linh Nguyen
On 7 Aug 2013, at 08:33, Linh Nguyen <linh.vaw...@gmail.com> wrote:
On Wednesday, July 31, 2013 6:59:51 PM UTC+10, Finn Lindgren wrote:
When working with precision matrices and spatial models, things are done a bit differently than when working with covariance matrices.  I r-inla, the precision for the basis weights in a spatial spde model can be obtained from inla.spde.precision().  Calling that precision Qx, a linear Gaussian model with observation model y_i=(A x)_i + epsilon_i can be written as

In inla.spde.precision(), we need to define the parameters called "theta". These parameters can get from inla.spde2.result()? Are they log.tau, log.kappa or exp(log.tau), exp(log.kappa)?

No, the theta-parameters are the parameters in the log linear models for tau and kappa.  Please see the definitions in the tutorial at

The definition of the model and the meaning of theta is on page 3 and 4.

Finn

 

X~N(mu, Qx)
Y|X=x ~ N(A x, Qeps)

The posterior distribution for X given Y=y is then given by

X|Y=y ~ N(mupost, Qpost)

Where

Qpost = Qx + A' Qeps A
mupost = mu + Qpost^-1 A' Qeps (y - A mu)

The basis weights in mupost can then be used to evaluate the posterior mean at any location of the field.  (The standard deviations require a bit more work and I don't have time to write all that in this email...)

All of this happens internally in r-inla and so it's not usually something one needs to do manually (except possibly when predicting onto more locations than inla can handle simultaneously)

So this only partially answered your question.  Other versions of the answer depends on _why_ you would want to have that precision matrix!

Finn



Thank you for your attention!

--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsub...@googlegroups.com.
To post to this group, send an email to r-inla-disc...@googlegroups.com.
Visit this group at http://groups.google.com/group/r-inla-discussion-group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.

Finn Lindgren

unread,
Aug 7, 2013, 9:09:42 AM8/7/13
to Linh Nguyen, r-inla-disc...@googlegroups.com, Linh Nguyen
Addition:
The estimated theta values are available from inla.spde2.result(),
At least in "BLC", but I believe they have a separate entry as well.

Finn

Linh Nguyen

unread,
Aug 13, 2013, 2:26:34 AM8/13/13
to r-inla-disc...@googlegroups.com, Linh Nguyen
Hi Finn,


On Wednesday, July 31, 2013 6:59:51 PM UTC+10, Finn Lindgren wrote:
On 31 Jul 2013, at 09:34, Linh Nguyen <linh.vaw...@gmail.com> wrote:

When working with precision matrices and spatial models, things are done a bit differently than when working with covariance matrices.  I r-inla, the precision for the basis weights in a spatial spde model can be obtained from inla.spde.precision().  Calling that precision Qx, a linear Gaussian model with observation model y_i=(A x)_i + epsilon_i can be written as

X~N(mu, Qx)
Y|X=x ~ N(A x, Qeps)

The posterior distribution for X given Y=y is then given by

X|Y=y ~ N(mupost, Qpost)

Where

Qpost = Qx + A' Qeps A
mupost = mu + Qpost^-1 A' Qeps (y - A mu)

The basis weights in mupost can then be used to evaluate the posterior mean at any location of the field.  

(The standard deviations require a bit more work and I don't have time to write all that in this email...)
 
Can you send me some documents regarding these standard deviations?



All of this happens internally in r-inla and so it's not usually something one needs to do manually (except possibly when predicting onto more locations than inla can handle simultaneously)

So this only partially answered your question.  Other versions of the answer depends on _why_ you would want to have that precision matrix!

Finn



Thank you for your attention!

--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsub...@googlegroups.com.

Linh Nguyen

unread,
Aug 13, 2013, 3:22:12 AM8/13/13
to r-inla-disc...@googlegroups.com, Linh Nguyen
Hi Finn,

 
When working with precision matrices and spatial models, things are done a bit differently than when working with covariance matrices.  I r-inla, the precision for the basis weights in a spatial spde model can be obtained from inla.spde.precision().  Calling that precision Qx, a linear Gaussian model with observation model y_i=(A x)_i + epsilon_i can be written as

If I have a set of observations {y_i}, i = 1 .. 100
Now I would compute the precision matrix of a subset (10 points) of this set. Is this possible? May I extract from Qx?

Thanks!

X~N(mu, Qx)
Y|X=x ~ N(A x, Qeps)

The posterior distribution for X given Y=y is then given by

X|Y=y ~ N(mupost, Qpost)

Where

Qpost = Qx + A' Qeps A
mupost = mu + Qpost^-1 A' Qeps (y - A mu)

The basis weights in mupost can then be used to evaluate the posterior mean at any location of the field.  (The standard deviations require a bit more work and I don't have time to write all that in this email...)

All of this happens internally in r-inla and so it's not usually something one needs to do manually (except possibly when predicting onto more locations than inla can handle simultaneously)

So this only partially answered your question.  Other versions of the answer depends on _why_ you would want to have that precision matrix!

Finn



Thank you for your attention!

--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsub...@googlegroups.com.

Finn Lindgren

unread,
Aug 13, 2013, 3:47:21 AM8/13/13
to Linh Nguyen, r-inla-disc...@googlegroups.com, Linh Nguyen
On 13 Aug 2013, at 08:22, Linh Nguyen <linh.vaw...@gmail.com> wrote:

Hi Finn,

 
When working with precision matrices and spatial models, things are done a bit differently than when working with covariance matrices.  I r-inla, the precision for the basis weights in a spatial spde model can be obtained from inla.spde.precision().  Calling that precision Qx, a linear Gaussian model with observation model y_i=(A x)_i + epsilon_i can be written as

If I have a set of observations {y_i}, i = 1 .. 100
Now I would compute the precision matrix of a subset (10 points) of this set. Is this possible? May I extract from Qx?

What I tried to explain was that this is not how one normally does things with GMRF models.  It is of course theoretically possible to numerically compute such a matrix, but it is not really useful.  Why do you think you need that matrix?
Finn


Thanks!

X~N(mu, Qx)
Y|X=x ~ N(A x, Qeps)

The posterior distribution for X given Y=y is then given by

X|Y=y ~ N(mupost, Qpost)

Where

Qpost = Qx + A' Qeps A
mupost = mu + Qpost^-1 A' Qeps (y - A mu)

The basis weights in mupost can then be used to evaluate the posterior mean at any location of the field.  (The standard deviations require a bit more work and I don't have time to write all that in this email...)

All of this happens internally in r-inla and so it's not usually something one needs to do manually (except possibly when predicting onto more locations than inla can handle simultaneously)

So this only partially answered your question.  Other versions of the answer depends on _why_ you would want to have that precision matrix!

Finn



Thank you for your attention!

--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsub...@googlegroups.com.
To post to this group, send an email to r-inla-disc...@googlegroups.com.
Visit this group at http://groups.google.com/group/r-inla-discussion-group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages