0

I am new to bayesian modelling and I've been playing around with pyro and have managed to create univariate models that correctly infer from data. However, when creating a very simple multivariate model to create a posterior that better fits my data (stock returns time series) the inference fails.

This is the code I have used.

df = pd.read_csv(path_to_data_folder())
df = df.apply(pd.to_numeric)
ex = torch.from_numpy(df.values)

def model(data):
    loc = torch.mean(data, dim=0)
    cov = torch.cov(torch.transpose(data,0,1))
    obs_dist = dist.MultivariateNormal(loc=loc, covariance_matrix=cov)
    obs = pyro.sample("obs", obs_dist, obs=data)

# Set up the NUTS sampler
nuts_kernel = NUTS(model)

# Set up the MCMC inference algorithm
mcmc = MCMC(nuts_kernel, num_samples=1000, warmup_steps=200)

# Run inference
mcmc.run(ex)

# Get the posterior samples
posterior_samples = mcmc.get_samples()

The MCMC inference is run in just over a second with a probability of 1.00 and the samples dictionary I get through get_samples() is empty.

I have tried running it with synthetic data and also including the means and covariance matrix in the model with their own priors, but none of that makes the MCMC inference run differently. What could be the problem? Thanks in advance!

fcelya
  • 1
  • 1

0 Answers0