Skip to content

Commit

Permalink
bug!: #79 add missing function create_model_formulas()
Browse files Browse the repository at this point in the history
  • Loading branch information
egouldo committed Sep 4, 2024
1 parent dc024fb commit d050e6f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions supp_mat/SM3_ExplainingDeviation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,20 @@ plot_model_means_RE <- function(data, variable, predictor_means) {
poss_fit <- possibly(fit, otherwise = NA, quiet = FALSE)
create_model_formulas <- function(outcome, fixed_effects, random_intercepts){
# https://community.rstudio.com/t/programmatically-generate-formulas-for-lmer/8575
# ---- Define random effects constructor function ----
randomify <- function(feats) {
paste0("(1|", feats, ")", collapse = " + ")
}
# ---- Construct formula ----
randomify <- function(feats) paste0("(1|", feats, ")", collapse = " + ")
fixed <- paste0(fixed_effects, collapse = " + ")
random <- randomify(random_intercepts)
model_formula <- as.formula(paste(outcome, "~", fixed, "+", random))
return(model_formula)
}
```

## Box-Cox transformation of response variable for model fitting
Expand Down

0 comments on commit d050e6f

Please sign in to comment.