{smcl}
{hline}
Help file for {hi:runmplus}
{hline}

{p 4 4 2}
Build a Mplus data file, command file, execute the command file 
and display Mplus log file in Stata results window. Parameter estimates,
standard errors, and model and fit statistics are stored as saved 
results. {cmd:runmplus} is a modification and extension of Michael Mitchell's 
{help stata2mplus} module (see http://www.ats.ucla.edu/stat/Stata/). The 
Mplus demo version and new version 6 Bayesian estimator options are supported.

{hline}

{p 8 17 2}
{cmd: runmplus} varlist [if] [in] , 
 [ 
 {hi:SAVEINPutfile(}{it:string}{hi:)} 
 {hi:SAVELOGfile(}{it:string}{hi:)} 
 {hi:saveinputdatafile(}{it:string}{hi:)}
 {hi:log(}{it:string}{hi:)}
 {hi:TItle(}{it:string}{hi:)} 
 {hi:DATa(}{it:string}{hi:)} 
 {hi:VARiable(}{it:string}{hi:)} 
 {hi:DEFine(}{it:string}{hi:)} 
 {hi:ANalysis(}{it:string}{hi:)} 
 {hi:MOdel(}{it:string}{hi:)}
 {hi:OUTput(}{it:string}{hi:)} 
 {hi:savedata(}{it:string}{hi:)}
 {hi:PLOT(}{it:string}{hi:)}
 {hi:mc(}{it:string}{hi:)}
 {hi:montecarlo(}{it:string}{hi:)}
 {hi:population(}{it:string}{hi:)}
 {hi:TItle(}{it:string}{hi:)} 
 {hi:demo6} 
 {hi:{it:Mplus_command_option_shortcuts}}
 {hi:{it:Special_postestimation_commands_options}}
 ]

{p 15 15 2}
 {hi:{it:Mplus command option shortcuts:}}

{p 17 17 2}
 {cmd:missing(}{it:#}{hi:)}
 {hi:IDvariable(}{it:string}{hi:)} 
 {hi:NGroups(}{it:string}{hi:)} 
 {hi:CATegorical(}{it:string}{hi:)} 
 {hi:GROUPing(}{it:string}{hi:)} 
 {hi:weight(}{it:string}{hi:)} 
 {hi:CLUSter(}{it:string}{hi:)} 
 {hi:within(}{it:string}{hi:)} 
 {hi:between(}{it:string}{hi:)} 
 {hi:tscores(}{it:string}{hi:)} 
 {hi:centering(}{it:string}{hi:)} 
 {hi:ttype(}{it:string}{hi:)}

{p 17 17 2}
 {hi:type(}{it:string}{hi:)} 
 {hi:ESTimator(}{it:string}{hi:)} 
 {hi:MATrix(}{it:string}{hi:)} 
 {hi:PARAMeterization(}{it:string}{hi:)}
 {hi:VARiance(}{it:string}{hi:)} 
 {hi:ITERations(}{it:string}{hi:)} 
 {hi:SDITERations(}{it:string}{hi:)} 
 {hi:H1ITERations(}{it:string}{hi:)}
 {hi:MITERations(}{it:string}{hi:)} 
 {hi:MCITERations(}{it:string}{hi:)} 
 {hi:MUITERations(}{it:string}{hi:)} 
 {hi:CONvergence(}{it:string}{hi:)}
 {hi:H1CONvergence(}{it:string}{hi:)} 
 {hi:COVERage(}{it:string}{hi:)} 
 {hi:logcriterion(}{it:string}{hi:)} 
 {hi:MCONVergence(}{it:string}{hi:)}
 {hi:MCCONVergence(}{it:string}{hi:)} 
 {hi:MUCONVergence(}{it:string}{hi:)} 
 {hi:mixc(}{it:string}{hi:)} 
 {hi:mixu(}{it:string}{hi:)}
 {hi:LOGHigh(}{it:string}{hi:)} 
 {hi:LOGLow(}{it:string}{hi:)} 
 {hi:UCELLsize(}{it:string}{hi:)} 
 {hi:ALGOrithm(}{it:string}{hi:)}

{p 17 17 2}
 {hi:SAMPStat} 
 {hi:MODindices(}{it:string}{hi:)} 
 {hi:STANDardized} 
 {hi:RESidual} 
 {hi:CINTerval} 
 {hi:NOCHIsquare}
 {hi:h1se} 
 {hi:H1TEch3} 
 {hi:PATterns} 
 {hi:FSCOEFficeint} 
 {hi:FSDETerminacy} 
 {hi:tech(}{it:string}{hi:)}
 {hi:population(}{it:string}{hi:)}
 {hi:loadresults}
 {hi:varnocheck}




{title:Required commands}

{p 0 8 2}
{cmd:varlist} - Variables to be used in the Mplus model. This command
is not actually required. If it's left blank runmplus will assume
you want all of the variables, unless there is text in the {hi:MC} or 
{hi:montecarlo} commands. NOTE: This varlist can be a STATA abbreviated 
varlist. Keep in mind that Mplus and STATA expand varlists differently, 
and what works in STATA may not work in Mplus. For example, the 
abbreviated list y1-x3 will identify all variables falling 
between and including y1 and x3, and will work as a varlist 
in this command. However, you couldn't use the option 
{hi: categorical y1-x3} because Mplus can't expand such a varlist.


{title:Options}

{p 0 8 2}
{cmd:demo6} - If you have both the demo version 6 and another 
version of Mplus, {cmd:demo6} will force a call to the Mplus 
demo version 6. If you only have the demo version, you 
do NOT need to specify this option. {hi:runplus} will find the 
right executable so long as they are in the default install 
locations. Specify "demo6" if running the demo version 6 of Mplus. 
No other demo versions are supported but you could edit the ado 
to achieve that (c. line 600). 

{p 0 8 2}
{cmd:missing} - Specify number for missing values, default -9999

{p 0 8 2}
{cmd:SAVEINPutfile(}{it:string}{hi:)} , 

{p 0 8 2}
{cmd:SAVELOGfile(}{it:string}{hi:)} and 

{p 0 8 2}
{cmd:saveinputdatafile(}{it:string}{hi:)} - {cmd:runplus} 
uses temporary file names to store the Mplus command file 
and data file. By default, these are not saved. If the 
user wishes to have these files to review after execution 
of {hi:runplus}, file names can be specified 
using the three save options. DOS shell copy 
commands are used and replacement of existing files 
will occur. NOTE: don't include the 
suffexes (inp, out, dat).

{p 0 8 2}
{cmd:log(string)} - if "off" is specified, runmplus 
supresses the dump of the Mplus output file 
to the STATA results window. Any other entry will have
no influence on runmplus processing.  Can be used at the 
same time as {cmd:savelogfile}. 

{p 0 8 2}
{hi:{it:Mplus_command_file_options}} - See below and the 
Mplus Users Guide. The Mplus command file options are 
captured as strings and placed into a ascii file that 
is sent to the {it:Mplus} program. You can put anything 
you want in any of these options, but only options that 
make sense to {it: Mplus} will be useful. Modifications or 
special circumstances are addressed in the next section.


{title:Description}

{p 4 4 2}
{cmd:runmplus} brings the powerful latent variable analysis 
capabilities of {it:Mplus} (see www.statmodel.com) into the 
Stata enviroment. While {cmd:runmplus} does little more than 
data reformat and ascii file creation, it removes a lot of 
the hassle of estimating categorical and continuous latent 
variable models using Mplus. {cmd:runmplus} is a 
modification and extension of Michael Mitchell's 
{cmd:stata2mplus} module (see 
http://www.ats.ucla.edu/stat/Stata/). The {cmd:runmplus} 
module does a number of tasks:

{p 4 8 2}
(1) creates an ascii data file suitable for use with Mplus 
using code from stata2mplus, and also 

{p 4 8 2}
(2) creates a mplus command file using options specified, 

{p 4 8 2}
(3) executes the mplus command file using the dos shell 
command feature, and

{p 4 8 2}
(4) dumps the Mplus model results to the screen/log 
(unless directed not to by the user using {cmd:log(off)}).

{p 4 4 2}
{it:Mplus} is required to use this STATA module. If you
don't have Mplus, visit www.statmodel.com.
Moreover, {cmd:runmplus} assumes mplus.exe is located 
in the windows path (or that mpdemo6.exe is in c:\program files\mplus demo\).
{cmd: runmplus} will not check code for errors. {cmd:runmplus} can't be 
used efficiently without an understanding of the Mplus 
command syntax.


{title:Known Bugs and Limitations}

{p 4 4 2}
Long variable names: Mplus does not support long variable names, so neither does {hi:runmplus}. 
Your runmplus/Mplus file will run with a long file name so long as the first 
eight characters are unique. It'd be better to make them short in STATA first.

{p 4 4 2}
{cmd:runmplus} will not allow you to use the PLOT option in Mplus.

{p 4 4 2}
{cmd:runmplus} may have trouble reading parameter estimates when more than 
one latent class variable is used. Use the {hi: saveinp} and {hi: saveinputdatafile }
options and run the model from Mplus.


{title:Examples}
{hline}

Simple linear regression for a continuous dependent variable

{p 8 8 2}
. {hi:runmplus y1 x1 x3, model(y1 on x1 x3;)}


Logistic regression 

{p 8 8 2}
. {hi:runmplus y1 x1 x3, categorical(y1) type(logistic) model(y1 on x1 x3;)}


Path analysis with continuous dependent variables

{p 8 8 2}
. {hi:runmplus y1-y3 x1-x3, model(y1 y2 on x1 x2 x3; y3 on y1 y2 x2;)}


Path analysis with categorical dependent variables

{p 8 8 2}
. {hi:runmplus y1-y3 x1-x3, categorical(y1 y2 y3) model(y1 y2 on x1 x2 x3; y3 on y1 y2 x2;)}


Path analysis with a combination of continuous and categorical dependent variables

{p 8 8 2}
. {hi:runmplus y1-y3 x1-x3, categorical(y3) model(y1 y2 on x1 x2 x3; y3 on y1 y2 x2;)}


Exploratory factor analysis with continuous indicators

{p 8 8 2}
. {hi: runmplus y1-y12, type(efa 1 4)}


Exploratory factor analysis with categorical indicators

{p 8 8 2}
. {hi: runmplus y1-y12, type(efa 1 4) categorical(all)}


Exploratory factor analysis with a mixture of categorical and continuous indicators

{p 8 8 2}
. {hi: runmplus y1-y12, type(efa 1 4) categorical(y1 y3 y5 y7 y9 y11)}


Confirmatory factor analysis with continuous indicators

{p 8 8 2}
. {hi: runmplus y1-y6, model(f1 by y1-y3; f2 by y4-y6;)}

Confirmatory factor analysis with continuous indicators and equality constraints, 
using {hi:savedata} and {hi:savelogfile} options, and 
following up with {hi: runmplus_load_savedata} bringing the factor estimates
back into the current data set

{p 8 8 1}
. {hi: runmplus y1-y6 id , idvariable(id) /// }

{p 11 8 1}
   {hi: model(f by y1-y6 *1 (1); f@1; [y1-y6 *0] ; y1-y6 *1 (2) ;) /// }
   
{p 11 8 1}
   {hi: savedata(save=fscores; file=c:\trash\trash.dat) /// }
   
{p 11 8 1}
   {hi: savelogfile(c:\trash\trash) } // note no suffix on trash.out

{p 8 8 2}
. {hi: preserve }

{p 8 8 2}
. {hi: runmplus_load_savedata , out(c:/trash/trash.out) clear } // note with suffix on trash.out

{p 8 8 2}
. {hi: id f }

{p 8 8 2}
. {hi: sort id }

{p 8 8 2}
. {hi: tempfile f1 }

{p 8 8 2}
. {hi: save `f1' }

{p 8 8 2}
. {hi: restore }

{p 8 8 2}
. {hi: merge id using `f1' , sort }

{p 8 8 2}
. {hi: table _merge}

{p 8 8 2}
. {hi: drop _merge }


{title:Mplus Program Options}
{hline}
{p 0 8 2}
{hi:{it:Data Options not usually needed}} - The user should
not generally need to specify Mplus DATA "file", 
"format", "type", "nobservations" options. {cmd:runmplus} takes 
care of all of this for you. 

{p 0 8 2}
{hi:NGroups }- number of groups

{p 0 8 2}
{hi:{it:Variable Options not needed}} - Generally, the Mplus "names", 
"useobservations", "usevariables" will not be needed. Use 
the {hi:if} and {hi:in} statements to 
accomplish the same thing as "Useobservations", and you 
must specify a variable list so "Usevariables" is 
assumed to be all of the variables. 

{p 0 8 2}
{hi:categorical }- names of categorical dependent 
variables. Use a string Mplus will understand. 

{p 0 8 2}
{hi:Grouping }- name and label values of grouping variable.
Put text here just like you would after the GROUPING option
in Mplus. For example {hi:{it:grouping(gender(1=male 2=female))}}. 
In the model statement, refer to these groups as you would in Mplus
(eg., model(f by y1 y2; f on x; model male:; f on x; model 
female:; f on x;)). 

{p 8 8 2}
Note the semi-colon after model <group>: This helps runmplus 
parse the command line.

{p 8 8 2}
It is possible you'll get an error message or the grouping
statement won't be parsed correctly, particularly if you have a long
grouping statement. If this happens, try shortening the grouping
statement by using shorter group lablels.

{p 0 8 2}
{hi:DEFINE}- The whole 
point of this program is to allow you to do this kind 
of stuff in Stata. But, if you want it, you can specify
a Mplus option string within the {hi:DEFINE} option and
have Mplus make new variables. This might be useful
if you wanted a new variable in the Mplus analysis
but not as a part of the master data set.

{p 0 8 2}
{hi:type }- refers to "type" option in Mplus ANALYSIS 
command. The default is general. Other options include 
meanstructure, missing, H1, Mcohort, Mixture, Complex, 
Twolevel, EFA # #, Logistic.
      
{p 0 8 2}
{hi:estimator }- Mplus will recognize and implement ML, 
MLM, MLMV, GLS, WLS, WLSM, WLSMV, MLR, MLF, MLM, MLMV, 
ULS estimators if the model type can support it. If 
nothing is specified, the Mplus default estimators 
are used.

{p 0 8 2}
{hi:matrix }- matrix to be evaluated. You can put 
anything you want but Mplus will only 
allow "covariance" or "correlation"

{p 0 8 2}
{hi:tech(}{it:number list}{hi:)} - list in {it:number list} 
the technical output to be displayed (just list the numbers)

{p 2 8 2}
{hi:1 }- parameter specifications and starting values for 
all free parameters.

{p 2 8 2}
{hi:2 }- parameter derivatives.

{p 2 8 2}
{hi:3 }- estimated covariance and correlation matrices 
for the parameter estimates.

{p 2 8 2}
{hi:4 }- means and covariace and correlation matrices 
for the latent variables in the model.

{p 2 8 2}
{hi:5 }- optimization history.

{p 2 8 2}
{hi:6 }- optimization in estimating the sample statistics.

{p 2 8 2}
{hi:7 }- sample statistics for each class 
(when {hi:type(}{it:mixture}{hi:)} is used) using raw 
data weighted by the estimated class probabilities.

{p 2 8 2}
{hi:8 }- optimization history when 
{hi:type(}{it:mixture}{hi:)} is used).

{p 2 8 2}
{hi:9 }- available when MONTECARLO command is 
used when {hi:type(}{it:mixture}{hi:)} is also used, 
and produces error messages regarding convergence 
for each replication of the Monte Carlo study.

{p 2 8 2}
{hi:10 }- used in conjunction with TYPE=MIXTURE to
request univariate and bivariate model fit information 
for the categorical dependent variables in the model. 

{p 2 8 2}
{hi:11 }- used in conjunction with TYPE=MIXTURE request 
the Lo-Mendell-Rubin likelihood ratio test of model fit.

{p 2 8 2}
{hi:12 }- used in conjunction with TYPE=MIXTURE to
request residuals for observed versus model estimated means, 
variances, covariances, univariate skewness, and univariate 
kurtosis. 

{p 2 8 2}
{hi:13 }- used in conjunction with TYPE=MIXTURE to
request two-sided tests of model fit for univariate, 
bivariate, and multivariate skew and kurtosis (Mardia’s 
measure of multivariate kurtosis). 

{p 2 8 2}
{hi:14 }- used in conjunction with TYPE=MIXTURE to
request a parametric bootstrapped likelihood ratio test.


{title:Author}
{p 8 8 2}Richard N Jones, ScD{break}
Institute for Aging Research{break}
Hebrew SeniorLife, Boston, MA{break} 
jones@mail.hrca.harvard.edu

updates and other STATA+Mplus tools at http://sites.google.com/site/lvmworkshop/home/runmplus-stuff


{title:Also see}

{p 0 19}On-line: help for 
   {help stata2mplus}
   {help runmplus}
   {help runmplus_fits}
   {help read_parameterestimates_general}
   {help read_parameterestimates}
   {help read_convergence}
   {help lli}
   {p_end}