extract_structure {LearnVizLMM} | R Documentation |
Image of the data structure
Description
extract_structure
generates an image of the multilevel data structure. It
does this in two steps. First, characteristics of the group(s) or grouping
factor(s) are identified via the model
input or the n_gf
,
gf_description
, and gf_names
inputs. Second, this information is used to
run DiagrammeR::grViz()
, which returns an image.
Usage
extract_structure(
model = NULL,
n_gf = NULL,
gf_description = NULL,
gf_names = NULL,
gf_nlevels = NULL,
gf3_index = "i",
label_levels = "yes",
export_type = "print"
)
Arguments
model |
Code for fitting a |
n_gf |
Number of groups or grouping factors: |
gf_description |
Description of the structure of the groups or grouping
factors: |
gf_names |
Character vector of the names of group(s) or grouping
factor(s). For nested, order names by level from highest to lowest. Must be
a vector of length equal to |
gf_nlevels |
Optional numeric or character vector of the number of
levels for each group or grouping factor in the |
gf3_index |
String for the index of the highest-level group or grouping
factor. Only applies if |
label_levels |
Indicates whether levels of the data structure should be
labeled on the left-hand side of the figure (default) or not
( |
export_type |
Export type can be |
Value
A PNG (export_type = "png"
), character
(export_type = "text"
), or object of class htmlwidget that will print
in the R console, within R Markdown documents, and within Shiny output
bindings (export_type = "print"
).
Examples
# Using the model input
extract_structure(model = "lme(Score ~ type, random=list(School=pdDiag(~1+type),Class=~1))")
extract_structure(model = "lme(Weight ~ Time, random=~Time|Subject, data)",
gf_nlevels = 47)
extract_structure(model = "lmer(Strength ~ 1 + (1|Machine) + (1|Worker))",
gf_nlevels = c("23", "J"))
# Using the n_gf, gf_description, and gf_names inputs
extract_structure(n_gf = 1,
gf_names = "Subject")
extract_structure(n_gf = 3,
gf_description = "nested",
gf_names = c("District", "School", "Class"),
gf_nlevels = c(8, 15, 5),
label_levels = "no")