Skip to content

Commit

Permalink
Cleanup namespace of extract functions, reduce references to these fu…
Browse files Browse the repository at this point in the history
…nctions in documentation
  • Loading branch information
michaelhallquist committed Mar 12, 2024
1 parent 92c0014 commit 98836d2
Show file tree
Hide file tree
Showing 21 changed files with 409 additions and 441 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ Suggests:
LazyLoad: yes
LazyData: yes
VignetteBuilder: knitr
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Encoding: UTF-8
Config/testthat/edition: 3
6 changes: 0 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ export(detectMplus)
export(detectVariables)
export(extract.mplus.model)
export(extract.mplusObject)
export(extractModIndices)
export(extractModelParameters)
export(extractModelSummaries)
export(getSavedata_Bparams)
export(getSavedata_Data)
export(getSavedata_Fileinfo)
export(get_bparameters)
export(get_class_counts)
export(get_covariance_coverage)
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 1.1.3 (DEVELOPMENT)
- notice: Package namespace has been cleaned up to remove long-deprecated functions including extractModelSummaries, extractModelParameters, and extractModIndices.

Version 1.1.2
- bugfix: Break file paths > 90 chars in prepareMplusData and mplusModeler to avoid line length errors

Expand Down
6 changes: 0 additions & 6 deletions R/MplusAutomation.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@
#' or \code{\link{LatexSummaryTable}} (returns a LaTex-formatted table of
#' summary statistics).
#'
#' Deprecated: To extract raw data created by the SAVEDATA command (e.g., class membership probabilities
#' or factor scores), see \code{\link{getSavedata_Data}}.
#'
#' Deprecated: To extract unstandardized or standardized parameter estimates from a single output file,
#' see \code{\link{extractModelParameters}}.
#'
#' Detailed model fit and parameter comparisons between two models can be obtained using
#' \code{\link{compareModels}}.
#'
Expand Down
8 changes: 3 additions & 5 deletions R/compareModels.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
#' for filtering out fixed parameters and nonsignificant parameters. When requested, \code{compareModels}
#' will compute the chi-square difference test for nested models (does not apply to MLMV, WLSM, and WLSMV
#' estimators, where DIFFTEST in Mplus is needed).
#' Model outputs to be compared can be full summaries and parameters (generated by \code{readModels}),
#' summary statistics only (\code{extractModelSummaries}), or parameters only (\code{extractModelParameters}).
#'
#'
#' Model outputs to be compared should come from the \code{readModels} command.
#'
#' The \code{show} parameter can be one or more of the following, which can be passed as a vector, such as c("equal", "pdiff").
#'
Expand Down Expand Up @@ -46,8 +45,7 @@
#' }
#' }
#'
#' @param m1 The first Mplus model to be compared. Generated by \code{readModels},
#' \code{extractModelSummaries}, or \code{extractModelParameters}.
#' @param m1 The first Mplus model to be compared. Generated by \code{readModels}.
#' @param m2 The second Mplus model to be compared.
#' @param show What aspects of the models should be compared. Options are
#' "all", "summaries", "equal", "diff", "pdiff", and "unique". See below for details.
Expand Down
1 change: 1 addition & 0 deletions R/extractEFAparameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' @param outfiletext character vector of Mplus output file being processed
#' @param filename name of the output file
#' @return list of parsed EFA parameters
#' @keywords internal
extractEFAparameters <- function(outfiletext, filename) {

#get pre-parsed header lines so that we demarcate the section boundaries properly
Expand Down
5 changes: 2 additions & 3 deletions R/extractModIndices.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ extractModIndices_1file <- function(outfiletext, filename) {
return(allSectionMI)
}

#' Extract model modification indices.
#' (DEPRECATED) Extract model modification indices.
#'
#' Extracts the model modification indices from the MODEL MODIFICATION INDICES section of one
#' or more Mplus output files. If the \code{target} is a directory, all .out files therein will be parsed
Expand Down Expand Up @@ -160,9 +160,8 @@ extractModIndices_1file <- function(outfiletext, filename) {
#' \item{StdYX_EPC}{The EPC value standardized using the variances of the continuous latent
#' variables as well as the variances of the background and/or outcome variables.}
#' @author Michael Hallquist
#' @export
#' @seealso \code{\link{readModels}}, \code{\link{extractModelSummaries}}, \code{\link{extractModelParameters}}
#' @keywords interface
#' @keywords internal
#' @examples
#' \dontrun{
#' ex3.14 <- extractModIndices(
Expand Down
5 changes: 2 additions & 3 deletions R/extractParameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ extractParameters_1file <- function(outfiletext, filename, resultType, efa = FAL
return(allSections)
}

#' Extract model parameters from MODEL RESULTS section.
#' (DEPRECATED) Extract model parameters from MODEL RESULTS section.
#'
#' Extracts the model parameters from the MODEL RESULTS section of one or more Mplus output files.
#' If a particular output file has more than one results section (unstandardized, stdyx, stdy, and/or std),
Expand Down Expand Up @@ -771,8 +771,7 @@ extractParameters_1file <- function(outfiletext, filename, resultType, efa = FAL
#'
#' @author Michael Hallquist
#' @seealso \code{\link{extractModelSummaries}}
#' @export
#' @keywords interface
#' @keywords internal
#' @examples
#' \dontrun{
#' ex3.14 <- extractModelParameters(
Expand Down
48 changes: 5 additions & 43 deletions R/extractSaveData.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
#' \item{bayesVarNames}{A character vector containing the names of variables in the BPARAMETERS dataset.}
#' \item{tech3File}{A character vector of the tech 3 output.}
#' \item{tech4File}{A character vector of the tech 4 output.}
#' @export
#' @author Michael Hallquist
#' @seealso \code{\link{getSavedata_Data}}
#' @examples
#' \dontrun{
#' fileInfo <- getSavedata_Fileinfo("C:/Program Files/Mplus/Test Output.out")
#' }
#' @keywords interface
#' @keywords internal
getSavedata_Fileinfo <- function(outfile) {
#wraps l_getSavedata_Fileinfo by checking for the outfile and reading it as a character vector.

Expand Down Expand Up @@ -337,38 +336,18 @@ l_getSavedata_Fileinfo <- function(outfile, outfiletext, summaries) {
#' If \code{outfile} is a relative path or just the filename, then it is assumed that the file resides in
#' the working directory \code{getwd()}.
#' @return A \code{data.frame} containing the analysis dataset generated by the SAVEDATA command.
#' @export
#' @author Michael Hallquist
#' @seealso \code{\link{getSavedata_Fileinfo}}
#' @examples
#' \dontrun{
#' savedat <- getSavedata_Data("C:/Program Files/Mplus/Test Output.out")
#' }
#' @keywords interface
#' @keywords internal
getSavedata_Data <- function(outfile) {
#exposed wrapper for l_getSavedata_Data, which pulls saveData data into data.frame

message("getSavedata_Data has been deprecated. Please use readModels(\"nameofMplusoutfile.out\", what=\"savedata\")$savedata to replicate the old functionality.")

#
# if(!file.exists(outfile)) {
# stop("Cannot locate outfile: ", outfile)
# }
#
# outfiletext <- scan(outfile, what="character", sep="\n", strip.white=FALSE, blank.lines.skip=FALSE, quiet=TRUE)
#
# if (length(outfiletext) == 0) {
# warning("Empty outfile")
# return(NULL)
# }
#
# fileInfo <- l_getSavedata_Fileinfo(outfile, outfiletext)
#
# if (is.null(fileInfo) || all(is.na(fileInfo))) return(NULL)
# else if (is.na(fileInfo[["fileVarWidths"]][1])) return(l_getSavedata_readRawFile(outfile, outfiletext, format="free", fileName=fileInfo[["fileName"]],
# varNames=fileInfo[["fileVarNames"]]))
# else return(l_getSavedata_readRawFile(outfile, outfiletext, format="fixed", fileName=fileInfo[["fileName"]],
# varNames=fileInfo[["fileVarNames"]], varWidths=fileInfo[["fileVarWidths"]]))
return(invisible(NULL))
}

#' Load the draws from the Bayesian model posterior distribution (SAVEDATA BPARAMETERS) command into an R data.frame
Expand All @@ -392,35 +371,18 @@ getSavedata_Data <- function(outfile) {
#' of how \code{Mplus} implements chain convergence checks and MCMC draws, see here: \url{http://www.statmodel.com/download/Bayes3.pdf}.
#'
#' @author Michael Hallquist, Florian Boeing-Messing
#' @export
#' @seealso \code{\link{getSavedata_Fileinfo}}, \code{\link{getSavedata_Data}}
#' @references \url{http://www.statmodel.com/download/Bayes3.pdf}
#' @examples
#' \dontrun{
#' fileInfo <- getSavedata_Data("C:/Program Files/Mplus/Test Output.out")
#' }
#' @keywords interface
#' @keywords internal
getSavedata_Bparams <- function(outfile, discardBurnin=TRUE) {
#exposed wrapper for l_getSavedata_readRawFile, which pulls bayesian parameters into a data.frame

message("getSavedata_Bparams has been deprecated. Please use readModels(\"nameofMplusoutfile.out\", what=\"bparameters\")$bparameters to replicate the old functionality.")

# if(!file.exists(outfile)) {
# stop("Cannot locate outfile: ", outfile)
# }
#
# outfiletext <- scan(outfile, what="character", sep="\n", strip.white=FALSE, blank.lines.skip=FALSE, quiet=TRUE)
#
# if (length(outfiletext) == 0) {
# warning("Empty outfile")
# return(NULL)
# }
#
# fileInfo <- l_getSavedata_Fileinfo(outfile, outfiletext)
#
# if (is.null(fileInfo) || all(is.na(fileInfo))) return(NULL)
# else return(l_getSavedata_Bparams(outfile, outfiletext, fileInfo, discardBurnin=discardBurnin))

return(invisible(NULL))
}


Expand Down
5 changes: 2 additions & 3 deletions R/parseOutput.R
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ extractSummaries_1file <- function(outfiletext, filename, input)
return(arglist)
}

#' Extract summary statistics from a single output file or from a group of Mplus models within a directory
#' (DEPRECATED) Extract summary statistics from a single output file or from a group of Mplus models within a directory
#'
#' Parses a group of Mplus model output files (.out extension) for model fit statistics.
#' At this time, the details extracted are fixed and include: \code{Filename, InputInstructions, Title, Estimator,
Expand Down Expand Up @@ -1048,8 +1048,7 @@ extractSummaries_1file <- function(outfiletext, filename, input)
#'
#' @author Michael Hallquist
#' @seealso \code{\link{regex}}, \code{\link{runModels}}, \code{\link{readModels}}
#' @keywords interface
#' @export
#' @keywords internal
#' @examples
#' \dontrun{
#' allExamples <- extractModelSummaries(
Expand Down
Loading

0 comments on commit 98836d2

Please sign in to comment.