# a 3-factor example using the HolzingerSwineford1939 data from `lavaan`
# some changes to the default values
# notice that in this example we are recreating the original model
abilityShortForm <- antcolony.lavaan(
data = lavaan::HolzingerSwineford1939,
ants = 2, evaporation = 0.7,
antModel = " visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 ",
list.items = list(c(
"x1",
"x2", "x3"
), c("x4", "x5", "x6"), c("x7", "x8", "x9")), full = 9, i.per.f =
c(3, 3, 3), factors = c("visual", "textual", "speed"), steps = 2, fit.indices =
c("cfi"), fit.statistics.test = "(cfi > 0.6)", summaryfile =
NULL, feedbackfile = NULL, max.run = 2, parallel = FALSE
)
if (FALSE) {
# using simulated test data and the default values for lavaan.model.specs
# first, read in the original or "full" model
data(exampleAntModel) # a character vector for a lavaan model
# then, create the list of the items by the factors
# in this case, all items load onto the general 'Ability' factor
list.items <- list(c(
"Item1", "Item2", "Item3", "Item4", "Item5",
"Item6", "Item7", "Item8", "Item9", "Item10",
"Item11", "Item12", "Item13", "Item14", "Item15",
"Item16", "Item17", "Item18", "Item19", "Item20",
"Item21", "Item22", "Item23", "Item24", "Item25",
"Item26", "Item27", "Item28", "Item29", "Item30",
"Item31", "Item32", "Item33", "Item34", "Item35",
"Item36", "Item37", "Item38", "Item39", "Item40",
"Item41", "Item42", "Item43", "Item44", "Item45",
"Item46", "Item47", "Item48", "Item49", "Item50",
"Item51", "Item52", "Item53", "Item54", "Item55", "Item56"
))
# load the data
data(simulated_test_data)
# finally, call the function with some minor changes to the default values.
abilityShortForm <- antcolony.lavaan(
data = simulated_test_data,
ants = 5, evaporation = 0.7, antModel = exampleAntModel,
list.items = list.items, full = 56, i.per.f = 20,
factors = "Ability", steps = 3, fit.indices = c("cfi", "rmsea"),
fit.statistics.test = "(cfi > 0.95)&(rmsea < 0.05)",
summaryfile = "summary.txt",
feedbackfile = "iteration.html",
max.run = 500
)
abilityShortForm # print the results of the final short form
}
Run the code above in your browser using DataLab