How Probable is a Set?

by R. Cox   Last Updated September 20, 2018 14:19 PM - source

I have some data on the contents of various types of box. I would like to find out how typical the contents of each box are for that type of box.

``````# Data
df_1 = pd.DataFrame({'Box' : [1006,1006,1006,1006,1006,1006,1007,1007,1007,1007,1008,1008,1008,1009,1009,1010,1011,1011,1012,1013],
'Item': [  40,  41,  42,  43,  44,  45,  40,  43,  44,  45,  43,  44,  45,  40,  41,  40,  44,  45,  44,  45]})

df_2 = pd.DataFrame({'Box' : [1006,1007,1008,1009,1010,1011,1012,1013],
'Type': [ 101, 101, 102, 102, 102, 103, 103, 103]})
``````

I've an idea of how to do this but I would be open to any suggestions of other approaches! Am I barking up the wrong tree with the following idea for a model? Is it over complicated?

Proposed Model 1

The model is an attempt at a binomial regression predicting what Items are likely to be found in each type of Box. This works simultaneously with varying intercept & slope regressions predicting what Items are found in each type of Box by Item & by Type as well as the correlation between Item & by Type.

``````N   = Binomial (n,Pm)   
logit(Pm)   = aM + aE.E + aP.Pa + aPE.Pa.E  
``````

Priors

``````aM  = Normal (0,sM) 
aE  = Normal (0,sE) 
aP  = Normal (0,sP) 
aPE = Normal (0,sPE)    

sM  = Half Cauchy (0,1) 
sE  = Half Cauchy (0,1) 
sP  = Half Cauchy (0,1) 
sPE = Half Cauchy (0,1) 
``````

Variables

``````Pm  Probability that the Items in a Box are typical
Pa  Item
E   Box
n   Number of Boxes
N   Number of typical Boxes

aM  Distribution of mean intercept
aE  Distribution of mean slope by Box
aP  Distribution of mean slope by Item
aPE Distribution of mean slope of correlation of Item & with Box

sM  Distribution of standard deviation of the intercept
sE  Distribution of standard deviation slope by Box
sP  Distribution of standard deviation slope by Item
sPE Distribution of standard deviation slope of correlation of Item & with Box
``````

& what should I read to learn how to implement it in Python please?

Tags :