mplus.extract: Extract Results Saved in a Mplus HDF5 file

View source: R/mplus.extract.R

mplus.extractR Documentation

Extract Results Saved in a Mplus HDF5 file

Description

This function extracts various results saved in the Hierarchical Data Format version 5 (HDF5) file with the h5 file extension created by Mplus when requesting H5RESULTS in the SAVEDATA section, e.g., SAVEDATA: H5RESULTS = results.h5;. By default, the function does not print any results on the console, i.e., result = "none". Note that Mplus version 8.11 or higher is required for saving result in a HDF file.

Usage

mplus.extract(x, print = c("none", "all", "input", "result"),
              result = c("all", "summary.analysis", "fit", "mod.result",
                         "conf.mod.result", "cred.mod.result", "std.mod.result",
                         "conf.std.mod.result", "cred.std.mod.result", "rsquare",
                         "irt.param", "modind", "prob.scale", "odds.ratio",
                         "conf.prob.scale", "cred.prob.scale", "ind.odds.ratio",
                         "brant.wald", "within.std.mod.result", "within.rsquare"),
              exclude = NULL, digits = NULL, write = NULL, append = TRUE,
              check = TRUE)

Arguments

x

a character string indicating the name of the Mplus H5 file (HDF5 format) with or without the file extension .h5, e.g., "Mplus_Results.h5" or "Mplus_Results".

print

a character vector indicating which Mplus output section to show on the R console, i.e., "none" (default) for no input or result sections, "all" for input section including warning messages and result sections, "input" for input section including warning messages, and "result" for result sections.

result

a character vector specifying the Mplus result sections to be shown on the console, "all" for all available result sections. See 'Details' for result sections that can be requested.

exclude

a character string indicating result sections to be excluded when result is not "none".

digits

an integer value indicating the number of decimal places to be used for displaying results. Note that by default, the function does not round any results.

write

a character string naming a text file with file extension ".txt" (e.g., "Output.txt") for writing the output into a text file.

append

logical: if TRUE (default), output will be appended to an existing text file with extension .txt specified in write, if FALSE existing text file will be overwritten.

check

logical: if TRUE (default), argument specification is checked.

Details

Result Sections

Following result sections can be selected by using the result argument or excluded by using the exclude argument:

  • "summary.analysis" for the SUMMARY OF ANALYSIS section.

  • "fit" for the Model Fit Information section.

  • "fit.config" for the Model Fit Information (configural) section.

  • "fit.metric" for the Model Fit Information (metric) section.

  • "fit.scalar" for the Model Fit Information (scalar) section.

  • "mod.result" for the Model Results section.

  • "mod.result.config" for the Model Results (configural) section.

  • "mod.result.metric" for the Model Results (metric) section.

  • "mod.result.scalar" for the Model Results (scalar) section.

  • "conf.mod.result" for the Confidence Intervals of Model Results section.

  • "conf.mod.result.config" for the Confidence Intervals of Model Results (configural) section.

  • "conf.mod.result.metric" for the Confidence Intervals of Model Results (metric) section.

  • "conf.mod.result.scalar" for the Confidence Intervals of Model Results (scalar) section.

  • "cred.mod.result" for the Credibility Intervals of Model Results section.

  • "cred.mod.result.config" for the Credibility Intervals of Model Results (configural) section.

  • "cred.mod.result.metric" for the Credibility Intervals of Model Results (metric) section.

  • "cred.mod.result.scalar" for the Credibility Intervals of Model Results (scalar) section.

  • "std.mod.result" for the Standardized Model Results section.

  • "conf.std.mod.result" for the Confidence Intervals of Standardized Model Results section.

  • "cred.std.mod.result" for the Credibility Intervals of Standardized Model Results section.

  • "rsquare" for the R-Square section.

  • "rsquare.config" for the R-Square (configural) section.

  • "rsquare.metric" for the R-Square (metric) section.

  • "rsquare.scalar" for the R-Square (scalar) section.

  • "irt.param" for the IRT Parameterization section.

  • "irt.param.config" for the IRT Parameterization (configural) section.

  • "irt.param.metric" for the IRT Parameterization (metric) section.

  • "irt.param.scalar" for the IRT Parameterization (scalar) section.

  • "modind" for the Model Modification Indices section.

  • "prob.scale" for the Results in Probability Scale section.

  • "prob.scale.config" for the Results in Probability Scale (configural) section.

  • "prob.scale.metric" for the Results in Probability Scale (metric) section.

  • "prob.scale.scalar" for the Results in Probability Scale (scalar) section.

  • "odds.ratio" for the Logistic Regression Odds Ratio Results section.

  • "conf.prob.scale" for the Confidence Intervals in Probability Scale section.

  • "conf.prob.scale.config" for the Confidence Intervals in Probability Scale (configural) section.

  • "conf.prob.scale.metric" for the Confidence Intervals in Probability Scale (metric) section.

  • "conf.prob.scale.scalar" for the Confidence Intervals in Probability Scale (scalar) section.

  • "cred.prob.scale" for the Credibility Intervals in Probability Scale section.

  • "cred.prob.scale.config" for the Credibility Intervals in Probability Scale (configural) section.

  • "cred.prob.scale.metric" for the Credibility Intervals in Probability Scale (metric) section.

  • "cred.prob.scale.scalar" for the Credibility Intervals in Probability Scale (scalar) section.

  • "ind.odds.ratio" for the Latent Class Indicator Odds Ratios for the Latent Classes section.

  • "ind.odds.ratio.config" for the Latent Class Indicator Odds Ratios for the Latent Classes (configural) section.

  • "ind.odds.ratio.metric" for the Latent Class Indicator Odds Ratios for the Latent Classes (metric) section.

  • "ind.odds.ratio.scalar" for the Latent Class Indicator Odds Ratios for the Latent Classes (scalar) section.

  • "brant.wald" for the Brant Wald Test For Proportional Odds section.

  • "within.std.mod.result" for the Within-level Standardized Model Results For Each Cluster section.

  • "within.rsquare" for the Within-level R-Square For Each Cluster section.

