I have the following issue: In the past I explicitly fitted logistic functions to some psychometric data. However, I now want to give the GLM module a try, mainly because it so nice an compact to use. In general it works as expected. However, my experimental data has two (or more) conditions for which I would like to fit individual slopes and intercepts. With the explicit logistic model I used an condition index vector and parameters of the desired shape. But I can’t figure out how to do something like this with the GLM module. I can split the data and add two GLM formulae (adding prefixes to the autogerated parameter names), but this gives me trouble when I later want to produce a single WAIC or loo score for the fit.
Thanks for the suggestion. It seems to be as you remember. I didn’t know how/where to look at the design matrix. But what you say matches exactly to the values I get by setting up two separate GLMs for the conditions.
Adding these deterministic vars got me the parameters I wanted:
a = pm.Deterministic('a', tt.stack((model['Intercept'],
model['Intercept']+model['Condition'])))
b = pm.Deterministic('b', tt.stack((model['X'],
model['X']+model['X:Condition'])))
With Condition being 0 or 1 and X the different levels …
a[0], a[1] are then the intercepts and b[0], b[1] the slopes for each condition.
Since the GLM module sets up everything, we don’t have direct references to the variables as we would if we manually set up the model. But it turns out they can be easily obtained by keying the model object (model in my example above) with the (auto-generated) parameter names. Didn’t know that … very convenient …