Functions to manipulate
a partables
-class object
Value
A partables
-class objects with
all the objects supplied combined
together. If an object is
a lavaan
-class object, its
parameter table will be retrieved
by lavaan::parameterTable()
.
If an object is a model_set
-class
object, the stored partables
-class
object will be retrieved.
Details
The partables
-class objects have
a c()
method that can be used to
combine parameter tables.
Each object must be
a. a partables
-class object,
b. a model_set
-class object,
c. a lavaan
-class object, or
d. a parameter table of
the class lavaan.data.frame()
,
usually generated by
lavaan::parameterTable()
.
Other objects will be discarded.
Names will be used when combining objects. If two objects have the same names, then only the first one will be retained. No warning message will be issued. Users are encouraged to explicitly name all objects carefully.
Note that, to invoke this method,
the first object must be a
partables
object.
The model_set
class also has a
c
-method. It
will replace the first object by the stored
partables and then call the c
-method of partables
objects.
The function partables_drop()
is
for dropping models from a
partables
-class object.
Author
Shu Fai Cheung https://orcid.org/0000-0002-9871-9448
Examples
library(lavaan)
moda <-
"
x3 ~ a*x1 + b*x2
x4 ~ a*x1
ab := a*b
"
fita <- sem(moda, dat_path_model, fixed.x = TRUE)
outa <- model_set(fita,
progress = FALSE,
parallel = FALSE)
modb <-
"
x3 ~ a*x1 + b*x2
x4 ~ a*x2
ab := a*b
"
fitb <- sem(modb, dat_path_model, fixed.x = TRUE)
outb <- model_set(fitb,
progress = FALSE,
parallel = FALSE)
mod2 <-
"
x2 ~ 0*x3 + 0*x4
x1 ~ 0*x3
"
fit2 <- sem(mod2, dat_path_model)
mod3 <-
"
x2 ~ x3 + 0*x4
x1 ~ x3
"
fit3 <- sem(mod3, dat_path_model)
out <- c(outa$models, user2 = fit2, outb$models, user3 = fit3)
out
#>
#> Call:
#> NULL
#>
#> Number of parameter tables: 9
#>
#> The modifications/models:
#> add: x4~x2
#> add: (x3~x1),(x4~x1)
#> drop: x3~x2
#> drop: x3~~x4
#> original
#> user2
#> add: x4~x1
#> add: (x3~x1),(x4~x2)
#> user3
out2 <- c(outa, user2 = fit2, outb$models, user3 = fit3)
out2
#>
#> Call:
#> NULL
#>
#> Number of parameter tables: 9
#>
#> The modifications/models:
#> add: x4~x2
#> add: (x3~x1),(x4~x1)
#> drop: x3~x2
#> drop: x3~~x4
#> original
#> user2
#> add: x4~x1
#> add: (x3~x1),(x4~x2)
#> user3
out3 <- c(outa, user2 = fit2, outb, user3 = fit3)
out3
#>
#> Call:
#> NULL
#>
#> Number of parameter tables: 9
#>
#> The modifications/models:
#> add: x4~x2
#> add: (x3~x1),(x4~x1)
#> drop: x3~x2
#> drop: x3~~x4
#> original
#> user2
#> add: x4~x1
#> add: (x3~x1),(x4~x2)
#> user3