# Gaussian Processes. Latent vs Marginal

**URL:** <https://discourse.pymc.io/t/gaussian-processes-latent-vs-marginal/13154>\
**Category:** General\
**Tags:** gaussian\_process, modeling\
**Created:** [October 23, 2023, 9:54am UTC](https://discourse.pymc.io/t/gaussian-processes-latent-vs-marginal/13154 "2023-10-23T09:54:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aabugaev](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/aabugaev/32/7515_2.png) [@aabugaev](https://discourse.pymc.io/u/aabugaev)\
**Post date:** [October 23, 2023, 9:54am UTC](https://discourse.pymc.io/t/gaussian-processes-latent-vs-marginal/13154/1 "2023-10-23T09:54:21Z")

</div>

Hello, PyMC community!

I recently started discovering Gaussian Processes, but feel that those can be very powerful tools for modelling.

Can you please help me understand the difference between Latent and Marginal processes?  
From PyMC docs I can only understand that [Marginal](https://www.pymc.io/projects/docs/en/stable/api/gp/generated/pymc.gp.Marginal.html) has additive noise (while [Latent](https://www.pymc.io/projects/docs/en/stable/api/gp/generated/pymc.gp.Latent.html) does not).

Therefore:

1. Can you please say if there’s any difference for using Marginal and Latent processes on interpretation level? (i.e. for modelling which cases is best to choose which?)

2. I can as well see that there are some differences on how Marginal and Latent are implemented technically, e.g.:

- you cannot use Periodic covariance function with Latent processes (only Marginal)
- you can add some Latent process into your `pm.Deterministic`, while it seems to be impossible for Marginal
- Marginal process requires some very specific `gp.marginal_likelihood`

Are those peculiarities related to some conceptual difference of the processes or are purely technical?

Very much appreciate your recommendations!

---

<div class="post-metadata">

**Author:** ![fonnesbeck](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/fonnesbeck/32/13_2.png) [@fonnesbeck](https://discourse.pymc.io/u/fonnesbeck)\
**Post date:** [October 23, 2023, 3:22pm UTC](https://discourse.pymc.io/t/gaussian-processes-latent-vs-marginal/13154/2 "2023-10-23T15:22:45Z")

</div>

The latent GP is typically used when you have a non-normal likelihood, or when you want to add additional components to the model before passing it to the likelihood. For example, if you are analyzing count data, you will likely assume a Poisson or negative binomial data generating process, so you would model the mean as a latent GP, and transform it before passing it to the likelihood. The interpretation is really no different. You should be able to use a periodic covariance with a latent GP, AFAIK.

---

<div class="post-metadata">

**Author:** ![bwengals](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/bwengals/32/1237_2.png) [@bwengals](https://discourse.pymc.io/u/bwengals)\
**Post date:** [October 24, 2023, 5:38am UTC](https://discourse.pymc.io/t/gaussian-processes-latent-vs-marginal/13154/3 "2023-10-24T05:38:15Z")

</div>

Just want to add that you can use any covariance for either `Marginal` or `Latent`, no restrictions.
