{"id":14066461,"url":"https://github.com/tidymodels/multilevelmod","last_synced_at":"2025-04-04T10:04:23.234Z","repository":{"id":37091115,"uuid":"258349675","full_name":"tidymodels/multilevelmod","owner":"tidymodels","description":"Parsnip wrappers for mixed-level and hierarchical models","archived":false,"fork":false,"pushed_at":"2024-10-17T13:48:01.000Z","size":3290,"stargazers_count":74,"open_issues_count":14,"forks_count":4,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-28T09:03:30.943Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://multilevelmod.tidymodels.org/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tidymodels.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-23T22:54:06.000Z","updated_at":"2024-10-17T13:46:05.000Z","dependencies_parsed_at":"2023-02-01T08:31:18.719Z","dependency_job_id":"9dcc8f36-ad8a-4ddd-82b8-9f41642e40fa","html_url":"https://github.com/tidymodels/multilevelmod","commit_stats":{"total_commits":94,"total_committers":8,"mean_commits":11.75,"dds":"0.44680851063829785","last_synced_commit":"62e41058f906b7a1f3315cda2c88064affa7dc2a"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fmultilevelmod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fmultilevelmod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fmultilevelmod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fmultilevelmod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tidymodels","download_url":"https://codeload.github.com/tidymodels/multilevelmod/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247152917,"owners_count":20892579,"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":[],"created_at":"2024-08-13T07:05:06.691Z","updated_at":"2025-04-04T10:04:23.209Z","avatar_url":"https://github.com/tidymodels.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r}\n#| include: false\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# multilevelmod \u003ca href=\"https://multilevelmod.tidymodels.org/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" alt=\"3 nesting dolls on an orange background\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)\n[![Codecov test coverage](https://codecov.io/gh/tidymodels/multilevelmod/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/multilevelmod?branch=main)\n[![R-CMD-check](https://github.com/tidymodels/multilevelmod/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/multilevelmod/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\nmultilevelmod enables the use of multi-level models (a.k.a mixed-effects models, Bayesian hierarchical models, etc.) with the parsnip package.  \n\n\u003ca href=\"https://pbs.twimg.com/media/FD1_OIhVIAE4H5l?format=jpg\u0026name=small\"\u003e\u003cimg src=\"man/figures/FD1_OIhVIAE4H5l.jpeg\" align=\"center\" alt=\"A sweaty Comic character trying to decide which button to push. The buttons read: 'mixed effect model', 'hierarchical linear model', 'random effects model', 'variance component model', 'mixed model', 'random intercepts/slopes', 'regularized regression', 'multilevel model', 'nested data model', and 'random parameter model'\". /\u003e\u003c/a\u003e\n\n(meme courtesy of [`@ChelseaParlett`](https://twitter.com/ChelseaParlett))\n\n## Installation\n\nYou can install the released version of multilevelmod from [CRAN](https://cran.r-project.org) with:\n\n``` r\ninstall.packages(\"multilevelmod\")\n```\n\nFor the development version: \n\n``` r\n# install.packages(\"pak\")\npak::pak(\"tidymodels/multilevelmod\")\n```\n\n## Available Engines\n\nThe multilevelmod package provides engines for the models in the following table.\n\n```{r}\n#| echo: false\n#| message: false\nlibrary(parsnip)\n\nparsnip_models \u003c- get_from_env(\"models\") %\u003e%\n  setNames(., .) %\u003e%\n  purrr::map_dfr(get_from_env, .id = \"model\")\n\nlibrary(multilevelmod)\n\nmultilevelmod_models \u003c- get_from_env(\"models\") %\u003e%\n  setNames(., .) %\u003e%\n  purrr::map_dfr(get_from_env, .id = \"model\")\n\ndplyr::anti_join(\n  multilevelmod_models, parsnip_models, \n  by = c(\"model\", \"engine\", \"mode\")\n) %\u003e%\n  knitr::kable()\n```\n\n## Example\n\nLoading mixedlevelmod will trigger it to add a few modeling _engines_ to the parsnip model database. For Bayesian models, there are now `stan-glmer` engines for `linear_reg()`, `logistic_reg()`, and `poisson_reg()`. \n\nTo use these, the function `parsnip::fit()` function should be used instead of `parsnip::fit_xy()` so that the model terms can be specified using the `lme`/`lme4` syntax. \n\nThe `sleepstudy` data is used as an example: \n\n```{r}\n#| label: sleep-lme\nlibrary(multilevelmod)\nset.seed(1234)\ndata(sleepstudy, package = \"lme4\")\n\nmixed_model_spec \u003c- linear_reg() %\u003e% set_engine(\"lmer\")\n\nmixed_model_fit \u003c- \n  mixed_model_spec %\u003e% \n  fit(Reaction ~ Days + (Days | Subject), data = sleepstudy)\n\nmixed_model_fit\n```\n\nFor a Bayesian model: \n\n\n```{r}\n#| label: sleep-stan\nhier_model_spec \u003c- linear_reg() %\u003e% set_engine(\"stan_glmer\")\n\nhier_model_fit \u003c- \n  hier_model_spec %\u003e% \n  fit(Reaction ~ Days + (Days | Subject), data = sleepstudy)\n\nhier_model_fit\n```\n\n## Contributing\n\nThis project is released with a [Contributor Code of Conduct](https://www.contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.\n\n- For questions and discussions about tidymodels packages, modeling, and machine learning, please [post on RStudio Community](https://community.rstudio.com/new-topic?category_id=15\u0026tags=tidymodels,question).\n\n- If you think you have encountered a bug, please [submit an issue](https://github.com/tidymodels/multilevelmod/issues).\n\n- Either way, learn how to create and share a [reprex](https://community.rstudio.com/new-topic?category_id=15\u0026tags=tidymodels,question) (a minimal, reproducible example), to clearly communicate about your code.\n\n- Check out further details on [contributing guidelines for tidymodels packages](https://www.tidymodels.org/contribute/) and [how to get help](https://www.tidymodels.org/help/).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidymodels%2Fmultilevelmod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftidymodels%2Fmultilevelmod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidymodels%2Fmultilevelmod/lists"}