{"id":16599943,"url":"https://github.com/dirmeier/modelframe","last_synced_at":"2025-04-04T23:25:27.516Z","repository":{"id":57442639,"uuid":"265076410","full_name":"dirmeier/modelframe","owner":"dirmeier","description":"Compute fixed and random effects model matrices in Python","archived":false,"fork":false,"pushed_at":"2020-05-30T23:41:07.000Z","size":476,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T09:37:06.773Z","etag":null,"topics":["design-matrix","hierarchical-models","mixed-models","model-matrix","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dirmeier.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}},"created_at":"2020-05-18T22:19:16.000Z","updated_at":"2020-05-30T23:34:18.000Z","dependencies_parsed_at":"2022-09-26T17:21:17.547Z","dependency_job_id":null,"html_url":"https://github.com/dirmeier/modelframe","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fmodelframe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fmodelframe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fmodelframe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fmodelframe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dirmeier","download_url":"https://codeload.github.com/dirmeier/modelframe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247263936,"owners_count":20910491,"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":["design-matrix","hierarchical-models","mixed-models","model-matrix","python"],"created_at":"2024-10-12T00:13:04.510Z","updated_at":"2025-04-04T23:25:27.498Z","avatar_url":"https://github.com/dirmeier.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"modelframe\n==========\n\n[![Project\nStatus](http://www.repostatus.org/badges/latest/concept.svg)](http://www.repostatus.org/#concept)\n[![travis](https://img.shields.io/travis/dirmeier/modelframe/master.svg?\u0026logo=travis)](https://travis-ci.org/dirmeier/modelframe/)\n[![codecov](https://codecov.io/gh/dirmeier/modelframe/branch/master/graph/badge.svg)](https://codecov.io/gh/dirmeier/modelframe)\n[![codacy](https://app.codacy.com/project/badge/Grade/c101def3b1d34481a3b72109852f4f8d)](https://www.codacy.com/manual/simon-dirmeier/modelframe?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=dirmeier/modelframe\u0026amp;utm_campaign=Badge_Grade)\n[![version](https://img.shields.io/pypi/v/modelframe.svg?colorB=black\u0026style=flat)](https://pypi.org/project/modelframe/)\n\n\u003e Compute fixed and random effects model matrices in Python\n\nAbout\n-----\n\n`modelframe` builds model matrices and response vectors from a given\ndataset using `lme4`-style formulas in Python. For instance, consider the `sleepstudy` data from\n[`lme4`](https://cran.r-project.org/web/packages/lme4/index.html):\n\n``` python\nfrom modelframe import model_frame, load_data\n\nsleepstudy = load_data()\nsleepstudy\n```\n\n    ##      Reaction  Days Subject\n    ## 0    249.5600     0     308\n    ## 1    258.7047     1     308\n    ## 2    250.8006     2     308\n    ## 3    321.4398     3     308\n    ## 4    356.8519     4     308\n    ## ..        ...   ...     ...\n    ## 175  329.6076     5     372\n    ## 176  334.4818     6     372\n    ## 177  343.2199     7     372\n    ## 178  369.1417     8     372\n    ## 179  364.1236     9     372\n    ## \n    ## [180 rows x 3 columns]\n\nComputing the model matrices is then as simple as:\n\n``` python\nframe = model_frame(\"~ Days + (Days | Subject)\", sleepstudy)\n```\n\nThe fixed effects model matrix:\n\n``` python\nframe.coef_model_matrix\n```\n\n    ##      Intercept  Days\n    ## 0          1.0     0\n    ## 1          1.0     1\n    ## 2          1.0     2\n    ## 3          1.0     3\n    ## 4          1.0     4\n    ## ..         ...   ...\n    ## 175        1.0     5\n    ## 176        1.0     6\n    ## 177        1.0     7\n    ## 178        1.0     8\n    ## 179        1.0     9\n    ## \n    ## [180 rows x 2 columns]\n\n\nThe random effects model matrix:\n\n``` python\nframe.ranef_model_matrix\n```\n\n    ##       Intercept Days Intercept Days  ... Intercept Days Intercept Days\n    ## group       308  308       309  309  ...       371  371       372  372\n    ## 0           1.0  0.0       0.0  0.0  ...       0.0  0.0       0.0  0.0\n    ## 1           1.0  1.0       0.0  0.0  ...       0.0  0.0       0.0  0.0\n    ## 2           1.0  2.0       0.0  0.0  ...       0.0  0.0       0.0  0.0\n    ## 3           1.0  3.0       0.0  0.0  ...       0.0  0.0       0.0  0.0\n    ## 4           1.0  4.0       0.0  0.0  ...       0.0  0.0       0.0  0.0\n    ## ..          ...  ...       ...  ...  ...       ...  ...       ...  ...\n    ## 175         0.0  0.0       0.0  0.0  ...       0.0  0.0       1.0  5.0\n    ## 176         0.0  0.0       0.0  0.0  ...       0.0  0.0       1.0  6.0\n    ## 177         0.0  0.0       0.0  0.0  ...       0.0  0.0       1.0  7.0\n    ## 178         0.0  0.0       0.0  0.0  ...       0.0  0.0       1.0  8.0\n    ## 179         0.0  0.0       0.0  0.0  ...       0.0  0.0       1.0  9.0\n    ## \n    ## [180 rows x 36 columns]\n\nInstallation\n------------\n\nYou can install `modelframe` either from PyPI using:\n\n```bash\npip install modelframe\n```\n\nor using the latest GitHub [release](https://github.com/dirmeier/modelframe/releases/):\n\n```bash\npython -m pip install git+https://github.com/dirmeier/modelframe.git\n```\n\n\n\nAuthor\n------\n\nSimon Dirmeier \u003ca href=\"mailto:simon.dirmeier @ gmx.de\"\u003esimon.dirmeier @ gmx.de\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirmeier%2Fmodelframe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirmeier%2Fmodelframe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirmeier%2Fmodelframe/lists"}