Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combinatorics navigation #7

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
844a135
commit for pr
hyunjimoon Jan 7, 2022
dbd92d5
Merge branch 'master' into combinatorics
Dashadower Jan 9, 2022
1ae4889
Find max hierarchy models for each subtree
Dashadower Jan 13, 2022
7cc22e8
Update n(signature)=1 case
Dashadower Jan 13, 2022
70233bd
Update highest model command and add apex search
Dashadower Jan 18, 2022
73a450d
Add chain search
Dashadower Jan 21, 2022
67fedf0
Update chain search
Dashadower Jan 21, 2022
80025a9
Update chain search code
Dashadower Jan 21, 2022
8733124
update search and add model df
Dashadower Jan 28, 2022
e80399d
Create model dataframe module and birthday model df
Dashadower Jan 30, 2022
d365077
update typing
Dashadower Jan 30, 2022
f65f1bc
Move files to directory, create mstan inferface and bayesian probabil…
Dashadower Jan 31, 2022
7b0577c
Update probability search and add score based algorithm
Dashadower Feb 4, 2022
883178b
Update bayesian probabilistic search to include plots
Dashadower Feb 5, 2022
3796258
remove pyc
Dashadower Feb 5, 2022
a76d53b
Upload full birthday DF
Dashadower Feb 13, 2022
ef62161
Remove redundant csv
Dashadower Feb 13, 2022
827e5af
full elpd for birthday
Dashadower Feb 13, 2022
9f514a4
Add roach model, score search, and notebook template
Dashadower Feb 15, 2022
64587d8
Upload roach csv
Dashadower Feb 16, 2022
3eacced
Update prob search
Dashadower Feb 18, 2022
876b4b4
Merge remote-tracking branch 'origin/master' into combinatorics
Dashadower Feb 18, 2022
72fdd62
Update notebook
Dashadower Feb 22, 2022
639adf9
Update chain algorithms and notebook
Dashadower Feb 22, 2022
a4f090d
Update notebook
Dashadower Feb 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
263 changes: 263 additions & 0 deletions examples/roach/roach.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
y,roach1,treatment,senior,exposure2
153,308,1,0,0.8
127,331.25,1,0,0.6
7,1.67,1,0,1
7,3,1,0,1
0,2,1,0,1.14285714285714
0,0,1,0,1
73,70,1,0,0.8
24,64.56,1,0,1.14285714285714
2,1,0,0,1
2,14,0,0,1.14285714285714
0,138.25,0,0,1
21,16,0,0,1
0,97,0,0,1
179,98,0,0,0.8
136,44,0,0,1
104,450,0,0,0.8
2,36.67,0,0,0.8
5,75,0,0,1
1,2,0,0,1
203,342.5,0,0,1
32,22.5,0,0,1
1,4,0,0,1
135,94,0,0,1
59,132.13,0,0,0.857142857142857
29,80,0,0,1
120,95,0,0,1
44,34.13,0,0,0.8
1,19,0,0,1
2,25,0,0,1
193,57.5,0,0,1
13,3.11,0,0,1
37,10.5,0,0,1
2,47,0,0,1
0,2.63,0,0,1
3,204,0,0,1
0,0,0,0,1
0,0,0,0,1
15,246.25,0,0,0.8
11,76.22,0,0,1.57142857142857
19,15,0,0,1.42857142857143
0,14.88,0,0,1
19,51,0,0,1
4,15,0,0,1
122,52.5,0,0,0.8
48,13.75,0,0,1
0,1.17,0,0,1
0,1,0,0,1
3,2,0,0,1
0,0,0,0,1
9,2,0,0,1
0,2,0,0,1.14285714285714
0,30,0,0,1.14285714285714
0,7,0,0,1
12,18,0,0,1
0,2,0,0,0.8
357,266,0,0,1
11,174,1,0,0.914285714285714
60,252,1,0,1
0,0.88,1,0,1.28571428571429
159,372.5,1,0,1
50,42,1,0,1
48,19,1,0,0.771428571428571
178,263,1,0,1
4,34,1,0,1.42857142857143
6,1.75,1,0,1
0,213.5,1,0,0.771428571428571
33,13.13,1,0,1
127,154,1,0,1
4,21,1,0,1
63,220,1,0,1
88,38.32,1,0,1
5,352.5,1,0,0.6
0,7,1,0,1
0,4,1,0,1
62,59.5,1,0,1
4,7.5,1,0,1
150,112.88,1,0,1.28571428571429
38,172,1,0,1
0,13,1,0,1
3,18,1,0,1
1,0,1,0,1
14,27,1,0,1
77,148,1,0,1
42,32,1,0,1.14285714285714
21,28,1,0,1
1,0,1,0,1
45,28,1,0,1
0,0,1,1,0.8
0,14,1,1,0.8
0,5,1,1,1
0,0,1,1,1
0,104,1,1,0.685714285714286
183,27,1,1,1
28,132,1,1,1
49,258,1,1,1
1,1,1,1,1
0,2,1,1,1
0,6,1,1,1
3,3,1,1,0.8
0,3,1,1,0.857142857142857
0,0,1,1,1
0,0,1,1,1
0,0,1,1,1
18,1.25,1,1,1
0,0,1,1,1
0,16,1,1,1
5,68,1,1,0.4
0,1,1,1,0.8
19,18,1,1,1.14285714285714
5,123.67,1,1,1
0,2,1,1,0.8
27,82.5,1,1,1
0,0,1,1,0.2
0,1.25,1,1,1
77,171,1,1,1
1,91.88,1,1,1
3,5,1,1,1
2,7,1,1,1
0,0,1,1,1
0,4,1,1,1
22,53.75,1,1,1
102,138.06,1,1,1.14285714285714
0,1,1,1,1.14285714285714
0,1.25,1,1,1
0,28,1,1,0.8
0,15,1,1,1
0,0.88,1,1,0.8
0,0,1,1,1
0,33,1,1,1
4,136.25,1,1,4.28571428571429
12,127.5,1,1,0.8
2,2,1,1,0.8
0,2,1,1,0.8
0,0,1,1,1
1,3,1,1,1
0,46,1,1,1.28571428571429
40,68,1,1,1
0,0,1,1,1
1,49,1,1,1
2,27.13,1,1,1
27,45.5,1,0,1
0,0,1,0,0.457142857142857
2,4,1,0,1
0,0,1,0,2.42857142857143
0,1,1,0,1.42857142857143
0,0,1,0,1
0,0,1,0,1
3,10.5,1,0,1.14285714285714
1,0,1,0,1
20,3,1,0,1.14285714285714
0,0,1,0,1
0,0,1,0,1
0,0,1,0,1
0,3.75,1,0,0.8
0,0,1,0,1.14285714285714
0,0,1,0,1
0,0,0,0,0.8
0,0.88,0,0,1.57142857142857
0,2,1,0,1
53,81,1,0,1.14285714285714
69,31,1,0,2.28571428571429
15,10,1,0,1
0,10.23,1,0,0.571428571428571
2,0,0,0,0.8
4,13,1,0,0.857142857142857
6,1,1,0,0.8
8,33.25,1,0,0.857142857142857
0,0,0,0,2.28571428571429
0,53,0,0,0.8
0,5,1,0,1
18,157,1,0,0.857142857142857
38,23.33,1,0,1
0,6,1,0,1.02857142857143
2,10,1,0,0.6
18,100,1,0,0.857142857142857
34,55,1,0,1
1,0,1,0,0.8
109,16.25,1,0,1
5,7.78,1,0,1.48571428571429
15,53,1,0,1
0,2,1,0,1
64,73,1,0,1
0,0,1,0,0.8
1,0,1,0,0.8
0,0,1,0,1
1,3.18,1,0,1
3,5,0,0,0.857142857142857
5,3,0,0,0.8
7,0,0,0,1
18,10,0,0,0.8
1,1,0,0,1
0,0,1,0,1
0,1,1,0,0.8
3,12,1,0,1
3,17,1,0,1
0,16,1,0,1
19,2.5,1,0,1.42857142857143
0,0,1,0,1.71428571428571
8,21.88,1,0,0.771428571428571
26,173,1,0,0.8
50,111,1,0,1
15,35,1,0,1.85714285714286
0,0,1,0,1
19,3,1,0,1
5,2.1,1,0,1
17,0,1,0,1
121,49,1,0,1
1,1.25,1,0,1
0,1,1,0,0.8
0,1,1,0,1
0,0,1,0,1
0,0,1,0,2.28571428571429
4,54,1,0,0.8
1,4.2,1,0,1.42857142857143
14,51.25,1,0,1.02857142857143
1,30,1,0,1.71428571428571
25,196,0,0,1.14285714285714
0,0,0,0,1.14285714285714
14,2,0,0,1
0,1.5,0,0,1
59,96.25,0,0,1.14285714285714
243,241.5,0,0,0.8
80,140,0,0,1.42857142857143
69,18,0,0,0.914285714285714
14,3,0,0,1.14285714285714
9,0.54,0,0,1.28571428571429
38,82,0,0,0.6
37,19,0,0,1
48,18.75,0,0,0.8
293,51,0,0,1.14285714285714
7,0,0,0,1
10,1,0,0,1.42857142857143
19,0,0,0,1
24,5.44,0,0,1
91,0,0,0,1
1,3,0,1,1
0,0,0,1,1
0,0,0,1,1
0,0,0,1,1
0,0,0,1,1
148,28.75,0,1,1.14285714285714
3,0,0,1,0.857142857142857
26,3,0,1,1
12,2,0,1,1
77,135,0,1,1
0,0,0,1,1
7,68.25,0,1,1
0,1,0,1,1
1,0,0,1,1
0,0,0,1,0.6
17,0,0,1,1.02857142857143
0,1,0,1,1
7,1,0,1,1
11,2.5,0,1,0.685714285714286
6,51.25,0,1,0.8
50,13.13,0,1,1
1,0,0,1,0.8
0,0,0,1,1.48571428571429
0,0,0,1,1
0,0,0,1,1
171,0,0,1,1
8,0,0,1,1
1 change: 1 addition & 0 deletions examples/roach/roach.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"y":[153,127,7,7,0,0,73,24,2,2,0,21,0,179,136,104,2,5,1,203,32,1,135,59,29,120,44,1,2,193,13,37,2,0,3,0,0,15,11,19,0,19,4,122,48,0,0,3,0,9,0,0,0,12,0,357,11,60,0,159,50,48,178,4,6,0,33,127,4,63,88,5,0,0,62,4,150,38,0,3,1,14,77,42,21,1,45,0,0,0,0,0,183,28,49,1,0,0,3,0,0,0,0,18,0,0,5,0,19,5,0,27,0,0,77,1,3,2,0,0,22,102,0,0,0,0,0,0,0,4,12,2,0,0,1,0,40,0,1,2,27,0,2,0,0,0,0,3,1,20,0,0,0,0,0,0,0,0,0,53,69,15,0,2,4,6,8,0,0,0,18,38,0,2,18,34,1,109,5,15,0,64,0,1,0,1,3,5,7,18,1,0,0,3,3,0,19,0,8,26,50,15,0,19,5,17,121,1,0,0,0,0,4,1,14,1,25,0,14,0,59,243,80,69,14,9,38,37,48,293,7,10,19,24,91,1,0,0,0,0,148,3,26,12,77,0,7,0,1,0,17,0,7,11,6,50,1,0,0,0,171,8],"roach1":[308,331.25,1.67,3,2,0,70,64.56,1,14,138.25,16,97,98,44,450,36.67,75,2,342.5,22.5,4,94,132.13,80,95,34.13,19,25,57.5,3.11,10.5,47,2.63,204,0,0,246.25,76.22,15,14.88,51,15,52.5,13.75,1.17,1,2,0,2,2,30,7,18,2,266,174,252,0.88,372.5,42,19,263,34,1.75,213.5,13.13,154,21,220,38.32,352.5,7,4,59.5,7.5,112.88,172,13,18,0,27,148,32,28,0,28,0,14,5,0,104,27,132,258,1,2,6,3,3,0,0,0,1.25,0,16,68,1,18,123.67,2,82.5,0,1.25,171,91.88,5,7,0,4,53.75,138.06,1,1.25,28,15,0.88,0,33,136.25,127.5,2,2,0,3,46,68,0,49,27.13,45.5,0,4,0,1,0,0,10.5,0,3,0,0,0,3.75,0,0,0,0.88,2,81,31,10,10.23,0,13,1,33.25,0,53,5,157,23.33,6,10,100,55,0,16.25,7.78,53,2,73,0,0,0,3.18,5,3,0,10,1,0,1,12,17,16,2.5,0,21.88,173,111,35,0,3,2.1,0,49,1.25,1,1,0,0,54,4.2,51.25,30,196,0,2,1.5,96.25,241.5,140,18,3,0.54,82,19,18.75,51,0,1,0,5.44,0,3,0,0,0,0,28.75,0,3,2,135,0,68.25,1,0,0,0,1,1,2.5,51.25,13.13,0,0,0,0,0,0],"treatment":[1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"senior":[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857,0.8,1,0.8571,1,1.0286,0.6,0.8571,1,0.8,1,1.4857,1,1,1,0.8,0.8,1,1,0.8571,0.8,1,0.8,1,1,0.8,1,1,1,1.4286,1.7143,0.7714,0.8,1,1.8571,1,1,1,1,1,1,0.8,1,1,2.2857,0.8,1.4286,1.0286,1.7143,1.1429,1.1429,1,1,1.1429,0.8,1.4286,0.9143,1.1429,1.2857,0.6,1,0.8,1.1429,1,1.4286,1,1,1,1,1,1,1,1,1.1429,0.8571,1,1,1,1,1,1,1,0.6,1.0286,1,1,0.6857,0.8,1,0.8,1.4857,1,1,1,1],"N":[262]}
120 changes: 120 additions & 0 deletions examples/roach/roach.m.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
data {
# y roach1 treatment senior exposure2
int N;
int y[N];
real roach1[N];
int treatment[N];
int senior[N];
real exposure2[N];
}

