Skip to content

Conversation

@jenniferdguay
Copy link

Using Mplus version 8.11 + the current MplusAutomation#master
Using this datafile: simdata.txt

and this code:

library(MplusAutomation)

data <- read.csv("simdata.txt", header = F, fill = T, sep = "")
colnames(data)[11] <- "group"
  
alignment.mdl <- mplusObject(
  TITLE =     "Run alignment with oblimin rotation;",
  VARIABLE =  "USEVARIABLES = group V1-V10; GROUPING =  group(2);",
  MODEL= "F1-F2 BY V1-V10(*1);",
  ANALYSIS =  "ROTATION = OBLIMIN; alignment = fixed",
  OUTPUT = "align tech1;",
  rdata = data
)

alignment.fit <- mplusModeler(alignment.mdl, modelout = "alignment_model.inp", run=T)

I get the following error messages:

No PROPORTION OF DATA PRESENT sections found within COVARIANCE COVERAGE OF DATA output.
Warning message:
In readModels(target = outfile, quiet = quiet) : NAs introduced by coercion

which are fixed in this pull request.

Would it be possible to check if this is correct and working for other Mplus versions and on other datasets? And if everything is correct, then would it be possible for you to add this to the next release of MplusAutomation?

Many thanks!

Copy link
Author

@jenniferdguay jenniferdguay May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we specify group labels (e.g., G1 and G2) in “GROUPING =“ of the model syntax, mplus knows how to label the levels in the grouping variable of the dataset (e.g., G1 refers to 1 and G2 refers to 2). The output does not print group levels in parenthesis (e.g., the (1) in Group G1 (1)) and the original code from mplusAutomation works.

So if we specify the model syntax with group labels (e.g., G1 and G2) in "GROUPING =", for instance:

alignment.mdl2 <- mplusObject(
  TITLE =     "Run alignment with oblimin rotation;",
  VARIABLE =  "USEVARIABLES = group x1-x10; GROUPING =  group(1 = G1 2 = G2);",
  MODEL= "F1-F2 BY x1-x10(*1);",
  ANALYSIS =  "ROTATION = OBLIMIN; alignment = fixed",
  OUTPUT = "align tech1;",
  rdata = simout$data
)

The original code can be used:

if (isTRUE(length(obs) %% 2 == 0)) {
            Observations <- as.numeric(obs[seq(2, to = length(obs), by = 2)])
            names(Observations) <- obs[seq(1, to = length(obs), by = 2)]
            attr(summaries, "Observations") <- Observations
          }

Whereas if we do not specify group labels in "Grouping =", but specify the number of levels in the group variable:

alignment.mdl <- mplusObject(
  TITLE =     "Run alignment with oblimin rotation;",
  VARIABLE =  "USEVARIABLES = group x1-x10; GROUPING =  group(2);",
  MODEL= "F1-F2 BY x1-x10(*1);",
  ANALYSIS =  "ROTATION = OBLIMIN; alignment = fixed",
  OUTPUT = "align tech1;",
  rdata = simout$data
)

Then the original code produces an error because it does not account for the group levels in parenthesis (e.g., (1) and (2) that have been printed next to G1 and G2 in the output). In this case, the proposed changes work:

if (isTRUE(length(obs) %% 2 == 0)) {
            Observations <- as.numeric(obs[seq(3, to = length(obs), by = 3)])
            names(Observations) <- obs[seq(1, to = length(obs), by = 3)]
            attr(allFiles[[listID]]$summaries, "Observations") <- Observations
          }

Thus, it could be good to check if group labels have been added in “Grouping =” argument, so that the original code can be used to parse the output, otherwise the proposed changes can be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant