Utility Functions for Working with lme4 Formula Objects
Utility functions for working with lme4 formula objects. The function
ma_lme4_formula_terms
decomposes an lme4 formula into several
parts for further processing.
ma_lme4_formula_terms(formula) ma_lme4_formula_design_matrices(formula, data, start_index=0, formula_terms=NULL, only_design_matrices=FALSE)
formula |
An R formula object |
data |
Data frame |
start_index |
Starting index for cluster identifiers |
formula_terms |
Optional argument with processed formula terms using the
function |
only_design_matrices |
Logical indicating whether only design matrices should be created |
List with several entries
############################################################################# # EXAMPLE 1: Splitting a lme4 formula ############################################################################# #*** formula for a multilevel model formula <- y ~ I( miceadds::cwc(x, idcluster)) + z + I(z^2) + I( miceadds::gm(x, idcluster) ) + w + ( x + I(x^2) | idcluster) + (0 + w | idcluster ) + ( 0 + I(as.factor(f)) | idcluster) miceadds::ma_lme4_formula_terms(formula) #*** formula for a single level model formula2 <- y ~ I( miceadds::cwc(x, idcluster)) + z + I(z^2) + I( miceadds::gm(x, idcluster) ) + w miceadds::ma_lme4_formula_terms(formula2) ############################################################################# # EXAMPLE 2: Design matrices for multilevel model ############################################################################# data(data.ma07, package="miceadds") dat <- data.ma07 formula <- x1 ~ x2 + I( miceadds::gm( x2, id2)) + I( miceadds::gm( x2, id3)) + y1 + z1 + ( x2 | id2:id3 ) + ( 1 | id3 ) + ( 0 + x2 | id3 ) res <- miceadds::ma_lme4_formula_design_matrices(formula, data=dat) str(res)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.