GP with multiplicative factor

Hello everyone,
I am wondering how to define the following GP using gp.Marginal:

\eta f(x) + g(x)

where

f(x) \sim GP(m_1(x), K_1(x,x')), and g(x) \sim GP(m_2(x), K_2(x,x')) and \eta is a RV. Stuf like

with pm.Model()
   eta = pm.InverseGamma("eta", alpha = 5,
                                               beta = 1)
   beta = pm.Normal("beta", mu = 0, sd =1)

  model_mean = pm.gp.mean.Linear(coeffs =beta)
  model_cov = pm.gp.cov.Constant(1)

  model_marginal_gp = eta * pm.gp.Marginal(mean_func = model_mean, cov_func = model_cov)

fails because the multiplication of a RV with gp.Marginal is not allowed. The same for

with pm.Model()
  eta = pm.InverseGamma("eta", alpha = 5,
                                               beta = 1)

  beta = pm.Normal("beta", mu = 0, sd =1)

  model_mean = eta * pm.gp.mean.Linear(coeffs =beta)
  model_cov = eta ** 2 * pm.gp.cov.Constant(1)

  model_marginal_gp = pm.gp.Marginal(mean_func = model_mean, cov_func = model_cov)

Here it fails because the multiplication of the mean function.

I will be grateful for any tips :slight_smile:

What about multiplying a pm.gp.Latent?

Hi @kejzlarv, as far as I have used gaussian processes in PyMC3, you cannot do let’s say
3 * gp_1 + 2 * gp_2. You can just simply add them.

However, in the second example, you have multiplied eta with the mean of GP and also with the covariance function. So, what actually is eta? Is it output variance?

Lastly, you can try Mixture. However, I haven’t tried it yet. I would be curious to know how you solve the problem, so please provide updates if possible. I hope my comments were helpful! :sweat_smile:

\eta is like a regression parameter, I model my data as this:

y_i = \eta f(x_i, \theta) + \delta(x_i) + e_i,

where \theta is unknown calibration parameter.

I was able to make it work by simply:

with pm.Model()
  eta = pm.InverseGamma("eta", alpha = 5,
                                               beta = 1)

  beta = pm.Normal("beta", mu = 0, sd =1)

  model_mean = pm.gp.mean.Linear(coeffs =beta * eta)
  model_cov = eta ** 2 * pm.gp.cov.Constant(1)

  model_marginal_gp = pm.gp.Marginal(mean_func = model_mean, cov_func = model_cov)

but that does not seem to be the most efficient. I will look into pm.gp.Latent suggested by @junpenglao

2 Likes

I think this is a good solution