diff --git a/posterior_database/models/info/GLMM1_model.info.json b/posterior_database/models/info/GLMM1_model.info.json index c6f1b834..41c46c14 100644 --- a/posterior_database/models/info/GLMM1_model.info.json +++ b/posterior_database/models/info/GLMM1_model.info.json @@ -1,6 +1,10 @@ { "name": "GLMM1_model", - "keywords": ["BPA", "Ch.4", "GLMM1_model"], + "keywords": [ + "BPA", + "Ch.4", + "GLMM1_model" + ], "title": "Generalized Linear Mixed Model for Peregrine Population Size", "description": "A GLMM for modeling peregrine population size with a random effect being the site of observation.", "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.04", @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/GLMM1_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/GLMM1_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/GLMM_Poisson_model.info.json b/posterior_database/models/info/GLMM_Poisson_model.info.json index c291b589..6aaad76c 100644 --- a/posterior_database/models/info/GLMM_Poisson_model.info.json +++ b/posterior_database/models/info/GLMM_Poisson_model.info.json @@ -1,6 +1,10 @@ { "name": "GLMM_Poisson_model", - "keywords": ["BPA", "Ch.4", "GLMM_Poisson_model"], + "keywords": [ + "BPA", + "Ch.4", + "GLMM_Poisson_model" + ], "title": "Mixed Model to Predict Population Size with Random Site and Year Effects", "description": "A GLMM for modeling peregrine population size with a random effect being the site and year of observation using the Poisson distribution to model counts.", "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.04", @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/GLMM_Poisson_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/GLMM_Poisson_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/GLM_Poisson_model.info.json b/posterior_database/models/info/GLM_Poisson_model.info.json index 98e768a3..9a0c04fd 100644 --- a/posterior_database/models/info/GLM_Poisson_model.info.json +++ b/posterior_database/models/info/GLM_Poisson_model.info.json @@ -1,6 +1,12 @@ { "name": "GLM_Poisson_model", - "keywords": ["Population", "Peregrine", "Generalized", "Generalised", "Linear Model"], + "keywords": [ + "Population", + "Peregrine", + "Generalized", + "Generalised", + "Linear Model" + ], "title": "Poisson GLM for modeling a population of Peregrines", "description": "Poisson Generalised Linear Model where the linear predictor is a cubic polynomial function of time.", "urls": "https://github.com/stan-dev/example-models/tree/master/BPA/Ch.03", @@ -11,6 +17,9 @@ "stan": { "model_code": "models/stan/GLM_Poisson_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/GLM_Poisson_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/Rate_2_model.info.json b/posterior_database/models/info/Rate_2_model.info.json index c99f515e..d35045b9 100644 --- a/posterior_database/models/info/Rate_2_model.info.json +++ b/posterior_database/models/info/Rate_2_model.info.json @@ -1,6 +1,11 @@ { "name": "Rate_2_model", - "keywords": ["Trial", "Success Rate", "Beta Distribution", "Difference"], + "keywords": [ + "Trial", + "Success Rate", + "Beta Distribution", + "Difference" + ], "title": "Difference in success rates", "description": "Predicting the difference between the success rates of two trials", "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial", @@ -11,6 +16,9 @@ "stan": { "model_code": "models/stan/Rate_2_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/Rate_2_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/Rate_4_model.info.json b/posterior_database/models/info/Rate_4_model.info.json index 5a6195d0..acaabf1c 100644 --- a/posterior_database/models/info/Rate_4_model.info.json +++ b/posterior_database/models/info/Rate_4_model.info.json @@ -1,6 +1,12 @@ { "name": "Rate_4_model", - "keywords": ["Trial", "Success Rate", "Inference", "Prior Inference", "Posterior Inference"], + "keywords": [ + "Trial", + "Success Rate", + "Inference", + "Prior Inference", + "Posterior Inference" + ], "title": "Success rate of a trial with prior and posterior inference", "description": "Inference of the success rate of a trial with prior and posterior inference", "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial", @@ -11,6 +17,9 @@ "stan": { "model_code": "models/stan/Rate_4_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/Rate_4_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/Rate_5_model.info.json b/posterior_database/models/info/Rate_5_model.info.json index 4776b7b1..13cf8314 100644 --- a/posterior_database/models/info/Rate_5_model.info.json +++ b/posterior_database/models/info/Rate_5_model.info.json @@ -1,6 +1,11 @@ { "name": "Rate_5_model", - "keywords": ["Trial", "Correct Answer Rate", "Beta Distribution", "Common Rate"], + "keywords": [ + "Trial", + "Correct Answer Rate", + "Beta Distribution", + "Common Rate" + ], "title": "Common Rate of Success From Two Trials with Posterior Predictives", "description": "Inference of a common rate of success from two trials with posterior predictive for each trial for checking the adequacy of the model.", "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial", @@ -11,6 +16,9 @@ "stan": { "model_code": "models/stan/Rate_5_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/Rate_5_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/accel_splines.info.json b/posterior_database/models/info/accel_splines.info.json index 20898b51..5ddf6d52 100644 --- a/posterior_database/models/info/accel_splines.info.json +++ b/posterior_database/models/info/accel_splines.info.json @@ -1,6 +1,9 @@ { "name": "accel_splines", - "keywords": ["stan_benchmark", "spline"], + "keywords": [ + "stan_benchmark", + "spline" + ], "title": "Splines for time-series data with varying mean and std", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +14,9 @@ "stan": { "model_code": "models/stan/accel_splines.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/accel_splines.py" } }, "references": "bales2019selecting", diff --git a/posterior_database/models/info/arK.info.json b/posterior_database/models/info/arK.info.json index c809b1a5..f84e37ee 100644 --- a/posterior_database/models/info/arK.info.json +++ b/posterior_database/models/info/arK.info.json @@ -2,7 +2,10 @@ "name": "arK", "title": "Autoregressive-5 model", "description": "An AR(5) time series model.", - "keywords": ["time series", "stan_benchmark"], + "keywords": [ + "time series", + "stan_benchmark" + ], "urls": "https://github.com/stan-dev/stat_comp_benchmarks/tree/master/benchmarks/arK", "prior": { "keywords": [] @@ -11,6 +14,9 @@ "stan": { "model_code": "models/stan/arK.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/arK.py" } }, "added_by": "Mans Magnusson", diff --git a/posterior_database/models/info/blr.info.json b/posterior_database/models/info/blr.info.json index f7bac5ce..2f0b4589 100644 --- a/posterior_database/models/info/blr.info.json +++ b/posterior_database/models/info/blr.info.json @@ -12,6 +12,9 @@ "stan": { "model_code": "models/stan/blr.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/blr.py" } }, "added_by": "Mans Magnusson", diff --git a/posterior_database/models/info/diamonds.info.json b/posterior_database/models/info/diamonds.info.json index 73d3b0ac..cf85961f 100644 --- a/posterior_database/models/info/diamonds.info.json +++ b/posterior_database/models/info/diamonds.info.json @@ -1,6 +1,9 @@ { "name": "diamonds", - "keywords": ["stan_benchmark", "linear regression"], + "keywords": [ + "stan_benchmark", + "linear regression" + ], "title": "Multiple Highly Correlated Predictors Log-Log Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +14,9 @@ "stan": { "model_code": "models/stan/diamonds.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/diamonds.py" } }, "references": "bales2019selecting", diff --git a/posterior_database/models/info/dogs.info.json b/posterior_database/models/info/dogs.info.json index ae431389..4a4c114e 100644 --- a/posterior_database/models/info/dogs.info.json +++ b/posterior_database/models/info/dogs.info.json @@ -1,6 +1,10 @@ { "name": "dogs", - "keywords": ["ARM", "Ch. 24", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 24", + "stan_examples" + ], "title": "Logistic Mixed Effects Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/dogs.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/dogs.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/dogs_hierarchical.info.json b/posterior_database/models/info/dogs_hierarchical.info.json index 212b3f59..e91da4b0 100644 --- a/posterior_database/models/info/dogs_hierarchical.info.json +++ b/posterior_database/models/info/dogs_hierarchical.info.json @@ -1,6 +1,9 @@ { "name": "dogs_hierarchical", - "keywords": ["ARM", "Ch. 24"], + "keywords": [ + "ARM", + "Ch. 24" + ], "title": "Hierarchical Logistic Mixed Effects Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -14,6 +17,9 @@ "stan": { "model_code": "models/stan/dogs_hierarchical.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/dogs_hierarchical.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/dugongs_model.info.json b/posterior_database/models/info/dugongs_model.info.json index d5d9d277..9973ba3b 100644 --- a/posterior_database/models/info/dugongs_model.info.json +++ b/posterior_database/models/info/dugongs_model.info.json @@ -1,6 +1,10 @@ { "name": "dugongs_model", - "keywords": ["nonlinear", "non-linear", "growth curve"], + "keywords": [ + "nonlinear", + "non-linear", + "growth curve" + ], "title": "Dugong Age and Length", "description": "Model of age and length data of dugongs using a nonlinear growth curve with no inflection point.", "urls": "https://github.com/stan-dev/example-models/tree/master/bugs_examples/vol2", @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/dugongs_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/dugongs_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/earn_height.info.json b/posterior_database/models/info/earn_height.info.json index 09710205..ede0e6af 100644 --- a/posterior_database/models/info/earn_height.info.json +++ b/posterior_database/models/info/earn_height.info.json @@ -1,6 +1,10 @@ { "name": "earn_height", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "One Predictor Linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/earn_height.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/earn_height.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/eight_schools_centered.info.json b/posterior_database/models/info/eight_schools_centered.info.json index b525e613..a7551442 100644 --- a/posterior_database/models/info/eight_schools_centered.info.json +++ b/posterior_database/models/info/eight_schools_centered.info.json @@ -2,8 +2,14 @@ "name": "eight_schools_centered", "title": "A centered hiearchical model for 8 schools", "description": "A centered hiearchical model for the 8 schools example of Rubin (1981)", - "keywords": ["bda3_example", "hiearchical"], - "references": ["rubin1981estimation", "gelman2013bayesian"], + "keywords": [ + "bda3_example", + "hiearchical" + ], + "references": [ + "rubin1981estimation", + "gelman2013bayesian" + ], "urls": "http://www.stat.columbia.edu/~gelman/arm/examples/schools", "prior": { "keywords": [] @@ -12,6 +18,9 @@ "stan": { "model_code": "models/stan/eight_schools_centered.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/eight_schools_centered.py" } }, "added_by": "Mans Magnusson", diff --git a/posterior_database/models/info/election88_full.info.json b/posterior_database/models/info/election88_full.info.json index 0b2f2c12..88732cc0 100644 --- a/posterior_database/models/info/election88_full.info.json +++ b/posterior_database/models/info/election88_full.info.json @@ -1,6 +1,10 @@ { "name": "election88_full", - "keywords": ["ARM", "Ch. 14", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 14", + "stan_examples" + ], "title": "Generalized Linear Mixed Effects Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/election88_full.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/election88_full.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/gp_pois_regr.info.json b/posterior_database/models/info/gp_pois_regr.info.json index 7f2f2096..0279c558 100644 --- a/posterior_database/models/info/gp_pois_regr.info.json +++ b/posterior_database/models/info/gp_pois_regr.info.json @@ -2,7 +2,10 @@ "name": "gp_pois_regr", "title": "Gaussian Process Poisson Regression", "description": "Poisson regression with a one-dimensional latent Gaussian process \nusing the exponential quadratic covariance function.", - "keywords": ["stan_benchmark", "gaussian process"], + "keywords": [ + "stan_benchmark", + "gaussian process" + ], "references": null, "urls": "https://github.com/stan-dev/stat_comp_benchmarks/tree/master/benchmarks/gp_pois_regr", "prior": { @@ -12,6 +15,9 @@ "stan": { "model_code": "models/stan/gp_pois_regr.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/gp_pois_regr.py" } }, "added_by": "Mans Magnusson", diff --git a/posterior_database/models/info/gp_regr.info.json b/posterior_database/models/info/gp_regr.info.json index 77fd8ab5..30fcf212 100644 --- a/posterior_database/models/info/gp_regr.info.json +++ b/posterior_database/models/info/gp_regr.info.json @@ -2,7 +2,10 @@ "name": "gp_regr", "title": "Gaussian Process regression", "description": "One-dimensional Gaussian process Regression using the\nexponential quadratic covariance function.", - "keywords": ["stan_benchmark", "gaussian process"], + "keywords": [ + "stan_benchmark", + "gaussian process" + ], "references": null, "urls": "https://github.com/stan-dev/stat_comp_benchmarks/tree/master/benchmarks/gp_regr", "prior": { @@ -12,6 +15,9 @@ "stan": { "model_code": "models/stan/gp_regr.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/gp_regr.py" } }, "added_by": "Mans Magnusson", diff --git a/posterior_database/models/info/irt_2pl.info.json b/posterior_database/models/info/irt_2pl.info.json index 79a29dab..eed91bbe 100644 --- a/posterior_database/models/info/irt_2pl.info.json +++ b/posterior_database/models/info/irt_2pl.info.json @@ -2,7 +2,10 @@ "name": "irt_2pl", "title": "Two Parameter Logistic Item Response Theory Model", "description": "Hierarchical item response theory model.", - "keywords": ["stan_benchmark", "hiearchical"], + "keywords": [ + "stan_benchmark", + "hiearchical" + ], "references": null, "urls": "https://github.com/stan-dev/stat_comp_benchmarks/tree/master/benchmarks/irt_2pl", "prior": { @@ -12,6 +15,9 @@ "stan": { "model_code": "models/stan/irt_2pl.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/irt_2pl.py" } }, "added_by": "Mans Magnusson", diff --git a/posterior_database/models/info/kidscore_interaction.info.json b/posterior_database/models/info/kidscore_interaction.info.json index d5370cf6..cc07216f 100644 --- a/posterior_database/models/info/kidscore_interaction.info.json +++ b/posterior_database/models/info/kidscore_interaction.info.json @@ -1,6 +1,10 @@ { "name": "kidscore_interaction", - "keywords": ["ARM", "Ch. 3", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 3", + "stan_examples" + ], "title": "Interacting Linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/kidscore_interaction.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/kidscore_interaction.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/kidscore_interaction_c.info.json b/posterior_database/models/info/kidscore_interaction_c.info.json index 3bce50bc..82ad3fcd 100644 --- a/posterior_database/models/info/kidscore_interaction_c.info.json +++ b/posterior_database/models/info/kidscore_interaction_c.info.json @@ -1,6 +1,10 @@ { "name": "kidscore_interaction_c", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "Multiple Interacting Predictors Centered Linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/kidscore_interaction_c.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/kidscore_interaction_c.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/kidscore_interaction_c2.info.json b/posterior_database/models/info/kidscore_interaction_c2.info.json index d636d6d3..7bf74faa 100644 --- a/posterior_database/models/info/kidscore_interaction_c2.info.json +++ b/posterior_database/models/info/kidscore_interaction_c2.info.json @@ -1,6 +1,10 @@ { "name": "kidscore_interaction_c2", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "Multiple Interacting Predictors Conventionally Centered Linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/kidscore_interaction_c2.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/kidscore_interaction_c2.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/kidscore_interaction_z.info.json b/posterior_database/models/info/kidscore_interaction_z.info.json index e5f0b595..b841d4f7 100644 --- a/posterior_database/models/info/kidscore_interaction_z.info.json +++ b/posterior_database/models/info/kidscore_interaction_z.info.json @@ -1,6 +1,10 @@ { "name": "kidscore_interaction_z", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "Multiple Interacting Predictors Standardized Linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/kidscore_interaction_z.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/kidscore_interaction_z.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/kidscore_mom_work.info.json b/posterior_database/models/info/kidscore_mom_work.info.json index f28f8d7d..e1ce2f6f 100644 --- a/posterior_database/models/info/kidscore_mom_work.info.json +++ b/posterior_database/models/info/kidscore_mom_work.info.json @@ -1,6 +1,10 @@ { "name": "kidscore_mom_work", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "Multiple Factor Level Predictors Linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/kidscore_mom_work.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/kidscore_mom_work.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/kidscore_momhs.info.json b/posterior_database/models/info/kidscore_momhs.info.json index e6420289..c339e04a 100644 --- a/posterior_database/models/info/kidscore_momhs.info.json +++ b/posterior_database/models/info/kidscore_momhs.info.json @@ -1,6 +1,10 @@ { "name": "kidscore_momhs", - "keywords": ["ARM", "Ch. 3", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 3", + "stan_examples" + ], "title": "One Predictor Linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/kidscore_momhs.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/kidscore_momhs.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/kidscore_momhsiq.info.json b/posterior_database/models/info/kidscore_momhsiq.info.json index 696cfa2b..24daa440 100644 --- a/posterior_database/models/info/kidscore_momhsiq.info.json +++ b/posterior_database/models/info/kidscore_momhsiq.info.json @@ -1,6 +1,10 @@ { "name": "kidscore_momhsiq", - "keywords": ["ARM", "Ch. 3", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 3", + "stan_examples" + ], "title": "Multiple Predictors Linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/kidscore_momhsiq.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/kidscore_momhsiq.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/kidscore_momiq.info.json b/posterior_database/models/info/kidscore_momiq.info.json index 2288c032..49f81a59 100644 --- a/posterior_database/models/info/kidscore_momiq.info.json +++ b/posterior_database/models/info/kidscore_momiq.info.json @@ -1,6 +1,10 @@ { "name": "kidscore_momiq", - "keywords": ["ARM", "Ch. 3", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 3", + "stan_examples" + ], "title": "One Predictor Linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/kidscore_momiq.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/kidscore_momiq.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/kilpisjarvi.info.json b/posterior_database/models/info/kilpisjarvi.info.json index f660cdd6..53c2df7a 100644 --- a/posterior_database/models/info/kilpisjarvi.info.json +++ b/posterior_database/models/info/kilpisjarvi.info.json @@ -1,6 +1,9 @@ { "name": "kilpisjarvi", - "keywords": ["stan_benchmark", "linear regression"], + "keywords": [ + "stan_benchmark", + "linear regression" + ], "title": "Multiple Highly Correlated Predictors Linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +14,9 @@ "stan": { "model_code": "models/stan/kilpisjarvi.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/kilpisjarvi.py" } }, "references": "bales2019selecting", diff --git a/posterior_database/models/info/log10earn_height.info.json b/posterior_database/models/info/log10earn_height.info.json index 1f0bd44b..1cb170af 100644 --- a/posterior_database/models/info/log10earn_height.info.json +++ b/posterior_database/models/info/log10earn_height.info.json @@ -1,6 +1,10 @@ { "name": "log10earn_height", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "One Predictor Log10-linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/log10earn_height.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/log10earn_height.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/logearn_height_male.info.json b/posterior_database/models/info/logearn_height_male.info.json index 99c2fec1..8d3c1003 100644 --- a/posterior_database/models/info/logearn_height_male.info.json +++ b/posterior_database/models/info/logearn_height_male.info.json @@ -1,6 +1,10 @@ { "name": "logearn_height_male", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "Multiple Predictors Log-linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/logearn_height_male.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/logearn_height_male.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/logearn_interaction.info.json b/posterior_database/models/info/logearn_interaction.info.json index 5952e2cf..8068c31c 100644 --- a/posterior_database/models/info/logearn_interaction.info.json +++ b/posterior_database/models/info/logearn_interaction.info.json @@ -1,6 +1,10 @@ { "name": "logearn_interaction", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "Multiple Predictors Interacting Log-linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/logearn_interaction.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/logearn_interaction.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/logearn_interaction_z.info.json b/posterior_database/models/info/logearn_interaction_z.info.json index 224ec367..b37a9fc5 100644 --- a/posterior_database/models/info/logearn_interaction_z.info.json +++ b/posterior_database/models/info/logearn_interaction_z.info.json @@ -1,6 +1,10 @@ { "name": "logearn_interaction_z", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "Multiple Linearly Transformed Predictors Interacting Log-linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/logearn_interaction_z.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/logearn_interaction_z.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/logearn_logheight_male.info.json b/posterior_database/models/info/logearn_logheight_male.info.json index 63b8fbc5..8fe65117 100644 --- a/posterior_database/models/info/logearn_logheight_male.info.json +++ b/posterior_database/models/info/logearn_logheight_male.info.json @@ -1,6 +1,10 @@ { "name": "logearn_logheight_male", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "Multiple Predictors Log-Log Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/logearn_logheight_male.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/logearn_logheight_male.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/logistic_regression_rhs.info.json b/posterior_database/models/info/logistic_regression_rhs.info.json index 48ceaed1..ac716e25 100644 --- a/posterior_database/models/info/logistic_regression_rhs.info.json +++ b/posterior_database/models/info/logistic_regression_rhs.info.json @@ -1,6 +1,9 @@ { "name": "logistic_regression_rhs", - "keywords": ["stan_benchmark", "logistic regression"], + "keywords": [ + "stan_benchmark", + "logistic regression" + ], "title": "Logistic Regression with Regularized Horseshoe Prior", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +14,9 @@ "stan": { "model_code": "models/stan/logistic_regression_rhs.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/logistic_regression_rhs.py" } }, "references": "piironen2017sparsity", diff --git a/posterior_database/models/info/logmesquite_logvas.info.json b/posterior_database/models/info/logmesquite_logvas.info.json index ff71a6d7..c086fe2d 100644 --- a/posterior_database/models/info/logmesquite_logvas.info.json +++ b/posterior_database/models/info/logmesquite_logvas.info.json @@ -1,6 +1,10 @@ { "name": "logmesquite_logvas", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "Log-Log Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/logmesquite_logvas.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/logmesquite_logvas.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/logmesquite_logvash.info.json b/posterior_database/models/info/logmesquite_logvash.info.json index 57909d21..0bc3eb7b 100644 --- a/posterior_database/models/info/logmesquite_logvash.info.json +++ b/posterior_database/models/info/logmesquite_logvash.info.json @@ -1,6 +1,10 @@ { "name": "logmesquite_logvash", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "Log-Log Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/logmesquite_logvash.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/logmesquite_logvash.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/low_dim_gauss_mix.info.json b/posterior_database/models/info/low_dim_gauss_mix.info.json index f9337ebb..7c9a71d8 100644 --- a/posterior_database/models/info/low_dim_gauss_mix.info.json +++ b/posterior_database/models/info/low_dim_gauss_mix.info.json @@ -2,7 +2,10 @@ "name": "low_dim_gauss_mix", "title": "A Two-Dimensional Gaussian Mixture Model", "description": "A Two-Dimensional Gaussian Mixture Model", - "keywords": ["stan_benchmark", "mixture model"], + "keywords": [ + "stan_benchmark", + "mixture model" + ], "references": null, "urls": "https://github.com/stan-dev/stat_comp_benchmarks/tree/master/benchmarks/low_dim_gauss_mix", "prior": { @@ -12,6 +15,9 @@ "stan": { "model_code": "models/stan/low_dim_gauss_mix.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/low_dim_gauss_mix.py" } }, "added_by": "Mans Magnusson", diff --git a/posterior_database/models/info/low_dim_gauss_mix_collapse.info.json b/posterior_database/models/info/low_dim_gauss_mix_collapse.info.json index 4bedf8e8..1877cf93 100644 --- a/posterior_database/models/info/low_dim_gauss_mix_collapse.info.json +++ b/posterior_database/models/info/low_dim_gauss_mix_collapse.info.json @@ -2,7 +2,10 @@ "name": "low_dim_gauss_mix_collapse", "title": "A Two-Dimensional (unordered) Gaussian Mixture Model", "description": "A Two-Dimensional Gaussian Mixture Model", - "keywords": ["stan_benchmark", "mixture model"], + "keywords": [ + "stan_benchmark", + "mixture model" + ], "references": null, "urls": "https://github.com/stan-dev/stat_comp_benchmarks/tree/master/benchmarks/low_dim_gauss_mix_collapse", "prior": { @@ -12,6 +15,9 @@ "stan": { "model_code": "models/stan/low_dim_gauss_mix_collapse.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/low_dim_gauss_mix_collapse.py" } }, "added_by": "Mans Magnusson", diff --git a/posterior_database/models/info/lsat_model.info.json b/posterior_database/models/info/lsat_model.info.json index 43041058..468a4cae 100644 --- a/posterior_database/models/info/lsat_model.info.json +++ b/posterior_database/models/info/lsat_model.info.json @@ -1,6 +1,10 @@ { "name": "lsat_model", - "keywords": ["Random Effects", "Random", "LSAT"], + "keywords": [ + "Random Effects", + "Random", + "LSAT" + ], "title": "Random Effects (Rasch) Model for True Difficulty of LSAT Questions", "description": "One-parameter 'Rasch Model' where the probability that a student\n responds correctly to a question is assumed to follow a logistic\n function parameterized by 'item difficulty' and a latent variable\n representing the students underlying ability.", "urls": "https://github.com/stan-dev/example-models/tree/master/bugs_examples/vol1/lsat", @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/lsat_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/lsat_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/mesquite.info.json b/posterior_database/models/info/mesquite.info.json index ca6405f9..fe92a63e 100644 --- a/posterior_database/models/info/mesquite.info.json +++ b/posterior_database/models/info/mesquite.info.json @@ -1,6 +1,10 @@ { "name": "mesquite", - "keywords": ["ARM", "Ch. 4", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 4", + "stan_examples" + ], "title": "Multiple Predictors Linear Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/mesquite.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/mesquite.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/nes_logit_model.info.json b/posterior_database/models/info/nes_logit_model.info.json index df769188..8f450843 100644 --- a/posterior_database/models/info/nes_logit_model.info.json +++ b/posterior_database/models/info/nes_logit_model.info.json @@ -1,9 +1,20 @@ { "name": "nes_logit_model", - "keywords": ["National", "Election", "Study", "Logistic Regression", "Single Predictor", "Preference", "Presidential Election"], + "keywords": [ + "National", + "Election", + "Study", + "Logistic Regression", + "Single Predictor", + "Preference", + "Presidential Election" + ], "title": "Logistic Regression Model for Voting Preference based on Income", "description": "Logistic regression to estimate the probability of supporting a candidate inferring on income.", - "urls": ["https://github.com/stan-dev/example-models/tree/master/ARM/Ch.5", "http://www.stat.columbia.edu/~gelman/arm/"], + "urls": [ + "https://github.com/stan-dev/example-models/tree/master/ARM/Ch.5", + "http://www.stat.columbia.edu/~gelman/arm/" + ], "references": "gelman2006data", "added_by": "Kane Lindsay", "added_date": "2021-07-01", @@ -11,6 +22,9 @@ "stan": { "model_code": "models/stan/nes_logit_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/nes_logit_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/normal_mixture.info.json b/posterior_database/models/info/normal_mixture.info.json index 024be3a8..e5ca9bdf 100644 --- a/posterior_database/models/info/normal_mixture.info.json +++ b/posterior_database/models/info/normal_mixture.info.json @@ -1,6 +1,9 @@ { "name": "normal_mixture", - "keywords": ["basic_estimators", "stan_examples"], + "keywords": [ + "basic_estimators", + "stan_examples" + ], "title": "Two Component Gaussian Mixture Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +14,9 @@ "stan": { "model_code": "models/stan/normal_mixture.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/normal_mixture.py" } }, "references": null, diff --git a/posterior_database/models/info/normal_mixture_k.info.json b/posterior_database/models/info/normal_mixture_k.info.json index 62fa23f6..166f132b 100644 --- a/posterior_database/models/info/normal_mixture_k.info.json +++ b/posterior_database/models/info/normal_mixture_k.info.json @@ -1,6 +1,9 @@ { "name": "normal_mixture_k", - "keywords": ["basic_estimators", "stan_examples"], + "keywords": [ + "basic_estimators", + "stan_examples" + ], "title": "K Component Gaussian Mixture Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +14,9 @@ "stan": { "model_code": "models/stan/normal_mixture_k.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/normal_mixture_k.py" } }, "references": null, diff --git a/posterior_database/models/info/pilots.info.json b/posterior_database/models/info/pilots.info.json index 070dbb23..a0d40bd9 100644 --- a/posterior_database/models/info/pilots.info.json +++ b/posterior_database/models/info/pilots.info.json @@ -1,6 +1,10 @@ { "name": "pilots", - "keywords": ["ARM", "Ch. 14", "stan_examples"], + "keywords": [ + "ARM", + "Ch. 14", + "stan_examples" + ], "title": "Linear Mixed Effects Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +15,9 @@ "stan": { "model_code": "models/stan/pilots.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/pilots.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/radon_county.info.json b/posterior_database/models/info/radon_county.info.json index 452c5862..eaa67b3c 100644 --- a/posterior_database/models/info/radon_county.info.json +++ b/posterior_database/models/info/radon_county.info.json @@ -1,6 +1,9 @@ { "name": "radon_county", - "keywords": ["stan_benchmark", "hierarchical model"], + "keywords": [ + "stan_benchmark", + "hierarchical model" + ], "title": "Hierarchical Model", "prior": { "keywords": "stan_recommended_35dbfe6" @@ -11,6 +14,9 @@ "stan": { "model_code": "models/stan/radon_county.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/radon_county.py" } }, "references": "bales2019selecting", diff --git a/posterior_database/models/info/radon_county_intercept.info.json b/posterior_database/models/info/radon_county_intercept.info.json index 20143753..cba2b79f 100644 --- a/posterior_database/models/info/radon_county_intercept.info.json +++ b/posterior_database/models/info/radon_county_intercept.info.json @@ -11,6 +11,9 @@ "stan": { "model_code": "models/stan/radon_county_intercept.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/radon_county_intercept.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/radon_hierarchical_intercept_centered.info.json b/posterior_database/models/info/radon_hierarchical_intercept_centered.info.json index 6d8845e4..908881ee 100644 --- a/posterior_database/models/info/radon_hierarchical_intercept_centered.info.json +++ b/posterior_database/models/info/radon_hierarchical_intercept_centered.info.json @@ -11,6 +11,9 @@ "stan": { "model_code": "models/stan/radon_hierarchical_intercept_centered.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/radon_hierarchical_intercept_centered.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/radon_hierarchical_intercept_noncentered.info.json b/posterior_database/models/info/radon_hierarchical_intercept_noncentered.info.json index bcc60fcb..f9c3ca6d 100644 --- a/posterior_database/models/info/radon_hierarchical_intercept_noncentered.info.json +++ b/posterior_database/models/info/radon_hierarchical_intercept_noncentered.info.json @@ -11,6 +11,9 @@ "stan": { "model_code": "models/stan/radon_hierarchical_intercept_noncentered.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/radon_hierarchical_intercept_noncentered.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/radon_partially_pooled_centered.info.json b/posterior_database/models/info/radon_partially_pooled_centered.info.json index 10365962..3e16c669 100644 --- a/posterior_database/models/info/radon_partially_pooled_centered.info.json +++ b/posterior_database/models/info/radon_partially_pooled_centered.info.json @@ -11,6 +11,9 @@ "stan": { "model_code": "models/stan/radon_partially_pooled_centered.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/radon_partially_pooled_centered.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/radon_pooled.info.json b/posterior_database/models/info/radon_pooled.info.json index b57f1a9d..d7acd7a2 100644 --- a/posterior_database/models/info/radon_pooled.info.json +++ b/posterior_database/models/info/radon_pooled.info.json @@ -11,6 +11,9 @@ "stan": { "model_code": "models/stan/radon_pooled.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/radon_pooled.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/radon_variable_intercept_centered.info.json b/posterior_database/models/info/radon_variable_intercept_centered.info.json index 92657541..7229c113 100644 --- a/posterior_database/models/info/radon_variable_intercept_centered.info.json +++ b/posterior_database/models/info/radon_variable_intercept_centered.info.json @@ -11,6 +11,9 @@ "stan": { "model_code": "models/stan/radon_variable_intercept_centered.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/radon_variable_intercept_centered.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/radon_variable_intercept_noncentered.info.json b/posterior_database/models/info/radon_variable_intercept_noncentered.info.json index 6112af94..c346b9c2 100644 --- a/posterior_database/models/info/radon_variable_intercept_noncentered.info.json +++ b/posterior_database/models/info/radon_variable_intercept_noncentered.info.json @@ -11,6 +11,9 @@ "stan": { "model_code": "models/stan/radon_variable_intercept_noncentered.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/radon_variable_intercept_noncentered.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/radon_variable_intercept_slope_centered.info.json b/posterior_database/models/info/radon_variable_intercept_slope_centered.info.json index c172c3b9..587f131c 100644 --- a/posterior_database/models/info/radon_variable_intercept_slope_centered.info.json +++ b/posterior_database/models/info/radon_variable_intercept_slope_centered.info.json @@ -11,6 +11,9 @@ "stan": { "model_code": "models/stan/radon_variable_intercept_slope_centered.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/radon_variable_intercept_slope_centered.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/radon_variable_intercept_slope_noncentered.info.json b/posterior_database/models/info/radon_variable_intercept_slope_noncentered.info.json index 25754794..50418621 100644 --- a/posterior_database/models/info/radon_variable_intercept_slope_noncentered.info.json +++ b/posterior_database/models/info/radon_variable_intercept_slope_noncentered.info.json @@ -11,6 +11,9 @@ "stan": { "model_code": "models/stan/radon_variable_intercept_slope_noncentered.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/radon_variable_intercept_slope_noncentered.py" } }, "references": "gelman2006data", diff --git a/posterior_database/models/info/rats_model.info.json b/posterior_database/models/info/rats_model.info.json index 1f0f7d95..3a0faac8 100644 --- a/posterior_database/models/info/rats_model.info.json +++ b/posterior_database/models/info/rats_model.info.json @@ -1,6 +1,13 @@ { "name": "rats_model", - "keywords": ["Heirarchical", "Normal", "Rats", "Random Effects", "Linear Growth", "Linear"], + "keywords": [ + "Heirarchical", + "Normal", + "Rats", + "Random Effects", + "Linear Growth", + "Linear" + ], "title": "Normal Heirarchical Model to Model Rats' Weight Over Time", "description": "The model is essentially a random effects linear growth curve.", "urls": "https://github.com/stan-dev/example-models/tree/master/bugs_examples/vol1/rats", @@ -11,6 +18,9 @@ "stan": { "model_code": "models/stan/rats_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/rats_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/seeds_centered_model.info.json b/posterior_database/models/info/seeds_centered_model.info.json index 80d20721..81365736 100644 --- a/posterior_database/models/info/seeds_centered_model.info.json +++ b/posterior_database/models/info/seeds_centered_model.info.json @@ -1,6 +1,13 @@ { "name": "seeds_centered_model", - "keywords": ["Random", "Effect", "Logistic", "Regression", "Stanified", "Centered"], + "keywords": [ + "Random", + "Effect", + "Logistic", + "Regression", + "Stanified", + "Centered" + ], "title": "Normal Heirarchical Model to Model Rats' Weight Over Time", "description": "The model is essentially a random effects logistic,\n allowing for over-dispersion. Models the proportion of germination\n of different seeds in different root extracts. 'Stanified' & centered:\n tau replaced by sigma, direct estimation using \n narrower semi-informative priors, coefficients are centered", "urls": "http://www.mrc-bsu.cam.ac.uk/wp-content/uploads/WinBUGS_Vol1.pdf", @@ -11,6 +18,9 @@ "stan": { "model_code": "models/stan/seeds_centered_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/seeds_centered_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/seeds_model.info.json b/posterior_database/models/info/seeds_model.info.json index b04a4279..083465a2 100644 --- a/posterior_database/models/info/seeds_model.info.json +++ b/posterior_database/models/info/seeds_model.info.json @@ -1,6 +1,11 @@ { "name": "seeds_model", - "keywords": ["Random", "Effect", "Logistic", "Regression"], + "keywords": [ + "Random", + "Effect", + "Logistic", + "Regression" + ], "title": "Random Effect Logistic Regression for Seed Germination Proportion", "description": "The model is essentially a random effects logistic,\n allowing for over-dispersion. Models the proportion of germination\n of different seeds in different root extracts.", "urls": "http://www.mrc-bsu.cam.ac.uk/wp-content/uploads/WinBUGS_Vol1.pdf", @@ -10,6 +15,9 @@ "model_implementations": { "stan": { "model_code": "models/stan/seeds_model.stan" + }, + "pymc": { + "model_code": "models/pymc/seeds_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/seeds_stanified_model.info.json b/posterior_database/models/info/seeds_stanified_model.info.json index 12c6f392..4c4f78ad 100644 --- a/posterior_database/models/info/seeds_stanified_model.info.json +++ b/posterior_database/models/info/seeds_stanified_model.info.json @@ -1,6 +1,12 @@ { "name": "seeds_stanified_model", - "keywords": ["Random", "Effect", "Logistic", "Regression", "Stanified"], + "keywords": [ + "Random", + "Effect", + "Logistic", + "Regression", + "Stanified" + ], "title": "Normal Heirarchical Model to Model Rats' Weight Over Time", "description": "The model is essentially a random effects logistic,\n allowing for over-dispersion. Models the proportion of germination\n of different seeds in different root extracts. 'Stanified':\n tau replaced by sigma, direct estimation using \n narrower semi-informative priors", "urls": "http://www.mrc-bsu.cam.ac.uk/wp-content/uploads/WinBUGS_Vol1.pdf", @@ -11,6 +17,9 @@ "stan": { "model_code": "models/stan/seeds_stanified_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/seeds_stanified_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/sesame_one_pred_a.info.json b/posterior_database/models/info/sesame_one_pred_a.info.json index 7d1f1afa..3e2eb9e5 100644 --- a/posterior_database/models/info/sesame_one_pred_a.info.json +++ b/posterior_database/models/info/sesame_one_pred_a.info.json @@ -1,6 +1,11 @@ { "name": "sesame_one_pred_a", - "keywords": ["sesame", "ARM", "Ch.10", "linear model"], + "keywords": [ + "sesame", + "ARM", + "Ch.10", + "linear model" + ], "title": "Linear model for the effect of encouragement to watch on actually watching Sesame Street", "description": "A linear model with one predictor.", "urls": "https://github.com/stan-dev/example-models/tree/master/ARM/Ch.10", @@ -11,6 +16,9 @@ "stan": { "model_code": "models/stan/sesame_one_pred_a.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/sesame_one_pred_a.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/wells_daae_c_model.info.json b/posterior_database/models/info/wells_daae_c_model.info.json index 660d8a09..7946a9bb 100644 --- a/posterior_database/models/info/wells_daae_c_model.info.json +++ b/posterior_database/models/info/wells_daae_c_model.info.json @@ -1,6 +1,20 @@ { "name": "wells_daae_c_model", - "keywords": ["wells", "ARM", "Ch.5", "logistic", "regression", "scaled", "four predictors", "arsenic", "distance", "education", "community organization", "centered", "social predictor"], + "keywords": [ + "wells", + "ARM", + "Ch.5", + "logistic", + "regression", + "scaled", + "four predictors", + "arsenic", + "distance", + "education", + "community organization", + "centered", + "social predictor" + ], "title": "4-Predictor logistic regression model with centered inputs for decision to switch wells", "description": "Performs logistic regression using four centered predictors:\n distance from nearest safe well, arsenic levels, years in\n education, and if the individual is associated with an active community project.\n The association predictor is not actually predictive of switching.\n ", "urls": "https://github.com/stan-dev/example-models/tree/master/ARM/Ch.5", @@ -11,6 +25,9 @@ "stan": { "model_code": "models/stan/wells_daae_c_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/wells_daae_c_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/wells_dae_c_model.info.json b/posterior_database/models/info/wells_dae_c_model.info.json index 8fd56f0d..27c9ad4b 100644 --- a/posterior_database/models/info/wells_dae_c_model.info.json +++ b/posterior_database/models/info/wells_dae_c_model.info.json @@ -1,6 +1,19 @@ { "name": "wells_dae_c_model", - "keywords": ["wells", "ARM", "Ch.5", "logistic", "regression", "scaled", "three predictors", "arsenic", "distance", "education", "centered", "social predictor"], + "keywords": [ + "wells", + "ARM", + "Ch.5", + "logistic", + "regression", + "scaled", + "three predictors", + "arsenic", + "distance", + "education", + "centered", + "social predictor" + ], "title": "3-Predictor logistic regression model with centered inputs for decision to switch wells", "description": "Performs logistic regression using three centered predictors \n (distance from nearest safe well, arsenic levels, and years in\n education).", "urls": "https://github.com/stan-dev/example-models/tree/master/ARM/Ch.5", @@ -11,6 +24,9 @@ "stan": { "model_code": "models/stan/wells_dae_c_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/wells_dae_c_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/wells_dae_inter_model.info.json b/posterior_database/models/info/wells_dae_inter_model.info.json index 9d35e1ed..137ea409 100644 --- a/posterior_database/models/info/wells_dae_inter_model.info.json +++ b/posterior_database/models/info/wells_dae_inter_model.info.json @@ -1,6 +1,20 @@ { "name": "wells_dae_inter_model", - "keywords": ["wells", "ARM", "Ch.5", "logistic", "regression", "scaled", "three predictors", "arsenic", "distance", "interaction", "centered", "education", "social predictor"], + "keywords": [ + "wells", + "ARM", + "Ch.5", + "logistic", + "regression", + "scaled", + "three predictors", + "arsenic", + "distance", + "interaction", + "centered", + "education", + "social predictor" + ], "title": "3-Input logistic regression model with interactions and centered inputs for decision to switch wells", "description": "Performs logistic regression using three centered inputs \n (distance from nearest safe well, log-scaled arsenic levels, and years in\n education) and the interactions between each pair of inputs.", "urls": "https://github.com/stan-dev/example-models/tree/master/ARM/Ch.5", @@ -11,6 +25,9 @@ "stan": { "model_code": "models/stan/wells_dae_inter_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/wells_dae_inter_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/wells_dae_model.info.json b/posterior_database/models/info/wells_dae_model.info.json index 5a4203da..5d271b21 100644 --- a/posterior_database/models/info/wells_dae_model.info.json +++ b/posterior_database/models/info/wells_dae_model.info.json @@ -1,6 +1,19 @@ { "name": "wells_dae_model", - "keywords": ["wells", "ARM", "Ch.5", "logistic", "regression", "scaled", "three predictors", "arsenic", "distance", "interaction", "education", "social predictor"], + "keywords": [ + "wells", + "ARM", + "Ch.5", + "logistic", + "regression", + "scaled", + "three predictors", + "arsenic", + "distance", + "interaction", + "education", + "social predictor" + ], "title": "3-Predictor logistic regression model for decision to switch wells.", "description": "Performs logistic regression using three predictors \n (distance from nearest safe well, arsenic levels, and years in\n education).", "urls": "https://github.com/stan-dev/example-models/tree/master/ARM/Ch.5", @@ -11,6 +24,9 @@ "stan": { "model_code": "models/stan/wells_dae_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/wells_dae_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/wells_dist.info.json b/posterior_database/models/info/wells_dist.info.json index 8f018591..7e1782d4 100644 --- a/posterior_database/models/info/wells_dist.info.json +++ b/posterior_database/models/info/wells_dist.info.json @@ -1,6 +1,12 @@ { "name": "wells_dist", - "keywords": ["wells", "ARM", "Ch.5", "logistic", "regression"], + "keywords": [ + "wells", + "ARM", + "Ch.5", + "logistic", + "regression" + ], "title": "Logistic regression model for decision to switch wells", "description": "Performs logistic regression using one predictor (distance from nearest safe well).", "urls": "https://github.com/stan-dev/example-models/tree/master/ARM/Ch.5", @@ -11,6 +17,9 @@ "stan": { "model_code": "models/stan/wells_dist.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/wells_dist.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/wells_dist100_model.info.json b/posterior_database/models/info/wells_dist100_model.info.json index 543c5b7c..67c0b78e 100644 --- a/posterior_database/models/info/wells_dist100_model.info.json +++ b/posterior_database/models/info/wells_dist100_model.info.json @@ -1,6 +1,13 @@ { "name": "wells_dist100_model", - "keywords": ["wells", "ARM", "Ch.5", "logistic", "regression", "scaled"], + "keywords": [ + "wells", + "ARM", + "Ch.5", + "logistic", + "regression", + "scaled" + ], "title": "Logistic regression model for decision to switch wells", "description": "Performs logistic regression using one predictor (distance from nearest safe well).\n Rescales distance to 100-meter units.", "urls": "https://github.com/stan-dev/example-models/tree/master/ARM/Ch.5", @@ -11,6 +18,9 @@ "stan": { "model_code": "models/stan/wells_dist100_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/wells_dist100_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/wells_dist100ars_model.info.json b/posterior_database/models/info/wells_dist100ars_model.info.json index 495f15a2..0570aff0 100644 --- a/posterior_database/models/info/wells_dist100ars_model.info.json +++ b/posterior_database/models/info/wells_dist100ars_model.info.json @@ -1,6 +1,16 @@ { "name": "wells_dist100ars_model", - "keywords": ["wells", "ARM", "Ch.5", "logistic", "regression", "scaled", "two predictors", "arsenic", "distance"], + "keywords": [ + "wells", + "ARM", + "Ch.5", + "logistic", + "regression", + "scaled", + "two predictors", + "arsenic", + "distance" + ], "title": "2-Predictor Logistic regression model for decision to switch wells", "description": "Performs logistic regression using two predictors (distance from nearest safe well and arsenic levels).\n Rescales distance to 100-meter units.", "urls": "https://github.com/stan-dev/example-models/tree/master/ARM/Ch.5", @@ -11,6 +21,9 @@ "stan": { "model_code": "models/stan/wells_dist100ars_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/wells_dist100ars_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/wells_interaction_c_model.info.json b/posterior_database/models/info/wells_interaction_c_model.info.json index ceeee8a4..3bce188a 100644 --- a/posterior_database/models/info/wells_interaction_c_model.info.json +++ b/posterior_database/models/info/wells_interaction_c_model.info.json @@ -1,6 +1,17 @@ { "name": "wells_interaction_c_model", - "keywords": ["wells", "ARM", "Ch.5", "logistic", "regression", "scaled", "two predictors", "arsenic", "distance", "interaction"], + "keywords": [ + "wells", + "ARM", + "Ch.5", + "logistic", + "regression", + "scaled", + "two predictors", + "arsenic", + "distance", + "interaction" + ], "title": "2-Predictor logistic regression model with interactions and centered inputs for decision to switch wells", "description": "Performs logistic regression using two predictors\n (distance from nearest safe well and arsenic levels) and their\n interaction with centered input variables.", "urls": "https://github.com/stan-dev/example-models/tree/master/ARM/Ch.5", @@ -11,6 +22,9 @@ "stan": { "model_code": "models/stan/wells_interaction_c_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/wells_interaction_c_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/info/wells_interaction_model.info.json b/posterior_database/models/info/wells_interaction_model.info.json index 6ccabe63..39c71532 100644 --- a/posterior_database/models/info/wells_interaction_model.info.json +++ b/posterior_database/models/info/wells_interaction_model.info.json @@ -1,6 +1,17 @@ { "name": "wells_interaction_model", - "keywords": ["wells", "ARM", "Ch.5", "logistic", "regression", "scaled", "two predictors", "arsenic", "distance", "interaction"], + "keywords": [ + "wells", + "ARM", + "Ch.5", + "logistic", + "regression", + "scaled", + "two predictors", + "arsenic", + "distance", + "interaction" + ], "title": "2-Predictor Logistic regression model with interactions for decision to switch wells", "description": "Performs logistic regression using two predictors (distance from nearest safe well and arsenic levels) and their interaction.", "urls": "https://github.com/stan-dev/example-models/tree/master/ARM/Ch.5", @@ -11,6 +22,9 @@ "stan": { "model_code": "models/stan/wells_interaction_model.stan", "stan_version": ">=2.26.0" + }, + "pymc": { + "model_code": "models/pymc/wells_interaction_model.py" } }, "licence": "BSD3" diff --git a/posterior_database/models/pymc/GLMM1_model.py b/posterior_database/models/pymc/GLMM1_model.py new file mode 100644 index 00000000..95b8dc45 --- /dev/null +++ b/posterior_database/models/pymc/GLMM1_model.py @@ -0,0 +1,29 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + nobs = data['nobs'] + nmis = data['nmis'] + nyear = data['nyear'] + nsite = data['nsite'] + obs = np.array(data['obs']) + obsyear = np.array(data['obsyear']) - 1 + obssite = np.array(data['obssite']) - 1 + misyear = np.array(data['misyear']) - 1 + missite = np.array(data['missite']) - 1 + + with pm.Model() as model: + + mu_alpha = pm.Normal("mu_alpha", mu=0, sigma=10) + sd_alpha = pm.Uniform("sd_alpha", lower=0, upper=5) + alpha = pm.Normal("alpha", mu=mu_alpha, sigma=sd_alpha, shape=nsite) + + log_lambda = pm.Deterministic("log_lambda", + pt.tile(alpha[None, :], (nyear, 1))) + + if not prior_only: + pm.Poisson("obs", mu=pt.exp(log_lambda[obsyear, obssite]), observed=obs) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/GLMM_Poisson_model.py b/posterior_database/models/pymc/GLMM_Poisson_model.py new file mode 100644 index 00000000..b44a435b --- /dev/null +++ b/posterior_database/models/pymc/GLMM_Poisson_model.py @@ -0,0 +1,31 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + n = data['n'] + C = np.array(data['C']) + year = np.array(data['year']) + + year_squared = year * year + year_cubed = year * year * year + + with pm.Model() as model: + alpha = pm.Uniform("alpha", lower=-20, upper=20) + beta1 = pm.Uniform("beta1", lower=-10, upper=10) + beta2 = pm.Uniform("beta2", lower=-10, upper=20) + beta3 = pm.Uniform("beta3", lower=-10, upper=10) + sigma = pm.Uniform("sigma", lower=0, upper=5) + + eps = pm.Normal("eps", mu=0, sigma=sigma, shape=n) + + log_lambda = pm.Deterministic("log_lambda", + alpha + beta1 * year + beta2 * year_squared + beta3 * year_cubed + eps) + + lambda_param = pm.Deterministic("lambda", pt.exp(log_lambda)) + + if not prior_only: + pm.Poisson("C", mu=lambda_param, observed=C) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/GLM_Poisson_model.py b/posterior_database/models/pymc/GLM_Poisson_model.py new file mode 100644 index 00000000..603284b3 --- /dev/null +++ b/posterior_database/models/pymc/GLM_Poisson_model.py @@ -0,0 +1,28 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + n = data['n'] + C = np.asarray(data['C']) + year = np.asarray(data['year']) + + year_squared = year**2 + year_cubed = year_squared * year + + with pm.Model() as model: + alpha = pm.Uniform("alpha", lower=-20, upper=20) + beta1 = pm.Uniform("beta1", lower=-10, upper=10) + beta2 = pm.Uniform("beta2", lower=-10, upper=10) + beta3 = pm.Uniform("beta3", lower=-10, upper=10) + + log_lambda = pm.Deterministic("log_lambda", + alpha + beta1 * year + beta2 * year_squared + beta3 * year_cubed) + + lambda_gq = pm.Deterministic("lambda", pt.exp(log_lambda)) + + if not prior_only: + pm.Poisson("C", mu=pt.exp(log_lambda), observed=C) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/Rate_2_model.py b/posterior_database/models/pymc/Rate_2_model.py new file mode 100644 index 00000000..2d025376 --- /dev/null +++ b/posterior_database/models/pymc/Rate_2_model.py @@ -0,0 +1,18 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np +from scipy.special import gammaln + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + theta1 = pm.Uniform("theta1", lower=0, upper=1) + theta2 = pm.Uniform("theta2", lower=0, upper=1) + + delta = pm.Deterministic("delta", theta1 - theta2) + + if not prior_only: + k1_obs = pm.Binomial("k1", n=data['n1'], p=theta1, observed=data['k1']) + k2_obs = pm.Binomial("k2", n=data['n2'], p=theta2, observed=data['k2']) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/Rate_4_model.py b/posterior_database/models/pymc/Rate_4_model.py new file mode 100644 index 00000000..ae2fa3e2 --- /dev/null +++ b/posterior_database/models/pymc/Rate_4_model.py @@ -0,0 +1,18 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + theta = pm.Uniform("theta", lower=0, upper=1) + thetaprior = pm.Uniform("thetaprior", lower=0, upper=1) + + if not prior_only: + k_obs = pm.Binomial("k", n=data['n'], p=theta, observed=data['k']) + + n = data['n'] + k = data['k'] + log_binom_coeff = pt.gammaln(n + 1) - pt.gammaln(k + 1) - pt.gammaln(n - k + 1) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/Rate_5_model.py b/posterior_database/models/pymc/Rate_5_model.py new file mode 100644 index 00000000..24322fd4 --- /dev/null +++ b/posterior_database/models/pymc/Rate_5_model.py @@ -0,0 +1,14 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + theta = pm.Beta("theta", alpha=1, beta=1) + + if not prior_only: + k1_obs = pm.Binomial("k1", n=data["n1"], p=theta, observed=data["k1"]) + k2_obs = pm.Binomial("k2", n=data["n2"], p=theta, observed=data["k2"]) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/accel_splines.py b/posterior_database/models/pymc/accel_splines.py new file mode 100644 index 00000000..253618df --- /dev/null +++ b/posterior_database/models/pymc/accel_splines.py @@ -0,0 +1,42 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + Y = data['Y'] + Ks = data['Ks'] + Xs = data['Xs'] + knots_1 = data['knots_1'] + Zs_1_1 = data['Zs_1_1'] + Ks_sigma = data['Ks_sigma'] + Xs_sigma = data['Xs_sigma'] + knots_sigma_1 = data['knots_sigma_1'] + Zs_sigma_1_1 = data['Zs_sigma_1_1'] + + with pm.Model() as model: + Intercept = pm.StudentT("Intercept", nu=3, mu=-13, sigma=36) + bs = pm.Flat("bs", shape=Ks) + + zs_1_1 = pm.Normal("zs_1_1", mu=0, sigma=1, shape=knots_1) + sds_1_1 = pm.Truncated("sds_1_1", pm.StudentT.dist(nu=3, mu=0, sigma=36), lower=0) + + Intercept_sigma = pm.StudentT("Intercept_sigma", nu=3, mu=0, sigma=10) + bs_sigma = pm.Flat("bs_sigma", shape=Ks_sigma) + + zs_sigma_1_1 = pm.Normal("zs_sigma_1_1", mu=0, sigma=1, shape=knots_sigma_1) + sds_sigma_1_1 = pm.Truncated("sds_sigma_1_1", pm.StudentT.dist(nu=3, mu=0, sigma=36), lower=0) + + s_1_1 = pm.Deterministic("s_1_1", sds_1_1 * zs_1_1) + s_sigma_1_1 = pm.Deterministic("s_sigma_1_1", sds_sigma_1_1 * zs_sigma_1_1) + + mu_linear = Intercept + Xs @ bs + Zs_1_1 @ s_1_1 + sigma_linear = Intercept_sigma + Xs_sigma @ bs_sigma + Zs_sigma_1_1 @ s_sigma_1_1 + + sigma = pm.Deterministic("sigma", pt.exp(sigma_linear)) + + if not prior_only: + Y_obs = pm.Normal("Y", mu=mu_linear, sigma=sigma, observed=Y) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/arK.py b/posterior_database/models/pymc/arK.py new file mode 100644 index 00000000..ff03fffb --- /dev/null +++ b/posterior_database/models/pymc/arK.py @@ -0,0 +1,24 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + K = data['K'] + T = data['T'] + y_data = data['y'] + + y_arr = np.array(y_data) + lag_matrix = np.column_stack([y_arr[K-k-1:T-k-1] for k in range(K)]) + + with pm.Model() as model: + alpha = pm.Normal("alpha", mu=0, sigma=10) + beta = pm.Normal("beta", mu=0, sigma=10, shape=K) + sigma = pm.HalfCauchy("sigma", beta=2.5) + + mu = pm.Deterministic("mu", alpha + lag_matrix @ beta) + + if not prior_only: + y_obs = pm.Normal("y", mu=mu, sigma=sigma, observed=y_data[K:]) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/blr.py b/posterior_database/models/pymc/blr.py new file mode 100644 index 00000000..ecd6dd96 --- /dev/null +++ b/posterior_database/models/pymc/blr.py @@ -0,0 +1,21 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + N = data['N'] + D = data['D'] + X = data['X'] + y = data['y'] + + beta = pm.Normal("beta", mu=0, sigma=10, shape=D) + sigma = pm.HalfNormal("sigma", sigma=10) + + mu = pm.Deterministic("mu", X @ beta) + + if not prior_only: + y_obs = pm.Normal("y", mu=mu, sigma=sigma, observed=y) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/diamonds.py b/posterior_database/models/pymc/diamonds.py new file mode 100644 index 00000000..ef86d0c9 --- /dev/null +++ b/posterior_database/models/pymc/diamonds.py @@ -0,0 +1,22 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + Y = data['Y'] + K = data['K'] + X = data['X'] + + Kc = K - 1 + + with pm.Model() as model: + b = pm.Normal("b", mu=0, sigma=1, shape=Kc) + Intercept = pm.StudentT("Intercept", nu=3, mu=8, sigma=10) + sigma = pm.HalfStudentT("sigma", nu=3, sigma=10) + + if not prior_only: + Y_obs = pm.Normal("Y", mu=Intercept, sigma=sigma, observed=Y) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/dogs.py b/posterior_database/models/pymc/dogs.py new file mode 100644 index 00000000..ee10ae99 --- /dev/null +++ b/posterior_database/models/pymc/dogs.py @@ -0,0 +1,21 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + n_dogs = data['n_dogs'] + n_trials = data['n_trials'] + y_data = np.array(data['y']) + n_avoid = np.hstack([np.zeros((n_dogs, 1)), np.cumsum(1 - y_data[:, :-1], axis=1)]) + n_shock = np.hstack([np.zeros((n_dogs, 1)), np.cumsum(y_data[:, :-1], axis=1)]) + + with pm.Model() as model: + beta = pm.Normal("beta", mu=0, sigma=100, shape=3) + + logit_p = beta[0] + beta[1] * n_avoid + beta[2] * n_shock + + if not prior_only: + pm.Bernoulli("y", logit_p=logit_p, observed=y_data) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/dogs_hierarchical.py b/posterior_database/models/pymc/dogs_hierarchical.py new file mode 100644 index 00000000..55058510 --- /dev/null +++ b/posterior_database/models/pymc/dogs_hierarchical.py @@ -0,0 +1,25 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + n_dogs = data['n_dogs'] + n_trials = data['n_trials'] + y_data = np.array(data['y']) + + J = n_dogs + T = n_trials + prev_shock = np.hstack([np.zeros((J, 1)), np.cumsum(y_data[:, :-1], axis=1)]) + prev_avoid = np.hstack([np.zeros((J, 1)), np.cumsum(1 - y_data[:, :-1], axis=1)]) + + with pm.Model() as model: + a = pm.Uniform("a", lower=0, upper=1) + b = pm.Uniform("b", lower=0, upper=1) + + p = pm.Deterministic("p", a ** prev_shock * b ** prev_avoid) + + if not prior_only: + y_obs = pm.Bernoulli("y", p=p, observed=y_data) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/dugongs_model.py b/posterior_database/models/pymc/dugongs_model.py new file mode 100644 index 00000000..f70646e1 --- /dev/null +++ b/posterior_database/models/pymc/dugongs_model.py @@ -0,0 +1,25 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + x = data['x'] + Y = data['Y'] + + with pm.Model() as model: + alpha = pm.Normal("alpha", mu=0.0, sigma=1000) + beta = pm.Normal("beta", mu=0.0, sigma=1000) + lambda_ = pm.Uniform("lambda", lower=0.5, upper=1.0) + tau = pm.Gamma("tau", alpha=0.0001, beta=0.0001) + + sigma = pm.Deterministic("sigma", 1 / pt.sqrt(tau)) + U3 = pm.Deterministic("U3", pm.math.logit(lambda_)) + + m = pm.Deterministic("m", alpha - beta * pt.power(lambda_, x)) + + if not prior_only: + Y_obs = pm.Normal("Y", mu=m, sigma=sigma, observed=Y) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/earn_height.py b/posterior_database/models/pymc/earn_height.py new file mode 100644 index 00000000..5a8b985a --- /dev/null +++ b/posterior_database/models/pymc/earn_height.py @@ -0,0 +1,20 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + N = data['N'] + earn = data['earn'] + height = data['height'] + + beta = pm.Flat("beta", shape=2) + sigma = pm.HalfFlat("sigma") + + mu = pm.Deterministic("mu", beta[0] + beta[1] * height) + + if not prior_only: + pm.Normal("earn", mu=mu, sigma=sigma, observed=earn) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/eight_schools_centered.py b/posterior_database/models/pymc/eight_schools_centered.py new file mode 100644 index 00000000..b0486fbb --- /dev/null +++ b/posterior_database/models/pymc/eight_schools_centered.py @@ -0,0 +1,19 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + J = data['J'] + y_obs = data['y'] + sigma_data = data['sigma'] + + mu = pm.Normal("mu", mu=0, sigma=5) + tau = pm.HalfCauchy("tau", beta=5) + theta = pm.Normal("theta", mu=mu, sigma=tau, shape=J) + + if not prior_only: + y = pm.Normal("y", mu=theta, sigma=sigma_data, observed=y_obs) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/election88_full.py b/posterior_database/models/pymc/election88_full.py new file mode 100644 index 00000000..6240652d --- /dev/null +++ b/posterior_database/models/pymc/election88_full.py @@ -0,0 +1,55 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + n_age = data['n_age'] + n_age_edu = data['n_age_edu'] + n_edu = data['n_edu'] + n_region_full = data['n_region_full'] + n_state = data['n_state'] + + age_idx = np.array(data['age']) - 1 + age_edu_idx = np.array(data['age_edu']) - 1 + edu_idx = np.array(data['edu']) - 1 + region_full_idx = np.array(data['region_full']) - 1 + state_idx = np.array(data['state']) - 1 + + black = np.array(data['black']) + female = np.array(data['female']) + v_prev_full = np.array(data['v_prev_full']) + y = np.array(data['y']) + + with pm.Model() as model: + sigma_a = pm.Uniform("sigma_a", lower=0, upper=100) + sigma_b = pm.Uniform("sigma_b", lower=0, upper=100) + sigma_c = pm.Uniform("sigma_c", lower=0, upper=100) + sigma_d = pm.Uniform("sigma_d", lower=0, upper=100) + sigma_e = pm.Uniform("sigma_e", lower=0, upper=100) + + a = pm.Normal("a", mu=0, sigma=sigma_a, shape=n_age) + b = pm.Normal("b", mu=0, sigma=sigma_b, shape=n_edu) + c = pm.Normal("c", mu=0, sigma=sigma_c, shape=n_age_edu) + d = pm.Normal("d", mu=0, sigma=sigma_d, shape=n_state) + e = pm.Normal("e", mu=0, sigma=sigma_e, shape=n_region_full) + + beta = pm.Normal("beta", mu=0, sigma=100, shape=5) + + logit_p = pm.Deterministic("logit_p", + beta[0] + + beta[1] * black + + beta[2] * female + + beta[3] * v_prev_full + + beta[4] * female * black + + a[age_idx] + + b[edu_idx] + + c[age_edu_idx] + + d[state_idx] + + e[region_full_idx]) + + if not prior_only: + pm.Bernoulli("y", logit_p=logit_p, observed=y) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/gp_pois_regr.py b/posterior_database/models/pymc/gp_pois_regr.py new file mode 100644 index 00000000..1aeb410d --- /dev/null +++ b/posterior_database/models/pymc/gp_pois_regr.py @@ -0,0 +1,29 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + x = np.array(data['x'], dtype=float) + k = np.array(data['k']) + + with pm.Model() as model: + + rho = pm.Gamma("rho", alpha=25, beta=4) + alpha = pm.HalfNormal("alpha", sigma=2) + f_tilde = pm.Normal("f_tilde", mu=0, sigma=1, shape=N) + + x_tensor = pt.as_tensor_variable(x) + x_diff = x_tensor[:, None] - x_tensor[None, :] + sqdist = x_diff ** 2 + cov = alpha**2 * pt.exp(-0.5 * sqdist / rho**2) + cov = cov + pt.eye(N) * 1e-10 + L_cov = pt.linalg.cholesky(cov) + + f = pm.Deterministic("f", L_cov @ f_tilde) + + if not prior_only: + k_obs = pm.Poisson("k", mu=pt.exp(f), observed=k) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/gp_regr.py b/posterior_database/models/pymc/gp_regr.py new file mode 100644 index 00000000..7b020b44 --- /dev/null +++ b/posterior_database/models/pymc/gp_regr.py @@ -0,0 +1,27 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + x = data['x'] + y = data['y'] + + x_arr = np.array(x, dtype=float) + x_reshaped = x_arr.reshape(-1, 1) + + with pm.Model() as model: + rho = pm.Gamma("rho", alpha=25, beta=4) + alpha = pm.HalfNormal("alpha", sigma=2) + sigma = pm.HalfNormal("sigma", sigma=1) + + sq_dist = (x_reshaped - x_reshaped.T)**2 + cov_gp = alpha**2 * pt.exp(-0.5 * sq_dist / rho**2) + cov = cov_gp + pt.diag(pt.full(N, sigma)) + L_cov = pt.linalg.cholesky(cov) + + if not prior_only: + y_obs = pm.MvNormal("y", mu=pt.zeros(N), chol=L_cov, observed=y) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/irt_2pl.py b/posterior_database/models/pymc/irt_2pl.py new file mode 100644 index 00000000..5dd9ad88 --- /dev/null +++ b/posterior_database/models/pymc/irt_2pl.py @@ -0,0 +1,25 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + I = data['I'] + J = data['J'] + y = data['y'] + + with pm.Model() as model: + sigma_theta = pm.HalfCauchy("sigma_theta", beta=2) + theta = pm.Normal("theta", mu=0, sigma=sigma_theta, shape=J) + sigma_a = pm.HalfCauchy("sigma_a", beta=2) + a = pm.LogNormal("a", mu=0, sigma=sigma_a, shape=I) + mu_b = pm.Normal("mu_b", mu=0, sigma=5) + sigma_b = pm.HalfCauchy("sigma_b", beta=2) + b = pm.Normal("b", mu=mu_b, sigma=sigma_b, shape=I) + + logit_p = a[:, None] * (theta[None, :] - b[:, None]) + + if not prior_only: + y_obs = pm.Bernoulli("y", logit_p=logit_p, observed=y) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/kidscore_interaction.py b/posterior_database/models/pymc/kidscore_interaction.py new file mode 100644 index 00000000..2c75c60c --- /dev/null +++ b/posterior_database/models/pymc/kidscore_interaction.py @@ -0,0 +1,23 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + kid_score = np.array(data['kid_score']) + mom_iq = np.array(data['mom_iq']) + mom_hs = np.array(data['mom_hs']) + + inter = mom_hs * mom_iq + + with pm.Model() as model: + beta = pm.Flat("beta", shape=4) + sigma = pm.HalfCauchy("sigma", beta=2.5) + + mu = beta[0] + beta[1] * mom_hs + beta[2] * mom_iq + beta[3] * inter + + if not prior_only: + pm.Normal("kid_score", mu=mu, sigma=sigma, observed=kid_score) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/kidscore_interaction_c.py b/posterior_database/models/pymc/kidscore_interaction_c.py new file mode 100644 index 00000000..2790f385 --- /dev/null +++ b/posterior_database/models/pymc/kidscore_interaction_c.py @@ -0,0 +1,24 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + kid_score = data['kid_score'] + mom_hs = data['mom_hs'] + mom_iq = data['mom_iq'] + c_mom_hs = mom_hs - np.mean(mom_hs) + c_mom_iq = mom_iq - np.mean(mom_iq) + inter = c_mom_hs * c_mom_iq + + with pm.Model() as model: + beta = pm.Flat("beta", shape=4) + sigma = pm.HalfFlat("sigma") + + mu = beta[0] + beta[1] * c_mom_hs + beta[2] * c_mom_iq + beta[3] * inter + + if not prior_only: + pm.Normal("kid_score", mu=mu, sigma=sigma, observed=kid_score) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/kidscore_interaction_c2.py b/posterior_database/models/pymc/kidscore_interaction_c2.py new file mode 100644 index 00000000..805e41aa --- /dev/null +++ b/posterior_database/models/pymc/kidscore_interaction_c2.py @@ -0,0 +1,25 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + kid_score = np.array(data['kid_score']) + mom_hs = np.array(data['mom_hs']) + mom_iq = np.array(data['mom_iq']) + + c2_mom_hs = mom_hs - 0.5 + c2_mom_iq = mom_iq - 100.0 + inter = c2_mom_hs * c2_mom_iq + + with pm.Model() as model: + beta = pm.Flat("beta", shape=4) + sigma = pm.HalfFlat("sigma") + + mu = pm.Deterministic("mu", beta[0] + beta[1] * c2_mom_hs + beta[2] * c2_mom_iq + beta[3] * inter) + + if not prior_only: + pm.Normal("kid_score", mu=mu, sigma=sigma, observed=kid_score) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/kidscore_interaction_z.py b/posterior_database/models/pymc/kidscore_interaction_z.py new file mode 100644 index 00000000..56f09338 --- /dev/null +++ b/posterior_database/models/pymc/kidscore_interaction_z.py @@ -0,0 +1,25 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + kid_score = data['kid_score'] + mom_hs = data['mom_hs'] + mom_iq = data['mom_iq'] + + z_mom_hs = (mom_hs - np.mean(mom_hs)) / (2 * np.std(mom_hs, ddof=0)) + z_mom_iq = (mom_iq - np.mean(mom_iq)) / (2 * np.std(mom_iq, ddof=0)) + inter = z_mom_hs * z_mom_iq + + with pm.Model() as model: + beta = pm.Flat("beta", shape=4) + sigma = pm.HalfFlat("sigma") + + mu = beta[0] + beta[1] * z_mom_hs + beta[2] * z_mom_iq + beta[3] * inter + + if not prior_only: + pm.Normal("kid_score", mu=mu, sigma=sigma, observed=kid_score) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/kidscore_mom_work.py b/posterior_database/models/pymc/kidscore_mom_work.py new file mode 100644 index 00000000..498e3718 --- /dev/null +++ b/posterior_database/models/pymc/kidscore_mom_work.py @@ -0,0 +1,24 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + kid_score = data['kid_score'] + mom_work = data['mom_work'] + + work2 = np.array(mom_work == 2, dtype=float) + work3 = np.array(mom_work == 3, dtype=float) + work4 = np.array(mom_work == 4, dtype=float) + + with pm.Model() as model: + beta = pm.Flat("beta", shape=4) + sigma = pm.HalfFlat("sigma") + + mu = pm.Deterministic("mu", beta[0] + beta[1] * work2 + beta[2] * work3 + beta[3] * work4) + + if not prior_only: + kid_score_obs = pm.Normal("kid_score", mu=mu, sigma=sigma, observed=kid_score) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/kidscore_momhs.py b/posterior_database/models/pymc/kidscore_momhs.py new file mode 100644 index 00000000..9dd9fab2 --- /dev/null +++ b/posterior_database/models/pymc/kidscore_momhs.py @@ -0,0 +1,16 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + beta = pm.Flat("beta", shape=2) + sigma = pm.HalfCauchy("sigma", beta=2.5) + + mu = pm.Deterministic("mu", beta[0] + beta[1] * data["mom_hs"]) + + if not prior_only: + kid_score_obs = pm.Normal("kid_score", mu=mu, sigma=sigma, observed=data["kid_score"]) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/kidscore_momhsiq.py b/posterior_database/models/pymc/kidscore_momhsiq.py new file mode 100644 index 00000000..df0820ff --- /dev/null +++ b/posterior_database/models/pymc/kidscore_momhsiq.py @@ -0,0 +1,16 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + beta = pm.Flat("beta", shape=3) + sigma = pm.HalfCauchy("sigma", beta=2.5) + + mu = pm.Deterministic("mu", beta[0] + beta[1] * data["mom_hs"] + beta[2] * data["mom_iq"]) + + if not prior_only: + pm.Normal("kid_score", mu=mu, sigma=sigma, observed=data["kid_score"]) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/kidscore_momiq.py b/posterior_database/models/pymc/kidscore_momiq.py new file mode 100644 index 00000000..1989e6e0 --- /dev/null +++ b/posterior_database/models/pymc/kidscore_momiq.py @@ -0,0 +1,16 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + beta = pm.Flat("beta", shape=2) + sigma = pm.HalfCauchy("sigma", beta=2.5) + + mu = beta[0] + beta[1] * data['mom_iq'] + + if not prior_only: + kid_score_obs = pm.Normal("kid_score", mu=mu, sigma=sigma, observed=data['kid_score']) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/kilpisjarvi.py b/posterior_database/models/pymc/kilpisjarvi.py new file mode 100644 index 00000000..6132c491 --- /dev/null +++ b/posterior_database/models/pymc/kilpisjarvi.py @@ -0,0 +1,26 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + N = data['N'] + x = data['x'] + y = data['y'] + xpred = data['xpred'] + pmualpha = data['pmualpha'] + psalpha = data['psalpha'] + pmubeta = data['pmubeta'] + psbeta = data['psbeta'] + + alpha = pm.Normal("alpha", mu=pmualpha, sigma=psalpha) + beta = pm.Normal("beta", mu=pmubeta, sigma=psbeta) + sigma = pm.HalfFlat("sigma") + + mu = alpha + beta * x + + if not prior_only: + y_obs = pm.Normal("y", mu=mu, sigma=sigma, observed=y) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/log10earn_height.py b/posterior_database/models/pymc/log10earn_height.py new file mode 100644 index 00000000..ee45f598 --- /dev/null +++ b/posterior_database/models/pymc/log10earn_height.py @@ -0,0 +1,22 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + earn = data['earn'] + height = data['height'] + + log10_earn = np.log10(earn) + + with pm.Model() as model: + beta = pm.Flat("beta", shape=2) + sigma = pm.HalfFlat("sigma") + + mu = beta[0] + beta[1] * height + + if not prior_only: + pm.Normal("log10_earn", mu=mu, sigma=sigma, observed=log10_earn) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/logearn_height_male.py b/posterior_database/models/pymc/logearn_height_male.py new file mode 100644 index 00000000..4d54e379 --- /dev/null +++ b/posterior_database/models/pymc/logearn_height_male.py @@ -0,0 +1,23 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + earn = data['earn'] + height = data['height'] + male = data['male'] + + log_earn = np.log(earn) + + with pm.Model() as model: + beta = pm.Flat("beta", shape=3) + sigma = pm.HalfFlat("sigma") + + mu = beta[0] + beta[1] * height + beta[2] * male + + if not prior_only: + log_earn_obs = pm.Normal("log_earn", mu=mu, sigma=sigma, observed=log_earn) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/logearn_interaction.py b/posterior_database/models/pymc/logearn_interaction.py new file mode 100644 index 00000000..1702ae1a --- /dev/null +++ b/posterior_database/models/pymc/logearn_interaction.py @@ -0,0 +1,24 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + earn = np.array(data['earn'], dtype=float) + height = np.array(data['height'], dtype=float) + male = np.array(data['male'], dtype=float) + + log_earn = np.log(earn) + inter = height * male + + with pm.Model() as model: + beta = pm.Flat("beta", shape=4) + sigma = pm.HalfFlat("sigma") + + mu = pm.Deterministic("mu", beta[0] + beta[1] * height + beta[2] * male + beta[3] * inter) + + if not prior_only: + log_earn_obs = pm.Normal("log_earn", mu=mu, sigma=sigma, observed=log_earn) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/logearn_interaction_z.py b/posterior_database/models/pymc/logearn_interaction_z.py new file mode 100644 index 00000000..e161acd0 --- /dev/null +++ b/posterior_database/models/pymc/logearn_interaction_z.py @@ -0,0 +1,25 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + earn = data['earn'] + height = data['height'] + male = data['male'] + + log_earn = np.log(earn) + z_height = (height - np.mean(height)) / np.std(height) + inter = z_height * male + + with pm.Model() as model: + beta = pm.Flat("beta", shape=4) + sigma = pm.HalfFlat("sigma") + + mu = pm.Deterministic("mu", beta[0] + beta[1] * z_height + beta[2] * male + beta[3] * inter) + + if not prior_only: + pm.Normal("log_earn", mu=mu, sigma=sigma, observed=log_earn) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/logearn_logheight_male.py b/posterior_database/models/pymc/logearn_logheight_male.py new file mode 100644 index 00000000..0105d934 --- /dev/null +++ b/posterior_database/models/pymc/logearn_logheight_male.py @@ -0,0 +1,19 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + log_earn = np.log(data['earn']) + log_height = np.log(data['height']) + + with pm.Model() as model: + beta = pm.Flat("beta", shape=3) + sigma = pm.HalfFlat("sigma") + + mu = beta[0] + beta[1] * log_height + beta[2] * data['male'] + + if not prior_only: + log_earn_obs = pm.Normal("log_earn", mu=mu, sigma=sigma, observed=log_earn) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/logistic_regression_rhs.py b/posterior_database/models/pymc/logistic_regression_rhs.py new file mode 100644 index 00000000..d41a3fb3 --- /dev/null +++ b/posterior_database/models/pymc/logistic_regression_rhs.py @@ -0,0 +1,34 @@ +import pymc as pm +import pytensor.tensor as pt + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + n = data['n'] + d = data['d'] + y = data['y'] + x = data['x'] + scale_icept = data['scale_icept'] + scale_global = data['scale_global'] + nu_global = data['nu_global'] + nu_local = data['nu_local'] + slab_scale = data['slab_scale'] + slab_df = data['slab_df'] + + with pm.Model() as model: + beta0 = pm.Normal("beta0", mu=0, sigma=scale_icept) + z = pm.Normal("z", mu=0, sigma=1, shape=d) + + tau = pm.HalfStudentT("tau", nu=nu_global, sigma=scale_global * 2) + lambda_ = pm.HalfStudentT("lambda", nu=nu_local, sigma=1, shape=d) + caux = pm.InverseGamma("caux", alpha=0.5 * slab_df, beta=0.5 * slab_df) + + c = slab_scale * pt.sqrt(caux) + lambda_tilde = pt.sqrt(c**2 * lambda_**2 / (c**2 + tau**2 * lambda_**2)) + beta = pm.Deterministic("beta", z * lambda_tilde * tau) + + logit_p = pm.Deterministic("logit_p", beta0 + x @ beta) + + if not prior_only: + pm.Bernoulli("y", logit_p=logit_p, observed=y) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/logmesquite_logvas.py b/posterior_database/models/pymc/logmesquite_logvas.py new file mode 100644 index 00000000..f72d2808 --- /dev/null +++ b/posterior_database/models/pymc/logmesquite_logvas.py @@ -0,0 +1,37 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + weight = np.array(data['weight']) + diam1 = np.array(data['diam1']) + diam2 = np.array(data['diam2']) + canopy_height = np.array(data['canopy_height']) + total_height = np.array(data['total_height']) + density = np.array(data['density'], dtype=float) + group = np.array(data['group'], dtype=float) + + log_weight = np.log(weight) + log_canopy_volume = np.log(diam1 * diam2 * canopy_height) + log_canopy_area = np.log(diam1 * diam2) + log_canopy_shape = np.log(diam1 / diam2) + log_total_height = np.log(total_height) + log_density = np.log(density) + + with pm.Model() as model: + beta = pm.Flat("beta", shape=7) + sigma = pm.HalfFlat("sigma") + + mu = (beta[0] + + beta[1] * log_canopy_volume + + beta[2] * log_canopy_area + + beta[3] * log_canopy_shape + + beta[4] * log_total_height + + beta[5] * log_density + + beta[6] * group) + + if not prior_only: + log_weight_obs = pm.Normal("log_weight", mu=mu, sigma=sigma, observed=log_weight) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/logmesquite_logvash.py b/posterior_database/models/pymc/logmesquite_logvash.py new file mode 100644 index 00000000..0420d40b --- /dev/null +++ b/posterior_database/models/pymc/logmesquite_logvash.py @@ -0,0 +1,36 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + weight = np.array(data['weight']) + diam1 = np.array(data['diam1']) + diam2 = np.array(data['diam2']) + canopy_height = np.array(data['canopy_height']) + total_height = np.array(data['total_height']) + group = np.array(data['group']) + + log_weight = np.log(weight) + log_canopy_volume = np.log(diam1 * diam2 * canopy_height) + log_canopy_area = np.log(diam1 * diam2) + log_canopy_shape = np.log(diam1 / diam2) + log_total_height = np.log(total_height) + + with pm.Model() as model: + beta = pm.Flat("beta", shape=6) + + sigma_log = pm.Flat("sigma_log") + sigma = pm.Deterministic("sigma", pt.exp(sigma_log)) + + mu = pm.Deterministic("mu", beta[0] + beta[1] * log_canopy_volume + + beta[2] * log_canopy_area + + beta[3] * log_canopy_shape + + beta[4] * log_total_height + + beta[5] * group) + + if not prior_only: + pm.Normal("log_weight", mu=mu, sigma=sigma, observed=log_weight) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/low_dim_gauss_mix.py b/posterior_database/models/pymc/low_dim_gauss_mix.py new file mode 100644 index 00000000..cf96cd9d --- /dev/null +++ b/posterior_database/models/pymc/low_dim_gauss_mix.py @@ -0,0 +1,22 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + N = data['N'] + y_data = data['y'] + + mu = pm.Normal("mu", mu=0, sigma=2, shape=2, transform=pm.distributions.transforms.ordered) + sigma = pm.HalfNormal("sigma", sigma=2, shape=2) + theta = pm.Beta("theta", alpha=5, beta=5) + + w = pt.stack([theta, 1 - theta]) + mu_components = pt.stack([mu[0], mu[1]]) + sigma_components = pt.stack([sigma[0], sigma[1]]) + + if not prior_only: + y_obs = pm.NormalMixture("y", w=w, mu=mu_components, sigma=sigma_components, observed=y_data) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/low_dim_gauss_mix_collapse.py b/posterior_database/models/pymc/low_dim_gauss_mix_collapse.py new file mode 100644 index 00000000..10b3423d --- /dev/null +++ b/posterior_database/models/pymc/low_dim_gauss_mix_collapse.py @@ -0,0 +1,20 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + N = data['N'] + y = data['y'] + + mu = pm.Normal("mu", mu=0, sigma=2, shape=2) + sigma = pm.HalfNormal("sigma", sigma=2, shape=2) + theta = pm.Beta("theta", alpha=5, beta=5) + + w = pt.stack([theta, 1 - theta]) + + if not prior_only: + pm.NormalMixture("y", w=w, mu=mu, sigma=sigma, observed=y) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/lsat_model.py b/posterior_database/models/pymc/lsat_model.py new file mode 100644 index 00000000..d57b5350 --- /dev/null +++ b/posterior_database/models/pymc/lsat_model.py @@ -0,0 +1,32 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + R = data['R'] + T = data['T'] + culm = data['culm'] + response = data['response'] + + culm = np.array(culm) + response = np.array(response) + + counts = np.diff(np.concatenate([[0], culm])) + r = np.repeat(response, counts, axis=0).T + + with pm.Model() as model: + alpha = pm.Normal("alpha", mu=0, sigma=100, shape=T) + theta = pm.Normal("theta", mu=0, sigma=1, shape=N) + beta = pm.HalfNormal("beta", sigma=100) + + logit_p = beta * theta[None, :] - alpha[:, None] + + if not prior_only: + pm.Bernoulli("r", logit_p=logit_p, observed=r) + + mean_alpha = pm.Deterministic("mean_alpha", pt.mean(alpha)) + a = pm.Deterministic("a", alpha - mean_alpha) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/mesquite.py b/posterior_database/models/pymc/mesquite.py new file mode 100644 index 00000000..017733f6 --- /dev/null +++ b/posterior_database/models/pymc/mesquite.py @@ -0,0 +1,27 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + N = data['N'] + weight = data['weight'] + diam1 = data['diam1'] + diam2 = data['diam2'] + canopy_height = data['canopy_height'] + total_height = data['total_height'] + density = data['density'] + group = data['group'] + + beta = pm.Flat("beta", shape=7) + sigma = pm.HalfFlat("sigma") + + mu = pm.Deterministic("mu", beta[0] + beta[1] * diam1 + beta[2] * diam2 + + beta[3] * canopy_height + beta[4] * total_height + + beta[5] * density + beta[6] * group) + + if not prior_only: + pm.Normal("weight", mu=mu, sigma=sigma, observed=weight) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/nes_logit_model.py b/posterior_database/models/pymc/nes_logit_model.py new file mode 100644 index 00000000..b541c04b --- /dev/null +++ b/posterior_database/models/pymc/nes_logit_model.py @@ -0,0 +1,21 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + income = np.array(data['income']) + vote = np.array(data['vote']) + x = income.reshape(-1, 1) + + with pm.Model() as model: + alpha = pm.Flat("alpha") + beta = pm.Flat("beta") + + logit_p = alpha + (x * beta).flatten() + + if not prior_only: + vote_obs = pm.Bernoulli("vote", logit_p=logit_p, observed=vote) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/normal_mixture.py b/posterior_database/models/pymc/normal_mixture.py new file mode 100644 index 00000000..6a89b7c8 --- /dev/null +++ b/posterior_database/models/pymc/normal_mixture.py @@ -0,0 +1,19 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + N = data['N'] + y_data = data['y'] + + theta = pm.Uniform('theta', lower=0, upper=1) + mu = pm.Normal('mu', mu=0, sigma=10, shape=2) + + w = pt.stack([theta, 1 - theta]) + + if not prior_only: + pm.NormalMixture('y', w=w, mu=mu, sigma=1.0, observed=y_data) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/normal_mixture_k.py b/posterior_database/models/pymc/normal_mixture_k.py new file mode 100644 index 00000000..31fda4bd --- /dev/null +++ b/posterior_database/models/pymc/normal_mixture_k.py @@ -0,0 +1,18 @@ +import pymc as pm +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + K = data['K'] + N = data['N'] + y = data['y'] + + with pm.Model() as model: + theta = pm.Dirichlet("theta", a=np.ones(K)) + mu = pm.Normal("mu", mu=0, sigma=10, shape=K) + sigma = pm.Uniform("sigma", lower=0, upper=10, shape=K) + + if not prior_only: + y_obs = pm.NormalMixture("y", w=theta, mu=mu, sigma=sigma, observed=y) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/pilots.py b/posterior_database/models/pymc/pilots.py new file mode 100644 index 00000000..b9cc41f5 --- /dev/null +++ b/posterior_database/models/pymc/pilots.py @@ -0,0 +1,28 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + group_idx = np.array(data['group_id']) - 1 + scenario_idx = np.array(data['scenario_id']) - 1 + + with pm.Model() as model: + mu_a = pm.Normal("mu_a", mu=0, sigma=1) + sigma_a = pm.Uniform("sigma_a", lower=0, upper=100) + + a = pm.Normal("a", mu=10 * mu_a, sigma=sigma_a, shape=data['n_groups']) + + mu_b = pm.Normal("mu_b", mu=0, sigma=1) + sigma_b = pm.Uniform("sigma_b", lower=0, upper=100) + + b = pm.Normal("b", mu=10 * mu_b, sigma=sigma_b, shape=data['n_scenarios']) + + sigma_y = pm.Uniform("sigma_y", lower=0, upper=100) + + y_hat = a[group_idx] + b[scenario_idx] + + if not prior_only: + y_obs = pm.Normal("y", mu=y_hat, sigma=sigma_y, observed=data['y']) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/radon_county.py b/posterior_database/models/pymc/radon_county.py new file mode 100644 index 00000000..cd5a5b0a --- /dev/null +++ b/posterior_database/models/pymc/radon_county.py @@ -0,0 +1,25 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + J = data['J'] + county = np.array(data['county']) - 1 + y_obs = np.array(data['y']) + + with pm.Model() as model: + + mu_a = pm.Normal("mu_a", mu=0, sigma=1) + sigma_a = pm.Uniform("sigma_a", lower=0, upper=100) + sigma_y = pm.Uniform("sigma_y", lower=0, upper=100) + + a = pm.Normal("a", mu=mu_a, sigma=sigma_a, shape=J) + + y_hat = a[county] + + if not prior_only: + pm.Normal("y", mu=y_hat, sigma=sigma_y, observed=y_obs) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/radon_county_intercept.py b/posterior_database/models/pymc/radon_county_intercept.py new file mode 100644 index 00000000..3610e9f0 --- /dev/null +++ b/posterior_database/models/pymc/radon_county_intercept.py @@ -0,0 +1,24 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + J = data['J'] + county_idx = np.array(data['county_idx']) - 1 + floor_measure = np.array(data['floor_measure']) + log_radon = np.array(data['log_radon']) + + with pm.Model() as model: + + alpha = pm.Normal("alpha", mu=0, sigma=10, shape=J) + beta = pm.Normal("beta", mu=0, sigma=10) + sigma_y = pm.TruncatedNormal("sigma_y", mu=0, sigma=1, lower=0) + + mu = alpha[county_idx] + beta * floor_measure + + if not prior_only: + y_obs = pm.Normal("log_radon", mu=mu, sigma=sigma_y, observed=log_radon) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/radon_hierarchical_intercept_centered.py b/posterior_database/models/pymc/radon_hierarchical_intercept_centered.py new file mode 100644 index 00000000..eddedcc1 --- /dev/null +++ b/posterior_database/models/pymc/radon_hierarchical_intercept_centered.py @@ -0,0 +1,28 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + J = data['J'] + county_idx = np.array(data['county_idx']) - 1 + log_uppm = np.array(data['log_uppm']) + floor_measure = np.array(data['floor_measure']) + log_radon = np.array(data['log_radon']) + + with pm.Model() as model: + sigma_alpha = pm.TruncatedNormal("sigma_alpha", mu=0, sigma=1, lower=0) + sigma_y = pm.TruncatedNormal("sigma_y", mu=0, sigma=1, lower=0) + mu_alpha = pm.Normal("mu_alpha", mu=0, sigma=10) + beta = pm.Normal("beta", mu=0, sigma=10, shape=2) + + alpha = pm.Normal("alpha", mu=mu_alpha, sigma=sigma_alpha, shape=J) + + muj = alpha[county_idx] + log_uppm * beta[0] + mu = muj + floor_measure * beta[1] + + if not prior_only: + y_obs = pm.Normal("y_obs", mu=mu, sigma=sigma_y, observed=log_radon) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/radon_hierarchical_intercept_noncentered.py b/posterior_database/models/pymc/radon_hierarchical_intercept_noncentered.py new file mode 100644 index 00000000..f31557be --- /dev/null +++ b/posterior_database/models/pymc/radon_hierarchical_intercept_noncentered.py @@ -0,0 +1,29 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + J = data['J'] + county_idx = np.array(data['county_idx']) - 1 + log_uppm = np.array(data['log_uppm']) + floor_measure = np.array(data['floor_measure']) + log_radon = np.array(data['log_radon']) + + with pm.Model() as model: + alpha_raw = pm.Normal("alpha_raw", mu=0, sigma=1, shape=J) + beta = pm.Normal("beta", mu=0, sigma=10, shape=2) + mu_alpha = pm.Normal("mu_alpha", mu=0, sigma=10) + sigma_alpha = pm.HalfNormal("sigma_alpha", sigma=1) + sigma_y = pm.HalfNormal("sigma_y", sigma=1) + + alpha = pm.Deterministic("alpha", mu_alpha + sigma_alpha * alpha_raw) + + muj = alpha[county_idx] + log_uppm * beta[0] + mu = pm.Deterministic("mu", muj + floor_measure * beta[1]) + + if not prior_only: + pm.Normal("log_radon", mu=mu, sigma=sigma_y, observed=log_radon) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/radon_partially_pooled_centered.py b/posterior_database/models/pymc/radon_partially_pooled_centered.py new file mode 100644 index 00000000..51504fa0 --- /dev/null +++ b/posterior_database/models/pymc/radon_partially_pooled_centered.py @@ -0,0 +1,24 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + J = data['J'] + county_idx = np.array(data['county_idx']) - 1 + log_radon = data['log_radon'] + + with pm.Model() as model: + sigma_y = pm.HalfNormal("sigma_y", sigma=1) + sigma_alpha = pm.HalfNormal("sigma_alpha", sigma=1) + mu_alpha = pm.Normal("mu_alpha", mu=0, sigma=10) + + alpha = pm.Normal("alpha", mu=mu_alpha, sigma=sigma_alpha, shape=J) + + mu = alpha[county_idx] + + if not prior_only: + pm.Normal("log_radon", mu=mu, sigma=sigma_y, observed=log_radon) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/radon_pooled.py b/posterior_database/models/pymc/radon_pooled.py new file mode 100644 index 00000000..2ab49502 --- /dev/null +++ b/posterior_database/models/pymc/radon_pooled.py @@ -0,0 +1,21 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False): + + N = data['N'] + floor_measure = data['floor_measure'] + log_radon = data['log_radon'] + + with pm.Model() as model: + alpha = pm.Normal("alpha", mu=0, sigma=10) + beta = pm.Normal("beta", mu=0, sigma=10) + sigma_y = pm.HalfNormal("sigma_y", sigma=1) + + mu = pm.Deterministic("mu", alpha + beta * floor_measure) + + if not prior_only: + pm.Normal("log_radon", mu=mu, sigma=sigma_y, observed=log_radon) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/radon_variable_intercept_centered.py b/posterior_database/models/pymc/radon_variable_intercept_centered.py new file mode 100644 index 00000000..c8fa960a --- /dev/null +++ b/posterior_database/models/pymc/radon_variable_intercept_centered.py @@ -0,0 +1,24 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + county_idx_0based = np.array(data['county_idx']) - 1 + floor_measure = np.array(data['floor_measure']) + + with pm.Model() as model: + sigma_y = pm.HalfNormal("sigma_y", sigma=1) + sigma_alpha = pm.HalfNormal("sigma_alpha", sigma=1) + mu_alpha = pm.Normal("mu_alpha", mu=0, sigma=10) + beta = pm.Normal("beta", mu=0, sigma=10) + + alpha = pm.Normal("alpha", mu=mu_alpha, sigma=sigma_alpha, shape=data['J']) + + mu = alpha[county_idx_0based] + floor_measure * beta + + if not prior_only: + log_radon_obs = pm.Normal("log_radon", mu=mu, sigma=sigma_y, + observed=data['log_radon']) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/radon_variable_intercept_noncentered.py b/posterior_database/models/pymc/radon_variable_intercept_noncentered.py new file mode 100644 index 00000000..fd83fd5f --- /dev/null +++ b/posterior_database/models/pymc/radon_variable_intercept_noncentered.py @@ -0,0 +1,27 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + J = data['J'] + county_idx = np.array(data['county_idx']) - 1 + floor_measure = np.array(data['floor_measure']) + log_radon = np.array(data['log_radon']) + + with pm.Model() as model: + alpha_raw = pm.Normal("alpha_raw", mu=0, sigma=1, shape=J) + beta = pm.Normal("beta", mu=0, sigma=10) + mu_alpha = pm.Normal("mu_alpha", mu=0, sigma=10) + sigma_alpha = pm.TruncatedNormal("sigma_alpha", mu=0, sigma=1, lower=0) + sigma_y = pm.TruncatedNormal("sigma_y", mu=0, sigma=1, lower=0) + + alpha = pm.Deterministic("alpha", mu_alpha + sigma_alpha * alpha_raw) + + mu = alpha[county_idx] + floor_measure * beta + + if not prior_only: + pm.Normal("log_radon", mu=mu, sigma=sigma_y, observed=log_radon) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/radon_variable_intercept_slope_centered.py b/posterior_database/models/pymc/radon_variable_intercept_slope_centered.py new file mode 100644 index 00000000..eaed9735 --- /dev/null +++ b/posterior_database/models/pymc/radon_variable_intercept_slope_centered.py @@ -0,0 +1,29 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + J = data['J'] + county_idx = np.array(data['county_idx']) - 1 + floor_measure = np.array(data['floor_measure']) + log_radon = np.array(data['log_radon']) + + with pm.Model() as model: + sigma_y = pm.TruncatedNormal("sigma_y", mu=0, sigma=1, lower=0) + sigma_alpha = pm.TruncatedNormal("sigma_alpha", mu=0, sigma=1, lower=0) + sigma_beta = pm.TruncatedNormal("sigma_beta", mu=0, sigma=1, lower=0) + + mu_alpha = pm.Normal("mu_alpha", mu=0, sigma=10) + mu_beta = pm.Normal("mu_beta", mu=0, sigma=10) + + alpha = pm.Normal("alpha", mu=mu_alpha, sigma=sigma_alpha, shape=J) + beta = pm.Normal("beta", mu=mu_beta, sigma=sigma_beta, shape=J) + + mu = alpha[county_idx] + floor_measure * beta[county_idx] + + if not prior_only: + y_obs = pm.Normal("log_radon", mu=mu, sigma=sigma_y, observed=log_radon) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/radon_variable_intercept_slope_noncentered.py b/posterior_database/models/pymc/radon_variable_intercept_slope_noncentered.py new file mode 100644 index 00000000..73d24841 --- /dev/null +++ b/posterior_database/models/pymc/radon_variable_intercept_slope_noncentered.py @@ -0,0 +1,33 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + J = data['J'] + county_idx = np.array(data['county_idx']) - 1 + floor_measure = np.array(data['floor_measure']) + log_radon = np.array(data['log_radon']) + + with pm.Model() as model: + + sigma_y = pm.HalfNormal("sigma_y", sigma=1) + sigma_alpha = pm.HalfNormal("sigma_alpha", sigma=1) + sigma_beta = pm.HalfNormal("sigma_beta", sigma=1) + + mu_alpha = pm.Normal("mu_alpha", mu=0, sigma=10) + mu_beta = pm.Normal("mu_beta", mu=0, sigma=10) + + alpha_raw = pm.Normal("alpha_raw", mu=0, sigma=1, shape=J) + beta_raw = pm.Normal("beta_raw", mu=0, sigma=1, shape=J) + + alpha = pm.Deterministic("alpha", mu_alpha + sigma_alpha * alpha_raw) + beta = pm.Deterministic("beta", mu_beta + sigma_beta * beta_raw) + + mu = pm.Deterministic("mu", alpha[county_idx] + floor_measure * beta[county_idx]) + + if not prior_only: + pm.Normal("log_radon", mu=mu, sigma=sigma_y, observed=log_radon) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/rats_model.py b/posterior_database/models/pymc/rats_model.py new file mode 100644 index 00000000..8dbc93bd --- /dev/null +++ b/posterior_database/models/pymc/rats_model.py @@ -0,0 +1,33 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + Npts = data['Npts'] + rat = np.array(data['rat']) - 1 + x = np.array(data['x']) + y = np.array(data['y']) + xbar = data['xbar'] + + with pm.Model() as model: + + mu_alpha = pm.Normal("mu_alpha", mu=0, sigma=100) + mu_beta = pm.Normal("mu_beta", mu=0, sigma=100) + + sigma_y = pm.HalfFlat("sigma_y") + sigma_alpha = pm.HalfFlat("sigma_alpha") + sigma_beta = pm.HalfFlat("sigma_beta") + + alpha = pm.Normal("alpha", mu=mu_alpha, sigma=sigma_alpha, shape=N) + beta = pm.Normal("beta", mu=mu_beta, sigma=sigma_beta, shape=N) + + mu_y = pm.Deterministic("mu_y", alpha[rat] + beta[rat] * (x - xbar)) + + if not prior_only: + y_obs = pm.Normal("y", mu=mu_y, sigma=sigma_y, observed=y) + + alpha0 = pm.Deterministic("alpha0", mu_alpha - xbar * mu_beta) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/seeds_centered_model.py b/posterior_database/models/pymc/seeds_centered_model.py new file mode 100644 index 00000000..a27bb11c --- /dev/null +++ b/posterior_database/models/pymc/seeds_centered_model.py @@ -0,0 +1,32 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + I = data['I'] + n = np.array(data['n']) + N = np.array(data['N']) + x1 = np.array(data['x1'], dtype=float) + x2 = np.array(data['x2'], dtype=float) + + x1x2 = x1 * x2 + + with pm.Model() as model: + alpha0 = pm.Normal("alpha0", mu=0.0, sigma=1.0) + alpha1 = pm.Normal("alpha1", mu=0.0, sigma=1.0) + alpha12 = pm.Normal("alpha12", mu=0.0, sigma=1.0) + alpha2 = pm.Normal("alpha2", mu=0.0, sigma=1.0) + + sigma = pm.HalfCauchy("sigma", beta=1.0) + + c = pm.Normal("c", mu=0.0, sigma=sigma, shape=I) + + b = pm.Deterministic("b", c - pt.mean(c)) + + eta = alpha0 + alpha1 * x1 + alpha2 * x2 + alpha12 * x1x2 + b + + if not prior_only: + n_obs = pm.Binomial("n", n=N, logit_p=eta, observed=n) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/seeds_model.py b/posterior_database/models/pymc/seeds_model.py new file mode 100644 index 00000000..4a2d880f --- /dev/null +++ b/posterior_database/models/pymc/seeds_model.py @@ -0,0 +1,31 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + I = data['I'] + n = np.array(data['n']) + N = np.array(data['N']) + x1 = np.array(data['x1']) + x2 = np.array(data['x2']) + + x1x2 = x1 * x2 + + with pm.Model() as model: + alpha0 = pm.Normal("alpha0", mu=0.0, sigma=1000.0) + alpha1 = pm.Normal("alpha1", mu=0.0, sigma=1000.0) + alpha2 = pm.Normal("alpha2", mu=0.0, sigma=1000.0) + alpha12 = pm.Normal("alpha12", mu=0.0, sigma=1000.0) + + tau = pm.Gamma("tau", alpha=1e-3, beta=1e-3) + sigma = pm.Deterministic("sigma", 1.0 / pt.sqrt(tau)) + + b = pm.Normal("b", mu=0.0, sigma=sigma, shape=I) + + linear_pred = alpha0 + alpha1 * x1 + alpha2 * x2 + alpha12 * x1x2 + b + + if not prior_only: + n_obs = pm.Binomial("n", n=N, logit_p=linear_pred, observed=n) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/seeds_stanified_model.py b/posterior_database/models/pymc/seeds_stanified_model.py new file mode 100644 index 00000000..a43dfd56 --- /dev/null +++ b/posterior_database/models/pymc/seeds_stanified_model.py @@ -0,0 +1,30 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + I = data['I'] + n = np.array(data['n']) + N = np.array(data['N']) + x1 = np.array(data['x1']) + x2 = np.array(data['x2']) + + x1x2 = x1 * x2 + + with pm.Model() as model: + alpha0 = pm.Normal("alpha0", mu=0.0, sigma=1.0) + alpha1 = pm.Normal("alpha1", mu=0.0, sigma=1.0) + alpha2 = pm.Normal("alpha2", mu=0.0, sigma=1.0) + alpha12 = pm.Normal("alpha12", mu=0.0, sigma=1.0) + + sigma = pm.HalfCauchy("sigma", beta=1.0) + + b = pm.Normal("b", mu=0.0, sigma=sigma, shape=I) + + logit_p = alpha0 + alpha1 * x1 + alpha2 * x2 + alpha12 * x1x2 + b + + if not prior_only: + n_obs = pm.Binomial("n", n=N, logit_p=logit_p, observed=n) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/sesame_one_pred_a.py b/posterior_database/models/pymc/sesame_one_pred_a.py new file mode 100644 index 00000000..43901c39 --- /dev/null +++ b/posterior_database/models/pymc/sesame_one_pred_a.py @@ -0,0 +1,19 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + encouraged = np.array(data['encouraged']) + watched_data = np.array(data['watched'], dtype=float) + + with pm.Model() as model: + beta = pm.Flat("beta", shape=2) + sigma = pm.HalfFlat("sigma") + + mu = pm.Deterministic("mu", beta[0] + beta[1] * encouraged) + + if not prior_only: + pm.Normal("watched", mu=mu, sigma=sigma, observed=watched_data) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/wells_daae_c_model.py b/posterior_database/models/pymc/wells_daae_c_model.py new file mode 100644 index 00000000..0528f08e --- /dev/null +++ b/posterior_database/models/pymc/wells_daae_c_model.py @@ -0,0 +1,28 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + switched = np.array(data['switched']) + dist = np.array(data['dist']) + arsenic = np.array(data['arsenic']) + assoc = np.array(data['assoc']) + educ = np.array(data['educ']) + c_dist100 = (dist - np.mean(dist)) / 100.0 + c_arsenic = arsenic - np.mean(arsenic) + da_inter = c_dist100 * c_arsenic + educ4 = educ / 4.0 + x = np.column_stack([c_dist100, c_arsenic, da_inter, assoc, educ4]) + + with pm.Model() as model: + alpha = pm.Flat("alpha") + beta = pm.Flat("beta", shape=5) + + logit_p = pm.Deterministic("logit_p", alpha + x @ beta) + + if not prior_only: + pm.Bernoulli("switched", logit_p=logit_p, observed=switched) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/wells_dae_c_model.py b/posterior_database/models/pymc/wells_dae_c_model.py new file mode 100644 index 00000000..618ea64a --- /dev/null +++ b/posterior_database/models/pymc/wells_dae_c_model.py @@ -0,0 +1,27 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + switched = np.array(data['switched']) + dist = np.array(data['dist']) + arsenic = np.array(data['arsenic']) + educ = np.array(data['educ']) + c_dist100 = (dist - np.mean(dist)) / 100.0 + c_arsenic = arsenic - np.mean(arsenic) + da_inter = c_dist100 * c_arsenic + educ4 = educ / 4.0 + x = np.column_stack([c_dist100, c_arsenic, da_inter, educ4]) + + with pm.Model() as model: + alpha = pm.Flat("alpha") + beta = pm.Flat("beta", shape=4) + + eta = alpha + x @ beta + + if not prior_only: + y_obs = pm.Bernoulli("switched", logit_p=eta, observed=switched) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/wells_dae_inter_model.py b/posterior_database/models/pymc/wells_dae_inter_model.py new file mode 100644 index 00000000..e0a950bc --- /dev/null +++ b/posterior_database/models/pymc/wells_dae_inter_model.py @@ -0,0 +1,29 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + switched = data['switched'] + dist = data['dist'] + arsenic = data['arsenic'] + educ = data['educ'] + c_dist100 = (dist - np.mean(dist)) / 100.0 + c_arsenic = arsenic - np.mean(arsenic) + c_educ4 = (educ - np.mean(educ)) / 4.0 + da_inter = c_dist100 * c_arsenic + de_inter = c_dist100 * c_educ4 + ae_inter = c_arsenic * c_educ4 + x = np.column_stack([c_dist100, c_arsenic, c_educ4, da_inter, de_inter, ae_inter]) + + with pm.Model() as model: + alpha = pm.Flat("alpha") + beta = pm.Flat("beta", shape=6) + + eta = alpha + x @ beta + + if not prior_only: + switched_obs = pm.Bernoulli("switched", logit_p=eta, observed=switched) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/wells_dae_model.py b/posterior_database/models/pymc/wells_dae_model.py new file mode 100644 index 00000000..37906cf0 --- /dev/null +++ b/posterior_database/models/pymc/wells_dae_model.py @@ -0,0 +1,27 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + switched = np.array(data['switched']) + dist = np.array(data['dist']) + arsenic = np.array(data['arsenic']) + educ = np.array(data['educ']) + + dist100 = dist / 100.0 + educ4 = educ / 4.0 + + x = np.column_stack([dist100, arsenic, educ4]) + + with pm.Model() as model: + alpha = pm.Flat("alpha") + beta = pm.Flat("beta", shape=3) + + eta = pm.Deterministic("eta", alpha + x @ beta) + + if not prior_only: + switched_obs = pm.Bernoulli("switched", logit_p=eta, observed=switched) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/wells_dist.py b/posterior_database/models/pymc/wells_dist.py new file mode 100644 index 00000000..4b700750 --- /dev/null +++ b/posterior_database/models/pymc/wells_dist.py @@ -0,0 +1,19 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + with pm.Model() as model: + N = data['N'] + switched = data['switched'] + dist = data['dist'] + + beta = pm.Flat("beta", shape=2) + + logit_p = beta[0] + beta[1] * dist + + if not prior_only: + switched_obs = pm.Bernoulli("switched", logit_p=logit_p, observed=switched) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/wells_dist100_model.py b/posterior_database/models/pymc/wells_dist100_model.py new file mode 100644 index 00000000..9715d655 --- /dev/null +++ b/posterior_database/models/pymc/wells_dist100_model.py @@ -0,0 +1,20 @@ +import pymc as pm +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + switched = data['switched'] + dist = np.array(data['dist']) + dist100 = dist / 100.0 + + with pm.Model() as model: + alpha = pm.Flat("alpha") + beta = pm.Flat("beta") + + logit_p = alpha + dist100 * beta + + if not prior_only: + pm.Bernoulli("switched", logit_p=logit_p, observed=switched) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/wells_dist100ars_model.py b/posterior_database/models/pymc/wells_dist100ars_model.py new file mode 100644 index 00000000..80bf971b --- /dev/null +++ b/posterior_database/models/pymc/wells_dist100ars_model.py @@ -0,0 +1,23 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + switched = data['switched'] + dist = np.array(data['dist']) + arsenic = np.array(data['arsenic']) + dist100 = dist / 100.0 + x = np.column_stack([dist100, arsenic]) + + with pm.Model() as model: + alpha = pm.Flat("alpha") + beta = pm.Flat("beta", shape=2) + + eta = pm.Deterministic("eta", alpha + x @ beta) + + if not prior_only: + switched_obs = pm.Bernoulli("switched", logit_p=eta, observed=switched) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/wells_interaction_c_model.py b/posterior_database/models/pymc/wells_interaction_c_model.py new file mode 100644 index 00000000..47b94531 --- /dev/null +++ b/posterior_database/models/pymc/wells_interaction_c_model.py @@ -0,0 +1,25 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + switched = data['switched'] + dist = data['dist'] + arsenic = data['arsenic'] + c_dist100 = (dist - np.mean(dist)) / 100.0 + c_arsenic = arsenic - np.mean(arsenic) + inter = c_dist100 * c_arsenic + x = np.column_stack([c_dist100, c_arsenic, inter]) + + with pm.Model() as model: + alpha = pm.Flat("alpha") + beta = pm.Flat("beta", shape=3) + + logit_p = alpha + x @ beta + + if not prior_only: + switched_obs = pm.Bernoulli("switched", logit_p=logit_p, observed=switched) + + return model \ No newline at end of file diff --git a/posterior_database/models/pymc/wells_interaction_model.py b/posterior_database/models/pymc/wells_interaction_model.py new file mode 100644 index 00000000..a3e4a092 --- /dev/null +++ b/posterior_database/models/pymc/wells_interaction_model.py @@ -0,0 +1,26 @@ +import pymc as pm +import pytensor.tensor as pt +import numpy as np + +def make_model(data: dict, prior_only: bool = False) -> pm.Model: + + N = data['N'] + switched = np.array(data['switched']) + dist = np.array(data['dist']) + arsenic = np.array(data['arsenic']) + + dist100 = dist / 100.0 + inter = dist100 * arsenic + + X = np.column_stack([dist100, arsenic, inter]) + + with pm.Model() as model: + alpha = pm.Flat("alpha") + beta = pm.Flat("beta", shape=3) + + logit_p = alpha + X @ beta + + if not prior_only: + switched_obs = pm.Bernoulli("switched", logit_p=logit_p, observed=switched) + + return model \ No newline at end of file