How Probable is a Set?

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

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)   [1]
logit(Pm)   = aM + aE.E + aP.Pa + aPE.Pa.E  [2]

Priors

aM  = Normal (0,sM) [3]
aE  = Normal (0,sE) [4]
aP  = Normal (0,sP) [5]
aPE = Normal (0,sPE)    [6]

sM  = Half Cauchy (0,1) [7]
sE  = Half Cauchy (0,1) [8]
sP  = Half Cauchy (0,1) [9]
sPE = Half Cauchy (0,1) [10]

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?



Related Questions


Categorical observed, Binomial latent

Updated August 01, 2017 14:19 PM