transformed data {
vector[N] roach1_vec = to_vector(roach1);
#roach1_vec = roach1_vec ./ 100
vector[N] treatment_vec = to_vector(treatment);
vector[N] senior_vec = to_vector(senior);
vector[N] exposure2_vec = to_vector(exposure2);
}

model {
y ~ Regression();
}

module "glm" Regression() {
transformed parameters {
vector[N] offset = OffsetType();
vector[N] mu = Roach() + Treatment() + Senior();
}
Likelihood();
}

module "Poisson" Likelihood() {
generated quantities {
vector[N] log_lik;
for (n in 1:N) log_lik[n] = poisson_lpmf(y[n] | exp(mu + RandomEffects() + offset));
}
y ~ poisson(exp(mu + RandomEffects() + offset));
}

module "NegBinomial" Likelihood() {
parameters {
real<lower=0> phi;
}
generated quantities {
vector[N] log_lik;
for (n in 1:N) log_lik[n] = neg_binomial_2_log_lpmf(y[n] | mu + offset, phi);

}
PhiPrior();
y ~ neg_binomial_2_log(exp(mu + offset), phi);
}

module "normal" PhiPrior() {
phi ~ normal(0, 3);
}

module "cauchy" PhiPrior() {
phi ~ cauchy(0, 3);
}

module "log" OffsetType() {
return log(exposure2_vec);
}

module "identity" OffsetType() {
return exposure2_vec;
}

module "sqrt" Roach() {
parameters {
real roach_coeff;
}
return roach_coeff * sqrt(roach1_vec);
}

module "identity" Roach() {
parameters {
real roach_coeff;
}
return roach_coeff * roach1_vec;
}

module "no" Roach() {
return rep_vector(0, N);
}

module "yes" Treatment() {
parameters {
real treatment_coeff;
}
return treatment_coeff * treatment_vec;
}

module "no" Treatment() {
return rep_vector(0, N);
}

module "yes" Senior() {
parameters {
real senior_coeff;
}
return senior_coeff * senior_vec;
}

module "no" Senior() {
return rep_vector(0, N);
}

module "yes" RandomEffects() {
parameters {
vector[N] random_effect;
}
model {
random_effect ~ normal(0, 5);
}
return random_effect;
}

module "no" RandomEffects() {
return rep_vector(0, N) ;
}
Loading