Hello,
We are trying to estimate the influence of an ordinal predictor and a continuous predictor on our observations.
We have found and could use the brm monotonic model presented here which works well for our case:
mu = np.mean( observations )
sd = np.std( observations )
ncat = len( np.unique(ordinal_predictor) )
df = ncat -1
con_simo = np.ones( df )
Xmo = np.zeros((len(ordinal_predictor), ncat), int)
for ic, i in enumerate(categories):
if i > 0:
Xmo[ic, :i+1] = np.arange(i+1)
a = theano.shared(np.zeros(1,))
with pm.Model() as brm_model:
temp_Intercept = pm.StudentT('intercept', mu=mu, sd=sd, nu=df)
beta = pm.Normal('beta', mu=0., sd=100.)
simo_t = pm.Dirichlet('simo', a=con_simo)
simo = T.concatenate([a, simo_t])
sigma = pm.HalfStudentT('sigma', sd=sd, nu=df)
p = temp_Intercept + beta * T.sum(simo[Xmo], axis=1)
obs = pm.Lognormal('obs', mu=p, sd=sigma, observed=observations)
trace = pm.sample(draws=3000, tune=3000, chains=2)
We were wondering if you would have advices or pointers that you could give us on how to best integrate the 2nd continuous predictor to this model?
Thank you