Here’s an answer for dealing with partial observation of `speed`

with no categorical variables. This is the simplest case that leads to a nontrivial model; with fully observed data, you’re just going to have three separate linear regressions and there are numerous tutorials for that. There are a few moving parts here so feel free to ask any follow up questions.

```
import numpy as np
import pandas as pd
import pymc3 as pm
# Make some fake data
columns = ['hrmax','age','bmi','hrrest','speed','recovery']
n = 20
p = len(columns)
df = pd.DataFrame(data=np.random.randn(n,p), columns=columns)
# Make three of the rows missing for the speed variable
df['speed'].iloc[[0,10,15]] = np.nan
with pm.Model():
# Place weak priors on the intercepts and
# error variance
intercepts = pm.Normal('intercepts', sd=100, shape=3)
error_stds = pm.HalfNormal('error_stds', sd=10, shape=3)
# Since the # of coefficients is different for speed, we
# can't just use one 2D array
coefficients_hrmax = pm.Normal('coefficients_hrmax', sd=10, shape=3)
coefficients_speed = pm.Normal('coefficients_speed', sd=10, shape=2)
coefficients_recovery = pm.Normal('coefficients_recovery', sd=10, shape=3)
mu_hrmax = intercepts[0] + pm.math.dot(df[['age','bmi','hrrest']],coefficients_hrmax)
hrmax = pm.Normal('hrmax', mu=mu_hrmax, sd=error_stds[0],observed=df['hrmax'])
# Using observed=speed where some of the values of speed are NaN
# in the Pandas Series tells PyMC3 to impute them using the rest of
# the probability model to sample them from the posterior.
mu_speed = intercepts[1] + pm.math.dot(df[['age','hrmax']],coefficients_speed)
speed = pm.Normal('speed', mu=mu_speed, sd=error_stds[1],observed=df['speed'])
# Even though the speed values are missing for some rows, their imputed
# values are fed forward into the regression for recovery.
mu_recovery = intercepts[2] + pm.math.dot(df[['hrrest','hrmax']],coefficients_recovery[0:2]) + speed*coefficients_recovery[2]
recovery = pm.Normal('recovery', mu=mu_recovery, sd=error_stds[2],observed=df['recovery'])
trace = pm.sample()
```