
Parameter Table Helpers
partable_helpers.RdHelper functions to manipulate parameter tables. They are exported for advanced users.
Usage
combine_partables(object_list, drop_duplicated = TRUE)
setdiff_eq_partables(x, y)
setdiff_partables(x, y)
union_eq_partables(x, y)
intersect_eq_partables(x, y)
setequal_eq_partables(x, y)
setequal_partables(x, y)
is_element_eq_partables(el, set)
is_element_partables(el, set)
match_eq_partables(x, table, nomatch = NA_integer_)
match_partables(x, table, nomatch = NA_integer_)
x %pt_in% table
x %pt_notin% table
is_partable(object, colchk = c("id", "lhs", "op", "rhs"))
is_partables(object, colchk = c("id", "lhs", "op", "rhs"))Arguments
- object_list
A list of objects of the class
partablesoreq_partables.- drop_duplicated
Logical. Whether duplicated models will be removed.
- x, y
List of parameter tables, such as
eq_partablesobjects.- el
A parameter table.
- set
A list of parameter tables.
- table
A list of parameter tables.
- nomatch
The same argument from
match().- object
The object to be checked whether it is a parameter table.
- colchk
The columns to be checked.
Value
The function combine_partables()
always returns an object of the class
eq_partables, which is a subclass
of partables.
The function setdiff_eq_partables()
returns a list of parameter tables,
of the same class of x, with models
present in y removed.
The function union_eq_partables()
returns a list of parameter tables,
of the class eq_partables.
The function intersect_eq_partables()
returns a list of parameter tables,
of the class eq_partables, common
in both x and y.
The function setequal_eq_partables()
returns TRUE or FALSE, based on
the results of get_digest_partables()
applied to x and y.
The function is_element_eq_partables()
(and is_element_partables())
returns TRUE or FALSE, based on
the results of is.element() applied
to the hash values from get_digest()
and get_digest_partables().
The function match_eq_partables()
(and match_partables())
returns the results of match() applied
to the hash values generated by
get_digest().
%pt_in% returns a logical vector,
the output of %in% applied to
the has values of x and table.
%pt_notin% returns a logical vector,
the output of %notin% applied to
the has values of x and table.
The function is_partable() returns
either TRUE or FALSE. It is
TRUE if the two conditions mentioned
in Details are met.
The function is_partables() returns
either TRUE or FALSE. It is
TRUE only if is_partable() returns
TRUE for all its elements.
Details
The function combine_partables()
combines a list of partables objects
or eq_partables objects
to one single object of the same type.
The function setdiff_eq_partables()
(and setdiff_partables())
removes from x models that are
also in y.
The function union_eq_partables()
combines the models in x and y,
with duplicated models removed.
The function intersect_eq_partables()
finds the models common in x and y.
The function setequal_eq_partables()
(and setequal_partables())
checks whether x and y has the
same set of models. Orders are ignored.
The function is_element_eq_partables()
checks whether el is one of the
models in set.
The function match_eq_partables()
(and match_partables())
is similar to match(), but check
matches based on the results of
get_digest() applied to the
parameter tables.
%pt_in% is similar to %in%,
but works on parameter tables using
match_eq_partables().
%pt_notin% is similar to %notin%,
but works on parameter tables using
match_eq_partables().
The function is_partable() checks
whether an object is probably a
parameter table. It checks whether
(a) the object is a data.frame-like
object (by is.data.frame()) and (b)
the columns in colchk exist. If
both conditions are met, then the
object is considered a parameter
table.
The function is_partables() checks
whether a list is likely a list of parameter
tables. It simply calls is_partable()
on all the elements.
Examples
library(lavaan)
# Model 1
mod1 <-
"
fx =~ x1 + x2 + x3
fm =~ m1 + m2 + m3
fy =~ y1 + y2 + y3
fm ~ fx
fy ~ fm + fx
"
fit1 <- sem(
model = mod1,
data = data_test_3_factor_3_item
)
fit1_1_more <- drop_k(fit1)
fit1_1_more_1_less <- lapply(
fit1_1_more,
add_k
)
partables1 <- combine_partables(fit1_1_more_1_less)
partables1
#>
#> Number of models: 4
#>
#> The models:
#>
#> Model
#> 1 drop: fm~fx.add: fx~~fm
#> 2 drop: fm~fx.add: fx~fm
#> 3 drop: fy~fm.add: fm~~fy
#> 4 drop: fy~fm.add: fm~fy
#>
#> NOTE: 'default' names are used. Call 'print()' and add 'names_to_use =
#> "long"' to use the long descriptive names, if available, for the
#> models.