# ma_lme4_formula_terms: Utility Functions for Working with 'lme4' Formula Objects In alexanderrobitzsch/miceadds: Some Additional Multiple Imputation Functions, Especially for 'mice'

## Description

Utility functions for working with lme4 formula objects. The function `ma_lme4_formula_terms` decomposes an lme4 formula into several parts for further processing.

## Usage

 ```1 2 3 4``` ```ma_lme4_formula_terms(formula) ma_lme4_formula_design_matrices(formula, data, start_index=0, formula_terms=NULL, only_design_matrices=FALSE) ```

## Arguments

 `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 `ma_lme4_formula_terms` `only_design_matrices` Logical indicating whether only design matrices should be created

## Value

List with several entries

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25``` ```############################################################################# # 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) ```

alexanderrobitzsch/miceadds documentation built on Oct. 6, 2018, 1:49 a.m.