Fixed covariance coverage subsection warning and NAs in the group observations from read.Models()#209
Fixed covariance coverage subsection warning and NAs in the group observations from read.Models()#209jenniferdguay wants to merge 3 commits intomichaelhallquist:masterfrom
Conversation
There was a problem hiding this comment.
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.
Using Mplus version 8.11 + the current MplusAutomation#master
Using this datafile: simdata.txt
and this code:
I get the following error messages:
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!