Note that all result sections are requested by specifying result = "all". The result argument is also used to select one (e.g., result = "mod.result") or more than one result section (e.g., result = c("mod.result", "std.mod.result")). The exclude argument is used to exclude result sections from the output (e.g., exclude = "mod.result"). By default, all result sections except SUMMARY OF ANALYSIS is shown on the R console when specifying "all" or "result" for the argument print.

Value

Returns a list with Mplus input and result sections.

Author(s)

Takuya Yanagida

References

Muthen, L. K., & Muthen, B. O. (1998-2017). Mplus User's Guide (8th ed.). Muthen & Muthen.

See Also

read.mplus, write.mplus, mplus, mplus.bayes, mplus.lca, mplus.lca.summa, mplus.plot, mplus.print, mplus.run, mplus.update

Examples

## Not run: 
#————————————————————————————————————————————————————————————————————————————
# Write data, specify input, run input, and extract results

# Write Mplus data file
write.mplus(ex3_1, file = "ex3_1.dat")

# Specify Mplus input
input1 <- '
DATA:     FILE IS ex3_1.dat;
VARIABLE: NAMES ARE y1 x1 x3;
MODEL:    y1 ON x1 x3;
OUTPUT:   STANDARDIZED;
SAVEDATA: H5RESULTS = ex3_1.h5;
'

# Run Mplus input
mplus(input1, file = "ex3_1.inp")

# Example 1a: Extract results, no results are printed by default
results <- mplus.extract("ex3_1.h5")

# Print 'Model Results' section
results$mod.result

# Example 1b: Print results, print all results except 'SUMMARY OF ANALYSIS'
mplus.extract("ex3_1.h5", print = "result")

# Example 1c: Print 'Model Fit Information' section
mplus.extract("ex3_1.h5", print = "result", result = "fit")

# Example 1c: Exclude 'Standardized Model Results' section
mplus.extract("ex3_1.h5", print = "result", exclude = "std.mod.result")

# Example 1d: Print results with two digits
mplus.extract("ex3_1.h5", print = "result", digits = 2)

#————————————————————————————————————————————————————————————————————————————
# Write Results

# Example 2: Write Results into a text file
mplus.extract("ex3_1.h5", print = "result", write = "Output_3-1.txt")

## End(Not run)

misty documentation built on Nov. 24, 2026, 5:06 p.m.

Related to mplus.extract in misty...