What does mean when i get an error while computing log_prob?


I’m running a multivariate regression model and keep getting the following error:

ValueError: Error while computing log_prob at site 'obs':
The value argument must be within the support
     Trace Shapes:              
      Param Sites:              
     Sample Sites:              
        sigma dist        |     
             value        |     
          log_prob        |     
linear.weight dist        | 1 82
             value        | 1 82
          log_prob        |     
  linear.bias dist        | 1   
             value        | 1   
          log_prob        |     
          obs dist 657878 |     
             value 657878 |     

I’m copy/pasted from the tutorial, only changing the y variable to Poisson distributed. I’m not sure what the above means.

I can’t say what the source of the error is without seeing your code, but the error message The value argument must be within the support is saying that the observed value at site obs is not compatible with the distribution at the site, perhaps because the observations are real-valued and the Poisson distribution you’ve used at the site expects nonnegative integer values.

Have you checked that the Poisson distribution is a valid likelihood for your data?

class BayesianRegression(PyroModule):
    def __init__(self, in_features, out_features):
        self.linear = PyroModule[nn.Linear](in_features, out_features)
        self.linear.weight = PyroSample(dist.Normal(0., 1.).expand([out_features, in_features]).to_event(2))
        self.linear.bias = PyroSample(dist.Normal(0., 10.).expand([out_features]).to_event(1))

    def forward(self, x, y=None):
        sigma = pyro.sample("sigma", dist.Uniform(0., 10.))
        mean = self.linear(x).squeeze(-1)
        with pyro.plate("data", x.shape[0]):
            rate = self.linear(x).squeeze(-1).exp()
            obs = pyro.sample("obs", dist.Poisson(rate), obs=y)
        return mean

Ok that makes sense. I’m trying to apply a bayesian framework to an insurance problem. In the insurance industry, claims frequency is Poisson distributed but the frequency is calculated as #claims/risk (risk = amount ratio of time the policy has been on the books).

So it’s a real number, not an integer. hmmm…i’ll have to think about this. Claims frequency is definitely zero-inflated and takes the shape of a poisson distribution. I’m not sure what else to attribute it to.