# Nonnegative Gaussian Process Regression

**URL:** <https://discourse.mc-stan.org/t/nonnegative-gaussian-process-regression/37682>\
**Category:** Modeling\
**Tags:** gaussian-process\
**Created:** [December 19, 2024, 4:38am UTC](https://discourse.mc-stan.org/t/nonnegative-gaussian-process-regression/37682 "2024-12-19T04:38:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sonicking](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sonicking](https://discourse.mc-stan.org/u/sonicking)\
**Post date:** [December 19, 2024, 4:38am UTC](https://discourse.mc-stan.org/t/nonnegative-gaussian-process-regression/37682/1 "2024-12-19T04:38:43Z")

</div>

Have anyone tried a Nonnegative Gaussian Process Regression? If you have, do you have any example code you may share?

What I mean is that the output is supposed to be non-negative.

I found a [paper](https://engineering.lehigh.edu/sites/engineering.lehigh.edu/files/_DEPARTMENTS/ise/pdf/tech-papers/20/20T_033.pdf) on this method but it does not use Bayesian method at all.

---

<div class="post-metadata">

**Author:** ![LucC](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/lucc/32/4475_2.png) [@LucC](https://discourse.mc-stan.org/u/LucC)\
**Post date:** [December 19, 2024, 9:22am UTC](https://discourse.mc-stan.org/t/nonnegative-gaussian-process-regression/37682/2 "2024-12-19T09:22:37Z")

</div>

Depending on what the non-negative outcome is (your post doesn’t say): if it is a continuous non-zero positive outcome, you could consider log-transforming it and modelling the result with a GP?

---

<div class="post-metadata">

**Author:** ![sonicking](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sonicking](https://discourse.mc-stan.org/u/sonicking)\
**Post date:** [December 20, 2024, 2:49am UTC](https://discourse.mc-stan.org/t/nonnegative-gaussian-process-regression/37682/3 "2024-12-20T02:49:35Z")

</div>

I appreciate the suggestion. The outcome is units of sale, which technically can be 0.  
I think the issue I am debating with log-transformation is that I think it is more customary to mean-center the outcome variable before running a GP-regression. I guess it is ok to compute log(y) then mean-center it…I would then add the constant back before exponentiation.

---

<div class="post-metadata">

**Author:** ![LucC](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/lucc/32/4475_2.png) [@LucC](https://discourse.mc-stan.org/u/LucC)\
**Post date:** [December 20, 2024, 7:47am UTC](https://discourse.mc-stan.org/t/nonnegative-gaussian-process-regression/37682/4 "2024-12-20T07:47:13Z")

</div>

If these are count data (i.e., non-continuous), may consider a count model (Poisson, negative binomial) with the logarithmic transformation as the link function and the GP for the linear predictor. I’m not a GP expert, so don’t know whether or how that may complicate things, but I don’t see how or why this wouldn’t be possible. At least you’d be treating the outcome data correctly.

---

<div class="post-metadata">

**Author:** ![sonicking](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sonicking](https://discourse.mc-stan.org/u/sonicking)\
**Post date:** [December 20, 2024, 3:27pm UTC](https://discourse.mc-stan.org/t/nonnegative-gaussian-process-regression/37682/5 "2024-12-20T15:27:58Z")

</div>

I need to think about this. Even though it is technically count, it is not customary to treat them as Poisson-like count because of the scale. But I appreciate your suggestion.

However, I would still like to know if there is a more direct way (like the [paper](https://engineering.lehigh.edu/sites/engineering.lehigh.edu/files/_DEPARTMENTS/ise/pdf/tech-papers/20/20T_033.pdf) I cited) to handle non-negativity in Stan…

---

<div class="post-metadata">

**Author:** ![avehtari](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/avehtari/32/5935_2.png) [@avehtari](https://discourse.mc-stan.org/u/avehtari)\
**Post date:** [December 21, 2024, 3:43pm UTC](https://discourse.mc-stan.org/t/nonnegative-gaussian-process-regression/37682/6 "2024-12-21T15:43:46Z")

</div>

It is completely valid to use GP as a prior for your desired data model through log or other link function. This is not different from generalised linear models, for which there are more than enough literature with formal justifications. Now the important part is what would be a good data model and knowing data is non-negative (if 0 is valid value) is not yet enough information. Is it possible that there are lot of 0’s (e.g. sales will be 0 for some time if the product is out of stock).
