Skip to content

Commit

Permalink
Fixes for length > 1 tests for EFA and latent class counts in R 4.3+
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhallquist committed Jul 15, 2023
1 parent af7e60a commit ec0c959
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Version 1.1.1
- patch: multi-class columns are now treated as their first class in prepareMplusData()
- patch: extract alternative parameterizations of categorical latent variables (thanks to sam-crawley for the pull request)

Version 1.1.0
- bugfix: fixed a bug in handling multiply imputed data introduced in 1.0.0
Expand Down
6 changes: 3 additions & 3 deletions R/extractModIndices.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ extractModIndices_1chunk <- function(chunk, columnNames, filename) {
#in the on/by section, the on comes first with a trailing / and no data, followed by the by line with the MI data
#check for this and propagate data from subsequent row to this row
if (length(thisLine) < numCols && length(thisLine) >= 4 &&
thisLine[4] == "/" &&
thisLine[4L] == "/" &&
length(nextLine) > 4 &&
nextLine[1] == thisLine[3] && #var1 of ON line corresponds to var2 of BY line
nextLine[3] == thisLine[1] #var2 of ON line corresponds to var1 of BY line
nextLine[1L] == thisLine[3L] && #var1 of ON line corresponds to var2 of BY line
nextLine[3L] == thisLine[1L] #var2 of ON line corresponds to var1 of BY line
) {
splitParams[[line]][4:length(nextLine)] <- nextLine[4:length(nextLine)]
} else if (length(thisLine) < numCols && substr(thisLine[1], 1, 1) == "[") {
Expand Down
10 changes: 5 additions & 5 deletions R/parseOutput.R
Original file line number Diff line number Diff line change
Expand Up @@ -947,9 +947,9 @@ extractSummaries_1file <- function(outfiletext, filename, input)

#calculate adjusted AIC per Burnham & Anderson(2004), which is better than AIC for non-nested model selection
#handle AICC calculation, requires AIC, Parameters, and observations
if (!is.null(arglist$Parameters) && !is.na(arglist$Parameters) &&
!is.null(arglist$AIC) && !is.na(arglist$AIC) &&
!is.null(arglist$Observations) && !is.na(arglist$Observations)) {
if (!is.null(arglist$Parameters) && !all(is.na(arglist$Parameters)) &&
!is.null(arglist$AIC) && !all(is.na(arglist$AIC)) &&
!is.null(arglist$Observations) && !all(is.na(arglist$Observations))) {
arglist$AICC <- arglist$AIC + (2*arglist$Parameters*(arglist$Parameters+1))/(arglist$Observations-arglist$Parameters-1)
} else {
arglist$AICC <- NA_real_
Expand Down Expand Up @@ -2060,10 +2060,10 @@ extractClassCounts <- function(outfiletext, filename, summaries) {

countlist <- list()

if (is.null(summaries) || missing(summaries) || summaries$NCategoricalLatentVars==1 || is.na(summaries$NCategoricalLatentVars)) {
if (is.null(summaries) || missing(summaries) || isTRUE(summaries$NCategoricalLatentVars[1L]==1) || all(is.na(summaries$NCategoricalLatentVars))) {
#Starting in Mplus v7.3 and above, formatting of the class counts appears to have changed...
#Capture the alternatives here
if (is.null(summaries) || missing(summaries) || is.null(summaries$Mplus.version) || as.numeric(summaries$Mplus.version) < 7.3) {
if (is.null(summaries) || missing(summaries) || is.null(summaries$Mplus.version) || as.numeric(summaries$Mplus.version[1L]) < 7.3) {
modelCounts <- getSection("^FINAL CLASS COUNTS AND PROPORTIONS FOR THE LATENT CLASSES$", outfiletext)
ppCounts <- getSection("^FINAL CLASS COUNTS AND PROPORTIONS FOR THE LATENT CLASS PATTERNS$", outfiletext)
mostLikelyCounts <- getSection("^CLASSIFICATION OF INDIVIDUALS BASED ON THEIR MOST LIKELY LATENT CLASS MEMBERSHIP$", outfiletext)
Expand Down

0 comments on commit ec0c959

Please sign in to comment.