Impute results in mismatch dimensions in dims and data

If it’s critical that you have wide data at estimation time, someone else will need to chime in.

There is, however, always a bijective mapping between long and wide data. So if it turns out impossible to get imputation working on wide data, you can go to long for estimation, then transform back to wide for inference.

Or you could work with multi-indices. For example, add a mutli-index to the idata, then use .sel to get the date-exercise combination you want. For example:

idata.posterior.coords.update({'mu_dim_0':load_long.set_index(['exercise', 'date', 'observation']).index})

exercise = 'Deadlift'
date = '2020-02-24'
load_mask = ((load_long.exercise == exercise) & (load_long.date == date)).values
az.plot_lm(y=load_long.loc[load_mask, 'load_std_masked'],
           x=velocity_long.loc[load_mask, 'velocity_std_masked'],
           y_model=idata.posterior.sel(exercise=exercise, date=date).mu)

image

1 Like