{"id":20766045,"url":"https://github.com/lamyj/slimp","last_synced_at":"2025-04-03T12:14:42.315Z","repository":{"id":223353445,"uuid":"760086954","full_name":"lamyj/slimp","owner":"lamyj","description":"Linear models with Stan and Pandas","archived":false,"fork":false,"pushed_at":"2025-02-10T19:13:57.000Z","size":385,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T19:50:39.463Z","etag":null,"topics":["bayesian","linear-models","matplotlib","pandas","stan","statistics"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lamyj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-19T19:00:10.000Z","updated_at":"2025-02-10T19:14:01.000Z","dependencies_parsed_at":"2024-02-19T20:30:31.451Z","dependency_job_id":"671d86a4-05ad-4cf8-8686-52b83ede2ba2","html_url":"https://github.com/lamyj/slimp","commit_stats":null,"previous_names":["lamyj/slimp"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamyj%2Fslimp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamyj%2Fslimp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamyj%2Fslimp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamyj%2Fslimp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamyj","download_url":"https://codeload.github.com/lamyj/slimp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246998218,"owners_count":20866696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bayesian","linear-models","matplotlib","pandas","stan","statistics"],"created_at":"2024-11-17T11:20:45.151Z","updated_at":"2025-04-03T12:14:42.289Z","avatar_url":"https://github.com/lamyj.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slimp: linear models with Stan and Pandas\n\n*slimp* estimates linear models using [Stan](https://mc-stan.org/) and [Pandas](https://pandas.pydata.org/). Think [rstanarm](https://mc-stan.org/rstanarm/) or [brms](https://mc-stan.org/users/interfaces/brms), but in Python and faster.\n\nCreate the model:\n\n```python\nimport matplotlib.pyplot\nimport numpy\nimport pandas\nimport slimp\n\ny, x = numpy.mgrid[0:10, 0:10]\nz = 10 + x + 2*y + numpy.random.normal(0, 2, (10, 10))\ndata = pandas.DataFrame({\"x\": x.ravel(), \"y\": y.ravel(), \"z\": z.ravel()})\n\nmodel = slimp.Model(\"z ~ 1 + x + y\", data, num_chains=4)\n# Also possible to specify random seed\n# model = slimp.Model(\"z ~ 1 + x + y\", data, seed=42)\n```\n\nSample the parameters, check the results:\n\n```python\nmodel.sample()\nprint(model.hmc_diagnostics)\nprint(model.summary()[[\"N_Eff\", \"R_hat\"]].describe().loc[[\"min\", \"max\"], :])\nr_squared = slimp.r_squared(model)\nprint(r_squared.quantile([0.05, 0.95]))\n```\n\nPlot prior and posterior predictive checks:\n\n```python\nfigure, plots = matplotlib.pyplot.subplots(1, 2, layout=\"tight\", figsize=(8, 4))\nslimp.predictive_plot(model, use_prior=True, plot_kwargs={\"ax\":plots[0]})\nslimp.predictive_plot(model, use_prior=False, plot_kwargs={\"ax\":plots[1]})\n```\n\nPlot the credible intervals of the parameters and their distributions:\n\n```\nslimp.parameters_plot(model, include=[\"x\", \"y\"])\nslimp.KDEPlot(model.draws[\"sigma\"], prob=0.90)\n```\n\nUse a custom Stan model: have a look [here](custom_model_example/README.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamyj%2Fslimp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamyj%2Fslimp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamyj%2Fslimp/lists"}