diff --git a/dev/news/index.html b/dev/news/index.html
index fff168c..3dfe73e 100644
--- a/dev/news/index.html
+++ b/dev/news/index.html
@@ -34,7 +34,8 @@
multilevelmod (development version)
-
+- Switched to cli for errors (#70).
+
multilevelmod 1.0.0
CRAN release: 2022-06-17
Maintainer change.
diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml
index 5c5f5a1..f548ca7 100644
--- a/dev/pkgdown.yml
+++ b/dev/pkgdown.yml
@@ -3,7 +3,7 @@ pkgdown: 2.1.1
pkgdown_sha: ~
articles:
multilevelmod: multilevelmod.html
-last_built: 2024-10-10T13:42Z
+last_built: 2024-10-10T13:44Z
urls:
reference: https://multilevelmod.tidymodels.org/reference
article: https://multilevelmod.tidymodels.org/articles
diff --git a/dev/search.json b/dev/search.json
index c0ddbd5..f179f5e 100644
--- a/dev/search.json
+++ b/dev/search.json
@@ -1 +1 @@
-[{"path":[]},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement codeofconduct@posit.co. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to multilevelmod","title":"Contributing to multilevelmod","text":"outlines propose change multilevelmod. detailed info contributing , tidyverse packages, please see development contributing guide.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"Contributing to multilevelmod","text":"can fix typos, spelling mistakes, grammatical errors documentation directly using GitHub web interface, long changes made source file. generally means ’ll need edit roxygen2 comments .R, .Rd file. can find .R file generates .Rd reading comment first line.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CONTRIBUTING.html","id":"bigger-changes","dir":"","previous_headings":"","what":"Bigger changes","title":"Contributing to multilevelmod","text":"want make bigger change, ’s good idea first file issue make sure someone team agrees ’s needed. ’ve found bug, please file issue illustrates bug minimal reprex (also help write unit test, needed).","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"Bigger changes","what":"Pull request process","title":"Contributing to multilevelmod","text":"Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"\", fork = TRUE). Install development dependences devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"Bigger changes","what":"Code style","title":"Contributing to multilevelmod","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to multilevelmod","text":"Please note multilevelmod project released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 multilevelmod authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/SUPPORT.html","id":null,"dir":"","previous_headings":"","what":"Getting help with multilevelmod","title":"Getting help with multilevelmod","text":"Thanks using multilevelmod! filing issue, places explore pieces put together make process smooth possible.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/SUPPORT.html","id":"make-a-reprex","dir":"","previous_headings":"","what":"Make a reprex","title":"Getting help with multilevelmod","text":"Start making minimal reproducible example using reprex package. haven’t heard used reprex , ’re treat! Seriously, reprex make R-question-asking endeavors easier (pretty insane ROI five ten minutes ’ll take learn ’s ). additional reprex pointers, check Get help! section tidyverse site.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/SUPPORT.html","id":"where-to-ask","dir":"","previous_headings":"","what":"Where to ask?","title":"Getting help with multilevelmod","text":"Armed reprex, next step figure ask. ’s question: start community.rstudio.com, /StackOverflow. people answer questions. ’s bug: ’re right place, file issue. ’re sure: let community help figure ! problem bug feature request, can easily return report . opening new issue, sure search issues pull requests make sure bug hasn’t reported /already fixed development version. default, search pre-populated :issue :open. can edit qualifiers (e.g. :pr, :closed) needed. example, ’d simply remove :open search issues repo, open closed.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/SUPPORT.html","id":"what-happens-next","dir":"","previous_headings":"","what":"What happens next?","title":"Getting help with multilevelmod","text":"efficient possible, development tidyverse packages tends bursty, shouldn’t worry don’t get immediate response. Typically don’t look repo sufficient quantity issues accumulates, ’s burst intense activity focus efforts. makes development efficient avoids expensive context switching problems, cost taking longer get back . process makes good reprex particularly important might multiple months initial report start working . can’t reproduce bug, can’t fix !","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/articles/multilevelmod.html","id":"generalized-estimator-equations-gee","dir":"Articles","previous_headings":"","what":"Generalized estimator equations (GEE)","title":"Get Started","text":"engine requires gee package installed. random effects model. Like generalized least squares model discussed , model deals within-subject correlations estimating correlation (covariance) matrix diagonal. , model formula use id_var() function. special syntax creating model matrices (actual id_var() function) designates column independent experimental unit. correlation structure can passed engine argument: single column name can given id_var(). predicting, id_var column required:","code":"gee_spec <- linear_reg() %>% set_engine(\"gee\", corstr = \"exchangeable\") gee_fit <- gee_spec %>% fit(Reaction ~ Days + id_var(Subject), data = sleepstudy) ## Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27 ## running glm to get initial regression estimate gee_fit ## parsnip model object ## ## ## GEE: GENERALIZED LINEAR MODELS FOR DEPENDENT DATA ## gee S-function, version 4.13 modified 98/01/27 (1998) ## ## Model: ## Link: Identity ## Variance to Mean Relation: Gaussian ## Correlation Structure: Exchangeable ## ## Call: ## gee::gee(formula = Reaction ~ Days, id = data$Subject, data = data, ## family = gaussian, corstr = \"exchangeable\") ## ## Number of observations : 180 ## ## Maximum cluster size : 10 ## ## ## Coefficients: ## (Intercept) Days ## 251.40510 10.46729 ## ## Estimated Scale Parameter: 2276.694 ## Number of Iterations: 1 ## ## Working Correlation[1:4,1:4] ## [,1] [,2] [,3] [,4] ## [1,] 1.0000000 0.5710385 0.5710385 0.5710385 ## [2,] 0.5710385 1.0000000 0.5710385 0.5710385 ## [3,] 0.5710385 0.5710385 1.0000000 0.5710385 ## [4,] 0.5710385 0.5710385 0.5710385 1.0000000 ## ## ## Returned Error Value: ## [1] 0 predict(gee_fit, new_subject %>% select(Days)) %>% bind_cols(new_subject) ## # A tibble: 10 × 3 ## .pred Days Subject ## ## 1 251. 0 one ## 2 262. 1 one ## 3 272. 2 one ## 4 283. 3 one ## 5 293. 4 one ## 6 304. 5 one ## 7 314. 6 one ## 8 325. 7 one ## 9 335. 8 one ## 10 346. 9 one"},{"path":"https://multilevelmod.tidymodels.org/dev/articles/multilevelmod.html","id":"generalized-least-squares","dir":"Articles","previous_headings":"","what":"Generalized least squares","title":"Get Started","text":"engine requires nlme package installed. model, syntax specify independent experimental unit inside corrrelation argument nlme::gls(). ’ll pass engine argument. Possible values can found using ?nlme::corStruct. example: GEE model, regression terms required prediction:","code":"library(nlme) # <- Only need to load this to get cor*() functions gls_spec <- linear_reg() %>% set_engine(\"gls\", correlation = corCompSymm(form = ~ 1 | Subject)) gls_fit <- gls_spec %>% fit(Reaction ~ Days, data = sleepstudy) gls_fit ## parsnip model object ## ## Generalized least squares fit by REML ## Model: Reaction ~ Days ## Data: data ## Log-restricted-likelihood: -893.2325 ## ## Coefficients: ## (Intercept) Days ## 251.40510 10.46729 ## ## Correlation Structure: Compound symmetry ## Formula: ~1 | Subject ## Parameter estimate(s): ## Rho ## 0.5893103 ## Degrees of freedom: 180 total; 178 residual ## Residual standard error: 48.3595 predict(gls_fit, new_subject %>% select(Days)) %>% bind_cols(new_subject) ## # A tibble: 10 × 3 ## .pred Days Subject ## ## 1 251. 0 one ## 2 262. 1 one ## 3 272. 2 one ## 4 283. 3 one ## 5 293. 4 one ## 6 304. 5 one ## 7 314. 6 one ## 8 325. 7 one ## 9 335. 8 one ## 10 346. 9 one"},{"path":"https://multilevelmod.tidymodels.org/dev/articles/multilevelmod.html","id":"linear-mixed-effects-via-lme","dir":"Articles","previous_headings":"","what":"Linear mixed effects via lme","title":"Get Started","text":"engine requires nlme package installed. models created nlme::lme(), random effects specified argument called random. can passed via set_engine(). formula specified fit() include fixed effects model. fit basic random intercept model: predictions, tidymodels uses “population effects”, .e., -subject specific random effects. designed tidymodels know specific training set values making type prediction. lme fit objects, subject column, given, ignored. underlying predict() function used, level = 0 argument automatically invoked:","code":"lme_spec <- linear_reg() %>% set_engine(\"lme\", random = ~ 1 | Subject) lme_fit <- lme_spec %>% fit(Reaction ~ Days, data = sleepstudy) lme_fit ## parsnip model object ## ## Linear mixed-effects model fit by REML ## Data: data ## Log-restricted-likelihood: -893.2325 ## Fixed: Reaction ~ Days ## (Intercept) Days ## 251.40510 10.46729 ## ## Random effects: ## Formula: ~1 | Subject ## (Intercept) Residual ## StdDev: 37.12383 30.99123 ## ## Number of Observations: 180 ## Number of Groups: 18 predict(lme_fit, new_subject) %>% bind_cols(new_subject) ## # A tibble: 10 × 3 ## .pred Days Subject ## ## 1 251. 0 one ## 2 262. 1 one ## 3 272. 2 one ## 4 283. 3 one ## 5 293. 4 one ## 6 304. 5 one ## 7 314. 6 one ## 8 325. 7 one ## 9 335. 8 one ## 10 346. 9 one # For this design, this is the same prediction as a training set point: predict(lme_fit, sleepstudy %>% filter(Subject == \"308\")) ## # A tibble: 10 × 1 ## .pred ## ## 1 251. ## 2 262. ## 3 272. ## 4 283. ## 5 293. ## 6 304. ## 7 314. ## 8 325. ## 9 335. ## 10 346."},{"path":"https://multilevelmod.tidymodels.org/dev/articles/multilevelmod.html","id":"models-using-lmer-glmer-and-stan_glmer","dir":"Articles","previous_headings":"","what":"Models using lmer, glmer, and stan_glmer","title":"Get Started","text":"\"lmer\", \"glmer\", \"stan_glmer\" engines use formula syntax fitting multilevel models. See Section 2.1 Linear Mixed Models lme4 details. section, ’ll demonstrate using \"lmer\" engine. model specification occurs formula; models terms specified via set_engine() (although arguments can passed , usual). fit random intercept model, syntax : predict way. determine packages required model, use function: \"stan_glmer\" engine, relevant arguments can passed set_engine() : chains: positive integer specifying number Markov chains. default 4. iter: positive integer specifying number iterations chain (including warmup). default 2000. seed: seed random number generation. cores: Number cores use executing chains parallel. prior: prior distribution (non-hierarchical) regression coefficients. prior_intercept: prior distribution intercept (centering predictors). See ?rstanarm::stan_glmer ?rstan::sampling information.","code":"lmer_spec <- linear_reg() %>% set_engine(\"lmer\") lmer_fit <- lmer_spec %>% fit(Reaction ~ Days + (1|Subject), data = sleepstudy) lmer_fit ## parsnip model object ## ## Linear mixed model fit by REML ['lmerMod'] ## Formula: Reaction ~ Days + (1 | Subject) ## Data: data ## REML criterion at convergence: 1786.465 ## Random effects: ## Groups Name Std.Dev. ## Subject (Intercept) 37.12 ## Residual 30.99 ## Number of obs: 180, groups: Subject, 18 ## Fixed Effects: ## (Intercept) Days ## 251.41 10.47 predict(lmer_fit, new_subject) %>% bind_cols(new_subject) ## # A tibble: 10 × 3 ## .pred Days Subject ## ## 1 251. 0 one ## 2 262. 1 one ## 3 272. 2 one ## 4 283. 3 one ## 5 293. 4 one ## 6 304. 5 one ## 7 314. 6 one ## 8 325. 7 one ## 9 335. 8 one ## 10 346. 9 one required_pkgs(lmer_spec) ## [1] \"parsnip\" \"lme4\" \"multilevelmod\""},{"path":"https://multilevelmod.tidymodels.org/dev/articles/multilevelmod.html","id":"using-tidymodels-workflows","dir":"Articles","previous_headings":"","what":"Using tidymodels workflows","title":"Get Started","text":"use workflows, suggestions. First, instead using add_formula(), suggest using add_variables(). passes columns -model fitting function. add random effects formula, use formula argument add_model(). example: using recipe, make sure functions like step_dummy() convert column independent experimental unit (.e. subject) dummy variables. underlying model fit functions require single column data. Using recipe also offers opportunity set different role independent experiment unit, can come handy complex preprocessing needed.","code":"lmer_wflow <- workflow() %>% add_variables(outcomes = Reaction, predictors = c(Days, Subject)) %>% add_model(lmer_spec, formula = Reaction ~ Days + (1|Subject)) lmer_wflow %>% fit(data = sleepstudy) ## ══ Workflow [trained] ════════════════════════════════════════════════════ ## Preprocessor: Variables ## Model: linear_reg() ## ## ── Preprocessor ────────────────────────────────────────────────────────── ## Outcomes: Reaction ## Predictors: c(Days, Subject) ## ## ── Model ───────────────────────────────────────────────────────────────── ## Linear mixed model fit by REML ['lmerMod'] ## Formula: Reaction ~ Days + (1 | Subject) ## Data: data ## REML criterion at convergence: 1786.465 ## Random effects: ## Groups Name Std.Dev. ## Subject (Intercept) 37.12 ## Residual 30.99 ## Number of obs: 180, groups: Subject, 18 ## Fixed Effects: ## (Intercept) Days ## 251.41 10.47 rec <- recipe(Reaction ~ Days + Subject, data = sleepstudy) %>% add_role(Subject, new_role = \"exp_unit\") %>% step_zv(all_predictors(), -has_role(\"exp_unit\")) lmer_wflow %>% remove_variables() %>% add_recipe(rec) %>% fit(data = sleepstudy) ## ══ Workflow [trained] ════════════════════════════════════════════════════ ## Preprocessor: Recipe ## Model: linear_reg() ## ## ── Preprocessor ────────────────────────────────────────────────────────── ## 1 Recipe Step ## ## • step_zv() ## ## ── Model ───────────────────────────────────────────────────────────────── ## Linear mixed model fit by REML ['lmerMod'] ## Formula: Reaction ~ Days + (1 | Subject) ## Data: data ## REML criterion at convergence: 1786.465 ## Random effects: ## Groups Name Std.Dev. ## Subject (Intercept) 37.12 ## Residual 30.99 ## Number of obs: 180, groups: Subject, 18 ## Fixed Effects: ## (Intercept) Days ## 251.41 10.47"},{"path":"https://multilevelmod.tidymodels.org/dev/articles/multilevelmod.html","id":"other-tips","dir":"Articles","previous_headings":"","what":"Other tips","title":"Get Started","text":"Finally, excellent helper functions broom.mixed tidybayes packages. need underlying model fit object: extract_fit_engine() function can used either parsnip workflow objects:","code":"lmer_wflow %>% fit(data = sleepstudy) %>% # <- returns a workflow extract_fit_engine() # <- returns the lmer object ## Linear mixed model fit by REML ['lmerMod'] ## Formula: Reaction ~ Days + (1 | Subject) ## Data: data ## REML criterion at convergence: 1786.465 ## Random effects: ## Groups Name Std.Dev. ## Subject (Intercept) 37.12 ## Residual 30.99 ## Number of obs: 180, groups: Subject, 18 ## Fixed Effects: ## (Intercept) Days ## 251.41 10.47"},{"path":"https://multilevelmod.tidymodels.org/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Max Kuhn. Author. Hannah Frick. Author, maintainer. . Copyright holder, funder.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Kuhn M, Frick H (2024). multilevelmod: Model Wrappers Multi-Level Models. R package version 1.0.0.9000, http://multilevelmod.tidymodels.org/, https://github.com/tidymodels/multilevelmod.","code":"@Manual{, title = {multilevelmod: Model Wrappers for Multi-Level Models}, author = {Max Kuhn and Hannah Frick}, year = {2024}, note = {R package version 1.0.0.9000, http://multilevelmod.tidymodels.org/}, url = {https://github.com/tidymodels/multilevelmod}, }"},{"path":"https://multilevelmod.tidymodels.org/dev/index.html","id":"multilevelmod-","dir":"","previous_headings":"","what":"Model Wrappers for Multi-Level Models","title":"Model Wrappers for Multi-Level Models","text":"multilevelmod enables use multi-level models (.k.mixed-effects models, Bayesian hierarchical models, etc.) parsnip package. (meme courtesy @ChelseaParlett)","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Model Wrappers for Multi-Level Models","text":"can install released version multilevelmod CRAN : development version:","code":"install.packages(\"multilevelmod\") # install.packages(\"pak\") pak::pak(\"tidymodels/multilevelmod\")"},{"path":"https://multilevelmod.tidymodels.org/dev/index.html","id":"available-engines","dir":"","previous_headings":"","what":"Available Engines","title":"Model Wrappers for Multi-Level Models","text":"multilevelmod package provides engines models following table.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Model Wrappers for Multi-Level Models","text":"Loading mixedlevelmod trigger add modeling engines parsnip model database. Bayesian models, now stan-glmer engines linear_reg(), logistic_reg(), poisson_reg(). use , function parsnip::fit() function used instead parsnip::fit_xy() model terms can specified using lme/lme4 syntax. sleepstudy data used example: Bayesian model:","code":"library(multilevelmod) set.seed(1234) data(sleepstudy, package = \"lme4\") mixed_model_spec <- linear_reg() %>% set_engine(\"lmer\") mixed_model_fit <- mixed_model_spec %>% fit(Reaction ~ Days + (Days | Subject), data = sleepstudy) mixed_model_fit #> parsnip model object #> #> Linear mixed model fit by REML ['lmerMod'] #> Formula: Reaction ~ Days + (Days | Subject) #> Data: data #> REML criterion at convergence: 1743.628 #> Random effects: #> Groups Name Std.Dev. Corr #> Subject (Intercept) 24.741 #> Days 5.922 0.07 #> Residual 25.592 #> Number of obs: 180, groups: Subject, 18 #> Fixed Effects: #> (Intercept) Days #> 251.41 10.47 hier_model_spec <- linear_reg() %>% set_engine(\"stan_glmer\") hier_model_fit <- hier_model_spec %>% fit(Reaction ~ Days + (Days | Subject), data = sleepstudy) hier_model_fit #> parsnip model object #> #> stan_glmer #> family: gaussian [identity] #> formula: Reaction ~ Days + (Days | Subject) #> observations: 180 #> ------ #> Median MAD_SD #> (Intercept) 251.3 6.5 #> Days 10.5 1.7 #> #> Auxiliary parameter(s): #> Median MAD_SD #> sigma 25.9 1.6 #> #> Error terms: #> Groups Name Std.Dev. Corr #> Subject (Intercept) 24.1 #> Days 6.9 0.09 #> Residual 26.0 #> Num. levels: Subject 18 #> #> ------ #> * For help interpreting the printed output see ?print.stanreg #> * For info on the priors used see ?prior_summary.stanreg"},{"path":"https://multilevelmod.tidymodels.org/dev/index.html","id":"contributing","dir":"","previous_headings":"","what":"Contributing","title":"Model Wrappers for Multi-Level Models","text":"project released Contributor Code Conduct. contributing project, agree abide terms. questions discussions tidymodels packages, modeling, machine learning, please post RStudio Community. think encountered bug, please submit issue. Either way, learn create share reprex (minimal, reproducible example), clearly communicate code. Check details contributing guidelines tidymodels packages get help.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/gee_fit.html","id":null,"dir":"Reference","previous_headings":"","what":"GEE fitting function — gee_fit","title":"GEE fitting function — gee_fit","text":"Custom fitting function add GEE model cluster variable parsnip GEE function call.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/gee_fit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"GEE fitting function — gee_fit","text":"","code":"gee_fit(formula, data, family = gaussian, ...)"},{"path":"https://multilevelmod.tidymodels.org/dev/reference/gee_fit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"GEE fitting function — gee_fit","text":"formula Normal formula uses gee_formula() internal function id_var() specification clustering. data Modeling data family family object: list functions expressions defining link variance functions. Families supported gee gaussian, binomial, poisson, Gamma, quasi; see glm family documentation. links currently available: 1/mu^2 sqrt hard-coded cgee engine present. inverse gaussian variance function available. combinations remaining functions can obtained either family selection use quasi. ... additional parameters","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/gee_fit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"GEE fitting function — gee_fit","text":"gee object","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/gee_fit.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"GEE fitting function — gee_fit","text":"gee() always prints warnings output even silent = TRUE. gee_fit() never produce output, even silent = FALSE. Also, issues gee() function, supplementary call glm() needed get rank QR decomposition objects predict() can used.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/longitudinal_counts.html","id":null,"dir":"Reference","previous_headings":"","what":"Simulated longitudinal Poisson counts — longitudinal_counts","title":"Simulated longitudinal Poisson counts — longitudinal_counts","text":"Simulated longitudinal Poisson counts","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/longitudinal_counts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Simulated longitudinal Poisson counts — longitudinal_counts","text":"longitudinal_counts tibble","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/longitudinal_counts.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Simulated longitudinal Poisson counts — longitudinal_counts","text":"simulated data 100 subjects 10 time points additional numeric covariate. linear predictor random standard normal intercept per subject, time coefficient 1.50, covariate coefficient 0.25.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/longitudinal_counts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Simulated longitudinal Poisson counts — longitudinal_counts","text":"","code":"data(longitudinal_counts) str(longitudinal_counts) #> tibble [1,000 × 4] (S3: tbl_df/tbl/data.frame) #> $ subject: Factor w/ 100 levels \"1\",\"2\",\"3\",\"4\",..: 1 1 1 1 1 1 1 1 1 1 ... #> $ time : num [1:1000] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 ... #> $ x : num [1:1000] 2.56 2.69 2.68 2.49 2.29 ... #> $ y : int [1:1000] 0 0 3 2 0 1 0 2 3 0 ..."},{"path":"https://multilevelmod.tidymodels.org/dev/reference/msa_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Measurement systems analysis data — msa_data","title":"Measurement systems analysis data — msa_data","text":"Measurement systems analysis data","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/msa_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Measurement systems analysis data — msa_data","text":"msa_data tibble","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/msa_data.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Measurement systems analysis data — msa_data","text":"biological assay (.e. lab test) run 56 separate samples twice. goal measure percentage total variation results related measurement system much attributable true systematic difference (sample--sample).","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/msa_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Measurement systems analysis data — msa_data","text":"","code":"data(msa_data) str(msa_data) #> tibble [112 × 3] (S3: tbl_df/tbl/data.frame) #> $ id : chr [1:112] \"sample_001\" \"sample_001\" \"sample_002\" \"sample_002\" ... #> $ replicate: chr [1:112] \"rep_1\" \"rep_2\" \"rep_1\" \"rep_2\" ... #> $ value : num [1:112] 2.406 1.837 -0.674 -0.102 1.08 ..."},{"path":"https://multilevelmod.tidymodels.org/dev/reference/multilevelmod-package.html","id":null,"dir":"Reference","previous_headings":"","what":"parsnip methods for hierarchical models — multilevelmod-package","title":"parsnip methods for hierarchical models — multilevelmod-package","text":"multilevelmod allows users use parsnip package fit certain hierarchical models (e.g., linear, logistic, Poisson regression). package relies formula method specify random effects.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/multilevelmod-package.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"parsnip methods for hierarchical models — multilevelmod-package","text":"example, package includes simulated longitudinal data subjects measured time points. outcome number counts predictors time point well additional numeric covariate. can fit model using lme4::glmer(): making predictions, basic predict() method trick:","code":"library(tidymodels) library(multilevelmod) library(poissonreg) # current required for poisson_reg() # The lme4 package is required for this model. tidymodels_prefer() # Split out two subjects to show how prediction works data_train <- longitudinal_counts %>% filter(!(subject %in% c(\"1\", \"2\"))) data_new <- longitudinal_counts %>% filter(subject %in% c(\"1\", \"2\")) # Fit the model count_mod <- poisson_reg() %>% set_engine(\"glmer\") %>% fit(y ~ time + x + (1 | subject), data = data_train) count_mod #> parsnip model object #> #> Generalized linear mixed model fit by maximum likelihood (Laplace #> Approximation) [glmerMod] #> Family: poisson ( log ) #> Formula: y ~ time + x + (1 | subject) #> Data: data #> AIC BIC logLik deviance df.resid #> 4474.553 4494.104 -2233.277 4466.553 976 #> Random effects: #> Groups Name Std.Dev. #> subject (Intercept) 0.9394 #> Number of obs: 980, groups: subject, 98 #> Fixed Effects: #> (Intercept) time x #> -0.5946 1.5145 0.2395 count_mod %>% predict(data_new) #> # A tibble: 20 x 1 #> .pred #> #> 1 1.19 #> 2 1.42 #> 3 1.65 #> 4 1.83 #> 5 2.04 #> 6 2.66 #> 7 2.96 #> 8 3.43 #> 9 3.94 #> 10 4.64 #> 11 2.21 #> 12 2.60 #> 13 2.97 #> 14 3.38 #> 15 4.16 #> 16 4.90 #> 17 5.45 #> 18 6.20 #> 19 7.55 #> 20 8.64"},{"path":[]},{"path":"https://multilevelmod.tidymodels.org/dev/reference/multilevelmod-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"parsnip methods for hierarchical models — multilevelmod-package","text":"Maintainer: Hannah Frick hannah@posit.co (ORCID) Authors: Max Kuhn max@posit.co (ORCID) contributors: Posit Software, PBC [copyright holder, funder]","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/riesby.html","id":null,"dir":"Reference","previous_headings":"","what":"Imipramine longitudinal data — riesby","title":"Imipramine longitudinal data — riesby","text":"Imipramine longitudinal data","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/riesby.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Imipramine longitudinal data — riesby","text":"Reisby, N., Gram, L.F., Bech, P. et al. Imipramine: Clinical effects pharmacokinetic variability. Psychopharmacology 54, 263-272 (1977).","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/riesby.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Imipramine longitudinal data — riesby","text":"riesby tibble","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/riesby.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Imipramine longitudinal data — riesby","text":"data longitudinal clinical trial depression. outcome change depression scores week--week. endogenous column indicator whether subject fit Depression Scale classification endogenous. imipramine desipramine columns measurements plasma levels substances.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/riesby.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Imipramine longitudinal data — riesby","text":"","code":"data(riesby) str(riesby) #> tibble [250 × 7] (S3: tbl_df/tbl/data.frame) #> $ subject : Factor w/ 66 levels \"101\",\"103\",\"104\",..: 1 1 1 1 2 2 2 2 3 3 ... #> $ depr_score : num [1:250] -8 -19 -22 -23 -18 -9 -18 -20 -11 -16 ... #> $ week : num [1:250] 0 1 2 3 0 1 2 3 0 1 ... #> $ male : num [1:250] 0 0 0 0 1 1 1 1 1 1 ... #> $ endogenous : num [1:250] 0 0 0 0 0 0 0 0 1 1 ... #> $ imipramine : num [1:250] 4.04 3.93 4.33 4.37 2.77 ... #> $ desipramine: num [1:250] 4.2 4.81 4.96 4.96 5.24 ..."},{"path":[]},{"path":"https://multilevelmod.tidymodels.org/dev/news/index.html","id":"multilevelmod-100","dir":"Changelog","previous_headings":"","what":"multilevelmod 1.0.0","title":"multilevelmod 1.0.0","text":"CRAN release: 2022-06-17 Maintainer change. Fix lme4::lme() nested random effects. -difabio added glmer engine linear_reg().","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/news/index.html","id":"multilevelmod-020","dir":"Changelog","previous_headings":"","what":"multilevelmod 0.2.0","title":"multilevelmod 0.2.0","text":"CRAN release: 2022-05-03 vignette now uses sleepstudy data. Support case weights added linear_reg(engine = \"lmer\"), logistic_reg(engine = \"glmer\"), poisson_reg(engine = \"glmer\") (#28).","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/news/index.html","id":"multilevelmod-010","dir":"Changelog","previous_headings":"","what":"multilevelmod 0.1.0","title":"multilevelmod 0.1.0","text":"CRAN release: 2022-03-11 First CRAN release.","code":""}]
+[{"path":[]},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement codeofconduct@posit.co. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to multilevelmod","title":"Contributing to multilevelmod","text":"outlines propose change multilevelmod. detailed info contributing , tidyverse packages, please see development contributing guide.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"Contributing to multilevelmod","text":"can fix typos, spelling mistakes, grammatical errors documentation directly using GitHub web interface, long changes made source file. generally means ’ll need edit roxygen2 comments .R, .Rd file. can find .R file generates .Rd reading comment first line.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CONTRIBUTING.html","id":"bigger-changes","dir":"","previous_headings":"","what":"Bigger changes","title":"Contributing to multilevelmod","text":"want make bigger change, ’s good idea first file issue make sure someone team agrees ’s needed. ’ve found bug, please file issue illustrates bug minimal reprex (also help write unit test, needed).","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"Bigger changes","what":"Pull request process","title":"Contributing to multilevelmod","text":"Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"\", fork = TRUE). Install development dependences devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"Bigger changes","what":"Code style","title":"Contributing to multilevelmod","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to multilevelmod","text":"Please note multilevelmod project released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 multilevelmod authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/SUPPORT.html","id":null,"dir":"","previous_headings":"","what":"Getting help with multilevelmod","title":"Getting help with multilevelmod","text":"Thanks using multilevelmod! filing issue, places explore pieces put together make process smooth possible.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/SUPPORT.html","id":"make-a-reprex","dir":"","previous_headings":"","what":"Make a reprex","title":"Getting help with multilevelmod","text":"Start making minimal reproducible example using reprex package. haven’t heard used reprex , ’re treat! Seriously, reprex make R-question-asking endeavors easier (pretty insane ROI five ten minutes ’ll take learn ’s ). additional reprex pointers, check Get help! section tidyverse site.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/SUPPORT.html","id":"where-to-ask","dir":"","previous_headings":"","what":"Where to ask?","title":"Getting help with multilevelmod","text":"Armed reprex, next step figure ask. ’s question: start community.rstudio.com, /StackOverflow. people answer questions. ’s bug: ’re right place, file issue. ’re sure: let community help figure ! problem bug feature request, can easily return report . opening new issue, sure search issues pull requests make sure bug hasn’t reported /already fixed development version. default, search pre-populated :issue :open. can edit qualifiers (e.g. :pr, :closed) needed. example, ’d simply remove :open search issues repo, open closed.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/SUPPORT.html","id":"what-happens-next","dir":"","previous_headings":"","what":"What happens next?","title":"Getting help with multilevelmod","text":"efficient possible, development tidyverse packages tends bursty, shouldn’t worry don’t get immediate response. Typically don’t look repo sufficient quantity issues accumulates, ’s burst intense activity focus efforts. makes development efficient avoids expensive context switching problems, cost taking longer get back . process makes good reprex particularly important might multiple months initial report start working . can’t reproduce bug, can’t fix !","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/articles/multilevelmod.html","id":"generalized-estimator-equations-gee","dir":"Articles","previous_headings":"","what":"Generalized estimator equations (GEE)","title":"Get Started","text":"engine requires gee package installed. random effects model. Like generalized least squares model discussed , model deals within-subject correlations estimating correlation (covariance) matrix diagonal. , model formula use id_var() function. special syntax creating model matrices (actual id_var() function) designates column independent experimental unit. correlation structure can passed engine argument: single column name can given id_var(). predicting, id_var column required:","code":"gee_spec <- linear_reg() %>% set_engine(\"gee\", corstr = \"exchangeable\") gee_fit <- gee_spec %>% fit(Reaction ~ Days + id_var(Subject), data = sleepstudy) ## Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27 ## running glm to get initial regression estimate gee_fit ## parsnip model object ## ## ## GEE: GENERALIZED LINEAR MODELS FOR DEPENDENT DATA ## gee S-function, version 4.13 modified 98/01/27 (1998) ## ## Model: ## Link: Identity ## Variance to Mean Relation: Gaussian ## Correlation Structure: Exchangeable ## ## Call: ## gee::gee(formula = Reaction ~ Days, id = data$Subject, data = data, ## family = gaussian, corstr = \"exchangeable\") ## ## Number of observations : 180 ## ## Maximum cluster size : 10 ## ## ## Coefficients: ## (Intercept) Days ## 251.40510 10.46729 ## ## Estimated Scale Parameter: 2276.694 ## Number of Iterations: 1 ## ## Working Correlation[1:4,1:4] ## [,1] [,2] [,3] [,4] ## [1,] 1.0000000 0.5710385 0.5710385 0.5710385 ## [2,] 0.5710385 1.0000000 0.5710385 0.5710385 ## [3,] 0.5710385 0.5710385 1.0000000 0.5710385 ## [4,] 0.5710385 0.5710385 0.5710385 1.0000000 ## ## ## Returned Error Value: ## [1] 0 predict(gee_fit, new_subject %>% select(Days)) %>% bind_cols(new_subject) ## # A tibble: 10 × 3 ## .pred Days Subject ## ## 1 251. 0 one ## 2 262. 1 one ## 3 272. 2 one ## 4 283. 3 one ## 5 293. 4 one ## 6 304. 5 one ## 7 314. 6 one ## 8 325. 7 one ## 9 335. 8 one ## 10 346. 9 one"},{"path":"https://multilevelmod.tidymodels.org/dev/articles/multilevelmod.html","id":"generalized-least-squares","dir":"Articles","previous_headings":"","what":"Generalized least squares","title":"Get Started","text":"engine requires nlme package installed. model, syntax specify independent experimental unit inside corrrelation argument nlme::gls(). ’ll pass engine argument. Possible values can found using ?nlme::corStruct. example: GEE model, regression terms required prediction:","code":"library(nlme) # <- Only need to load this to get cor*() functions gls_spec <- linear_reg() %>% set_engine(\"gls\", correlation = corCompSymm(form = ~ 1 | Subject)) gls_fit <- gls_spec %>% fit(Reaction ~ Days, data = sleepstudy) gls_fit ## parsnip model object ## ## Generalized least squares fit by REML ## Model: Reaction ~ Days ## Data: data ## Log-restricted-likelihood: -893.2325 ## ## Coefficients: ## (Intercept) Days ## 251.40510 10.46729 ## ## Correlation Structure: Compound symmetry ## Formula: ~1 | Subject ## Parameter estimate(s): ## Rho ## 0.5893103 ## Degrees of freedom: 180 total; 178 residual ## Residual standard error: 48.3595 predict(gls_fit, new_subject %>% select(Days)) %>% bind_cols(new_subject) ## # A tibble: 10 × 3 ## .pred Days Subject ## ## 1 251. 0 one ## 2 262. 1 one ## 3 272. 2 one ## 4 283. 3 one ## 5 293. 4 one ## 6 304. 5 one ## 7 314. 6 one ## 8 325. 7 one ## 9 335. 8 one ## 10 346. 9 one"},{"path":"https://multilevelmod.tidymodels.org/dev/articles/multilevelmod.html","id":"linear-mixed-effects-via-lme","dir":"Articles","previous_headings":"","what":"Linear mixed effects via lme","title":"Get Started","text":"engine requires nlme package installed. models created nlme::lme(), random effects specified argument called random. can passed via set_engine(). formula specified fit() include fixed effects model. fit basic random intercept model: predictions, tidymodels uses “population effects”, .e., -subject specific random effects. designed tidymodels know specific training set values making type prediction. lme fit objects, subject column, given, ignored. underlying predict() function used, level = 0 argument automatically invoked:","code":"lme_spec <- linear_reg() %>% set_engine(\"lme\", random = ~ 1 | Subject) lme_fit <- lme_spec %>% fit(Reaction ~ Days, data = sleepstudy) lme_fit ## parsnip model object ## ## Linear mixed-effects model fit by REML ## Data: data ## Log-restricted-likelihood: -893.2325 ## Fixed: Reaction ~ Days ## (Intercept) Days ## 251.40510 10.46729 ## ## Random effects: ## Formula: ~1 | Subject ## (Intercept) Residual ## StdDev: 37.12383 30.99123 ## ## Number of Observations: 180 ## Number of Groups: 18 predict(lme_fit, new_subject) %>% bind_cols(new_subject) ## # A tibble: 10 × 3 ## .pred Days Subject ## ## 1 251. 0 one ## 2 262. 1 one ## 3 272. 2 one ## 4 283. 3 one ## 5 293. 4 one ## 6 304. 5 one ## 7 314. 6 one ## 8 325. 7 one ## 9 335. 8 one ## 10 346. 9 one # For this design, this is the same prediction as a training set point: predict(lme_fit, sleepstudy %>% filter(Subject == \"308\")) ## # A tibble: 10 × 1 ## .pred ## ## 1 251. ## 2 262. ## 3 272. ## 4 283. ## 5 293. ## 6 304. ## 7 314. ## 8 325. ## 9 335. ## 10 346."},{"path":"https://multilevelmod.tidymodels.org/dev/articles/multilevelmod.html","id":"models-using-lmer-glmer-and-stan_glmer","dir":"Articles","previous_headings":"","what":"Models using lmer, glmer, and stan_glmer","title":"Get Started","text":"\"lmer\", \"glmer\", \"stan_glmer\" engines use formula syntax fitting multilevel models. See Section 2.1 Linear Mixed Models lme4 details. section, ’ll demonstrate using \"lmer\" engine. model specification occurs formula; models terms specified via set_engine() (although arguments can passed , usual). fit random intercept model, syntax : predict way. determine packages required model, use function: \"stan_glmer\" engine, relevant arguments can passed set_engine() : chains: positive integer specifying number Markov chains. default 4. iter: positive integer specifying number iterations chain (including warmup). default 2000. seed: seed random number generation. cores: Number cores use executing chains parallel. prior: prior distribution (non-hierarchical) regression coefficients. prior_intercept: prior distribution intercept (centering predictors). See ?rstanarm::stan_glmer ?rstan::sampling information.","code":"lmer_spec <- linear_reg() %>% set_engine(\"lmer\") lmer_fit <- lmer_spec %>% fit(Reaction ~ Days + (1|Subject), data = sleepstudy) lmer_fit ## parsnip model object ## ## Linear mixed model fit by REML ['lmerMod'] ## Formula: Reaction ~ Days + (1 | Subject) ## Data: data ## REML criterion at convergence: 1786.465 ## Random effects: ## Groups Name Std.Dev. ## Subject (Intercept) 37.12 ## Residual 30.99 ## Number of obs: 180, groups: Subject, 18 ## Fixed Effects: ## (Intercept) Days ## 251.41 10.47 predict(lmer_fit, new_subject) %>% bind_cols(new_subject) ## # A tibble: 10 × 3 ## .pred Days Subject ## ## 1 251. 0 one ## 2 262. 1 one ## 3 272. 2 one ## 4 283. 3 one ## 5 293. 4 one ## 6 304. 5 one ## 7 314. 6 one ## 8 325. 7 one ## 9 335. 8 one ## 10 346. 9 one required_pkgs(lmer_spec) ## [1] \"parsnip\" \"lme4\" \"multilevelmod\""},{"path":"https://multilevelmod.tidymodels.org/dev/articles/multilevelmod.html","id":"using-tidymodels-workflows","dir":"Articles","previous_headings":"","what":"Using tidymodels workflows","title":"Get Started","text":"use workflows, suggestions. First, instead using add_formula(), suggest using add_variables(). passes columns -model fitting function. add random effects formula, use formula argument add_model(). example: using recipe, make sure functions like step_dummy() convert column independent experimental unit (.e. subject) dummy variables. underlying model fit functions require single column data. Using recipe also offers opportunity set different role independent experiment unit, can come handy complex preprocessing needed.","code":"lmer_wflow <- workflow() %>% add_variables(outcomes = Reaction, predictors = c(Days, Subject)) %>% add_model(lmer_spec, formula = Reaction ~ Days + (1|Subject)) lmer_wflow %>% fit(data = sleepstudy) ## ══ Workflow [trained] ════════════════════════════════════════════════════ ## Preprocessor: Variables ## Model: linear_reg() ## ## ── Preprocessor ────────────────────────────────────────────────────────── ## Outcomes: Reaction ## Predictors: c(Days, Subject) ## ## ── Model ───────────────────────────────────────────────────────────────── ## Linear mixed model fit by REML ['lmerMod'] ## Formula: Reaction ~ Days + (1 | Subject) ## Data: data ## REML criterion at convergence: 1786.465 ## Random effects: ## Groups Name Std.Dev. ## Subject (Intercept) 37.12 ## Residual 30.99 ## Number of obs: 180, groups: Subject, 18 ## Fixed Effects: ## (Intercept) Days ## 251.41 10.47 rec <- recipe(Reaction ~ Days + Subject, data = sleepstudy) %>% add_role(Subject, new_role = \"exp_unit\") %>% step_zv(all_predictors(), -has_role(\"exp_unit\")) lmer_wflow %>% remove_variables() %>% add_recipe(rec) %>% fit(data = sleepstudy) ## ══ Workflow [trained] ════════════════════════════════════════════════════ ## Preprocessor: Recipe ## Model: linear_reg() ## ## ── Preprocessor ────────────────────────────────────────────────────────── ## 1 Recipe Step ## ## • step_zv() ## ## ── Model ───────────────────────────────────────────────────────────────── ## Linear mixed model fit by REML ['lmerMod'] ## Formula: Reaction ~ Days + (1 | Subject) ## Data: data ## REML criterion at convergence: 1786.465 ## Random effects: ## Groups Name Std.Dev. ## Subject (Intercept) 37.12 ## Residual 30.99 ## Number of obs: 180, groups: Subject, 18 ## Fixed Effects: ## (Intercept) Days ## 251.41 10.47"},{"path":"https://multilevelmod.tidymodels.org/dev/articles/multilevelmod.html","id":"other-tips","dir":"Articles","previous_headings":"","what":"Other tips","title":"Get Started","text":"Finally, excellent helper functions broom.mixed tidybayes packages. need underlying model fit object: extract_fit_engine() function can used either parsnip workflow objects:","code":"lmer_wflow %>% fit(data = sleepstudy) %>% # <- returns a workflow extract_fit_engine() # <- returns the lmer object ## Linear mixed model fit by REML ['lmerMod'] ## Formula: Reaction ~ Days + (1 | Subject) ## Data: data ## REML criterion at convergence: 1786.465 ## Random effects: ## Groups Name Std.Dev. ## Subject (Intercept) 37.12 ## Residual 30.99 ## Number of obs: 180, groups: Subject, 18 ## Fixed Effects: ## (Intercept) Days ## 251.41 10.47"},{"path":"https://multilevelmod.tidymodels.org/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Max Kuhn. Author. Hannah Frick. Author, maintainer. . Copyright holder, funder.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Kuhn M, Frick H (2024). multilevelmod: Model Wrappers Multi-Level Models. R package version 1.0.0.9000, http://multilevelmod.tidymodels.org/, https://github.com/tidymodels/multilevelmod.","code":"@Manual{, title = {multilevelmod: Model Wrappers for Multi-Level Models}, author = {Max Kuhn and Hannah Frick}, year = {2024}, note = {R package version 1.0.0.9000, http://multilevelmod.tidymodels.org/}, url = {https://github.com/tidymodels/multilevelmod}, }"},{"path":"https://multilevelmod.tidymodels.org/dev/index.html","id":"multilevelmod-","dir":"","previous_headings":"","what":"Model Wrappers for Multi-Level Models","title":"Model Wrappers for Multi-Level Models","text":"multilevelmod enables use multi-level models (.k.mixed-effects models, Bayesian hierarchical models, etc.) parsnip package. (meme courtesy @ChelseaParlett)","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Model Wrappers for Multi-Level Models","text":"can install released version multilevelmod CRAN : development version:","code":"install.packages(\"multilevelmod\") # install.packages(\"pak\") pak::pak(\"tidymodels/multilevelmod\")"},{"path":"https://multilevelmod.tidymodels.org/dev/index.html","id":"available-engines","dir":"","previous_headings":"","what":"Available Engines","title":"Model Wrappers for Multi-Level Models","text":"multilevelmod package provides engines models following table.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Model Wrappers for Multi-Level Models","text":"Loading mixedlevelmod trigger add modeling engines parsnip model database. Bayesian models, now stan-glmer engines linear_reg(), logistic_reg(), poisson_reg(). use , function parsnip::fit() function used instead parsnip::fit_xy() model terms can specified using lme/lme4 syntax. sleepstudy data used example: Bayesian model:","code":"library(multilevelmod) set.seed(1234) data(sleepstudy, package = \"lme4\") mixed_model_spec <- linear_reg() %>% set_engine(\"lmer\") mixed_model_fit <- mixed_model_spec %>% fit(Reaction ~ Days + (Days | Subject), data = sleepstudy) mixed_model_fit #> parsnip model object #> #> Linear mixed model fit by REML ['lmerMod'] #> Formula: Reaction ~ Days + (Days | Subject) #> Data: data #> REML criterion at convergence: 1743.628 #> Random effects: #> Groups Name Std.Dev. Corr #> Subject (Intercept) 24.741 #> Days 5.922 0.07 #> Residual 25.592 #> Number of obs: 180, groups: Subject, 18 #> Fixed Effects: #> (Intercept) Days #> 251.41 10.47 hier_model_spec <- linear_reg() %>% set_engine(\"stan_glmer\") hier_model_fit <- hier_model_spec %>% fit(Reaction ~ Days + (Days | Subject), data = sleepstudy) hier_model_fit #> parsnip model object #> #> stan_glmer #> family: gaussian [identity] #> formula: Reaction ~ Days + (Days | Subject) #> observations: 180 #> ------ #> Median MAD_SD #> (Intercept) 251.3 6.5 #> Days 10.5 1.7 #> #> Auxiliary parameter(s): #> Median MAD_SD #> sigma 25.9 1.6 #> #> Error terms: #> Groups Name Std.Dev. Corr #> Subject (Intercept) 24.1 #> Days 6.9 0.09 #> Residual 26.0 #> Num. levels: Subject 18 #> #> ------ #> * For help interpreting the printed output see ?print.stanreg #> * For info on the priors used see ?prior_summary.stanreg"},{"path":"https://multilevelmod.tidymodels.org/dev/index.html","id":"contributing","dir":"","previous_headings":"","what":"Contributing","title":"Model Wrappers for Multi-Level Models","text":"project released Contributor Code Conduct. contributing project, agree abide terms. questions discussions tidymodels packages, modeling, machine learning, please post RStudio Community. think encountered bug, please submit issue. Either way, learn create share reprex (minimal, reproducible example), clearly communicate code. Check details contributing guidelines tidymodels packages get help.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/gee_fit.html","id":null,"dir":"Reference","previous_headings":"","what":"GEE fitting function — gee_fit","title":"GEE fitting function — gee_fit","text":"Custom fitting function add GEE model cluster variable parsnip GEE function call.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/gee_fit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"GEE fitting function — gee_fit","text":"","code":"gee_fit(formula, data, family = gaussian, ...)"},{"path":"https://multilevelmod.tidymodels.org/dev/reference/gee_fit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"GEE fitting function — gee_fit","text":"formula Normal formula uses gee_formula() internal function id_var() specification clustering. data Modeling data family family object: list functions expressions defining link variance functions. Families supported gee gaussian, binomial, poisson, Gamma, quasi; see glm family documentation. links currently available: 1/mu^2 sqrt hard-coded cgee engine present. inverse gaussian variance function available. combinations remaining functions can obtained either family selection use quasi. ... additional parameters","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/gee_fit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"GEE fitting function — gee_fit","text":"gee object","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/gee_fit.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"GEE fitting function — gee_fit","text":"gee() always prints warnings output even silent = TRUE. gee_fit() never produce output, even silent = FALSE. Also, issues gee() function, supplementary call glm() needed get rank QR decomposition objects predict() can used.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/longitudinal_counts.html","id":null,"dir":"Reference","previous_headings":"","what":"Simulated longitudinal Poisson counts — longitudinal_counts","title":"Simulated longitudinal Poisson counts — longitudinal_counts","text":"Simulated longitudinal Poisson counts","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/longitudinal_counts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Simulated longitudinal Poisson counts — longitudinal_counts","text":"longitudinal_counts tibble","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/longitudinal_counts.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Simulated longitudinal Poisson counts — longitudinal_counts","text":"simulated data 100 subjects 10 time points additional numeric covariate. linear predictor random standard normal intercept per subject, time coefficient 1.50, covariate coefficient 0.25.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/longitudinal_counts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Simulated longitudinal Poisson counts — longitudinal_counts","text":"","code":"data(longitudinal_counts) str(longitudinal_counts) #> tibble [1,000 × 4] (S3: tbl_df/tbl/data.frame) #> $ subject: Factor w/ 100 levels \"1\",\"2\",\"3\",\"4\",..: 1 1 1 1 1 1 1 1 1 1 ... #> $ time : num [1:1000] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 ... #> $ x : num [1:1000] 2.56 2.69 2.68 2.49 2.29 ... #> $ y : int [1:1000] 0 0 3 2 0 1 0 2 3 0 ..."},{"path":"https://multilevelmod.tidymodels.org/dev/reference/msa_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Measurement systems analysis data — msa_data","title":"Measurement systems analysis data — msa_data","text":"Measurement systems analysis data","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/msa_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Measurement systems analysis data — msa_data","text":"msa_data tibble","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/msa_data.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Measurement systems analysis data — msa_data","text":"biological assay (.e. lab test) run 56 separate samples twice. goal measure percentage total variation results related measurement system much attributable true systematic difference (sample--sample).","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/msa_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Measurement systems analysis data — msa_data","text":"","code":"data(msa_data) str(msa_data) #> tibble [112 × 3] (S3: tbl_df/tbl/data.frame) #> $ id : chr [1:112] \"sample_001\" \"sample_001\" \"sample_002\" \"sample_002\" ... #> $ replicate: chr [1:112] \"rep_1\" \"rep_2\" \"rep_1\" \"rep_2\" ... #> $ value : num [1:112] 2.406 1.837 -0.674 -0.102 1.08 ..."},{"path":"https://multilevelmod.tidymodels.org/dev/reference/multilevelmod-package.html","id":null,"dir":"Reference","previous_headings":"","what":"parsnip methods for hierarchical models — multilevelmod-package","title":"parsnip methods for hierarchical models — multilevelmod-package","text":"multilevelmod allows users use parsnip package fit certain hierarchical models (e.g., linear, logistic, Poisson regression). package relies formula method specify random effects.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/multilevelmod-package.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"parsnip methods for hierarchical models — multilevelmod-package","text":"example, package includes simulated longitudinal data subjects measured time points. outcome number counts predictors time point well additional numeric covariate. can fit model using lme4::glmer(): making predictions, basic predict() method trick:","code":"library(tidymodels) library(multilevelmod) library(poissonreg) # current required for poisson_reg() # The lme4 package is required for this model. tidymodels_prefer() # Split out two subjects to show how prediction works data_train <- longitudinal_counts %>% filter(!(subject %in% c(\"1\", \"2\"))) data_new <- longitudinal_counts %>% filter(subject %in% c(\"1\", \"2\")) # Fit the model count_mod <- poisson_reg() %>% set_engine(\"glmer\") %>% fit(y ~ time + x + (1 | subject), data = data_train) count_mod #> parsnip model object #> #> Generalized linear mixed model fit by maximum likelihood (Laplace #> Approximation) [glmerMod] #> Family: poisson ( log ) #> Formula: y ~ time + x + (1 | subject) #> Data: data #> AIC BIC logLik deviance df.resid #> 4474.553 4494.104 -2233.277 4466.553 976 #> Random effects: #> Groups Name Std.Dev. #> subject (Intercept) 0.9394 #> Number of obs: 980, groups: subject, 98 #> Fixed Effects: #> (Intercept) time x #> -0.5946 1.5145 0.2395 count_mod %>% predict(data_new) #> # A tibble: 20 x 1 #> .pred #> #> 1 1.19 #> 2 1.42 #> 3 1.65 #> 4 1.83 #> 5 2.04 #> 6 2.66 #> 7 2.96 #> 8 3.43 #> 9 3.94 #> 10 4.64 #> 11 2.21 #> 12 2.60 #> 13 2.97 #> 14 3.38 #> 15 4.16 #> 16 4.90 #> 17 5.45 #> 18 6.20 #> 19 7.55 #> 20 8.64"},{"path":[]},{"path":"https://multilevelmod.tidymodels.org/dev/reference/multilevelmod-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"parsnip methods for hierarchical models — multilevelmod-package","text":"Maintainer: Hannah Frick hannah@posit.co (ORCID) Authors: Max Kuhn max@posit.co (ORCID) contributors: Posit Software, PBC [copyright holder, funder]","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/riesby.html","id":null,"dir":"Reference","previous_headings":"","what":"Imipramine longitudinal data — riesby","title":"Imipramine longitudinal data — riesby","text":"Imipramine longitudinal data","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/riesby.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Imipramine longitudinal data — riesby","text":"Reisby, N., Gram, L.F., Bech, P. et al. Imipramine: Clinical effects pharmacokinetic variability. Psychopharmacology 54, 263-272 (1977).","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/riesby.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Imipramine longitudinal data — riesby","text":"riesby tibble","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/riesby.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Imipramine longitudinal data — riesby","text":"data longitudinal clinical trial depression. outcome change depression scores week--week. endogenous column indicator whether subject fit Depression Scale classification endogenous. imipramine desipramine columns measurements plasma levels substances.","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/reference/riesby.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Imipramine longitudinal data — riesby","text":"","code":"data(riesby) str(riesby) #> tibble [250 × 7] (S3: tbl_df/tbl/data.frame) #> $ subject : Factor w/ 66 levels \"101\",\"103\",\"104\",..: 1 1 1 1 2 2 2 2 3 3 ... #> $ depr_score : num [1:250] -8 -19 -22 -23 -18 -9 -18 -20 -11 -16 ... #> $ week : num [1:250] 0 1 2 3 0 1 2 3 0 1 ... #> $ male : num [1:250] 0 0 0 0 1 1 1 1 1 1 ... #> $ endogenous : num [1:250] 0 0 0 0 0 0 0 0 1 1 ... #> $ imipramine : num [1:250] 4.04 3.93 4.33 4.37 2.77 ... #> $ desipramine: num [1:250] 4.2 4.81 4.96 4.96 5.24 ..."},{"path":"https://multilevelmod.tidymodels.org/dev/news/index.html","id":"multilevelmod-development-version","dir":"Changelog","previous_headings":"","what":"multilevelmod (development version)","title":"multilevelmod (development version)","text":"Switched cli errors (#70).","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/news/index.html","id":"multilevelmod-100","dir":"Changelog","previous_headings":"","what":"multilevelmod 1.0.0","title":"multilevelmod 1.0.0","text":"CRAN release: 2022-06-17 Maintainer change. Fix lme4::lme() nested random effects. -difabio added glmer engine linear_reg().","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/news/index.html","id":"multilevelmod-020","dir":"Changelog","previous_headings":"","what":"multilevelmod 0.2.0","title":"multilevelmod 0.2.0","text":"CRAN release: 2022-05-03 vignette now uses sleepstudy data. Support case weights added linear_reg(engine = \"lmer\"), logistic_reg(engine = \"glmer\"), poisson_reg(engine = \"glmer\") (#28).","code":""},{"path":"https://multilevelmod.tidymodels.org/dev/news/index.html","id":"multilevelmod-010","dir":"Changelog","previous_headings":"","what":"multilevelmod 0.1.0","title":"multilevelmod 0.1.0","text":"CRAN release: 2022-03-11 First CRAN release.","code":""}]