0

Good afternoon, Ant-colony algorithms in R allow for the inclusion of custom objective functions. The package stuart accepts custom ojectives for the algorithm to develop models to improve upon. However, getting the function to accept custom functions is casuing issues.

How can we include the covariance matrix using "objectivematricies" function so that the ant colony algorith (mmas function) minimises the latent covariance between the factors? Essentially, using ant-colony algorithms to find solutions that have the weakest latent factor covariance. Note that the latent covariance is actually the default for objectivematricies function, so this should be possible.

Here is a minimal reproducible using the data that comes with stuart

First we can create the covariance matrix from the data

library("stuart")
# Load the data
data(sups) # from stuart
# Define a two factor structure
fs <- list(
pro = names(sups)[2:13],
fee = names(sups)[14:20]
)
# Generate the objective matrices
mats <- objectivematrices(data = sups, factor.structure = fs, capacity = 3, cores = 1)
# potentially set these to F or 0 to indicate this is the goal?
mats$lvcor$use[,] <- FALSE

Next we run the ant-colony algorith and ask it to minimse the latent correlation between the two factors

sel <- mmas(fairplayer, 
            fs, 
            3, # specify again the number of final items? This is already included in the custom objective above.
            objective = empiricalobjective(
                         criteria = "??",
                          side = "bottom", # lower is desired
                          matrix = "mats" # our new covariance matrix),
            seed = 55635, 
            cores = 1)

The code above extracts covariance matrix, includes this as an objective, however, obviously will not work. mmas does not know how to minimise the matrix through criteria, or what mats is (I think).

When completed, the standard errors are below which suggests the logic is incorrect as the suggested solution does not answer our question (note, error occurs when we substitute "?" above for logical values).

"Error in (function (criteria = c("rmsea", "srmr", "crel"), add = c("chisq", : Not all criteria provided to the objective function have defaults. Problem with: . Consider using these as auxiliary information via "add" or including them manually via "fixed" instead. In addition: Warning message: No empirical values provided to empiricalobjective. Attempting to return defaults."

Thank you in advance.

0 Answers0