Clinical Trial data - request help on variable number of comparisons per trial

I think I will explore expanding the “na” column with the following code:

na=pd.DataFrame(np.array([[i,j-1,k+1] for i,j in enumerate(data[‘na’]) for k in np.arange(j-1)]))

In this case it extends the na’s from 36 to 37 rows. I hope that I can then feed it to the scan function as a sequence, along with other non sequenced variables to build the structures with variables in the right positions that I need.

I’m not sure how to code it or what the unknow unknows are going to be.

I want to develop along the lines of the code below:

import pytensor 
import pytensor.tensor as pt

na=pd.DataFrame(np.array([[i,j-1,k+1] for i,j in enumerate(data['na']) for k in np.arange(j-1)]))

with pm.Model() as model:
    #study_arms=pm.Deterministic("study_arms",na)
    study_arms=pm.MutableData('study_arms',na)
    
    def pairs(a):
        b=a[:2]
        return b

    outputs,_=pytensor.scan(fn=pairs,sequences=study_arms)
    foo=pm.Deterministic("foo",outputs)

    pm.model_to_graphviz(model)