I’m working on extending the following regression model to include an additional variable that is unknown. It is the mean of unknown scores of a given observation’s relationships. In other words, y = intercept + b_x1 *x1 + b_x2 * x2 + b_x3 * x3 + b_x4 * x4, where x4 is the mean(subset of unknown values).
# Pyro model (linear regression)
def model(x1, x2, x3, y=None):
"""
"""
# Coefficients
intercept = pyro.sample("intercept", dist.Normal(0., 1.0))
b_x1 = pyro.sample("b_x1", dist.Normal(0., 1.0))
b_x2 = pyro.sample("b_x2", dist.Normal(0., 1.0))
b_x3 = pyro.sample("b_x3", dist.Normal(0., 1.0))
sigma = pyro.sample("sigma", dist.Uniform(0., 1.0))
mean = \
intercept +\
b_x1 * x1 +\
b_x2 * x2 +\
b_x3 * x3
with pyro.plate("data", len(x1)):
return pyro.sample("y", dist.Normal(mean, sigma), obs=y)
It’s not correctly coded, but I’d like to add something like the following in order to estimate the values for another variable, x4:
# Unknown variable for each person to be estimated.
latent_scores = [pyro.sample("latent_score_{i}", dist.Normal(0., 1.0)) for i in range(x1)]
# For each person, calculate the unknown x4 value, where x4[i] is the mean
# of unknown values of a given person's connections (i.e. network edges).
x4[i] = (latent_scores[0] + latent_scores[1]) / 2
Basically, I’m wanting to estimate the unknown values for each person as well as the model coefficients at the same time. I’m new to Pyro, so if there is a more appropriate modeling approach, please let me know!