michaelhallquist / MplusAutomation

The MplusAutomation package leverages the flexibility of the R language to automate latent variable model estimation and interpretation using Mplus, a powerful latent variable modeling program developed by Muthen and Muthen (www.statmodel.com). Specifically, MplusAutomation provides routines for creating related groups of models, running batches of models, and extracting and tabulating model parameters and fit statistics.
84 stars 46 forks source link

No Data/ No Output for Montecarlo simulation #110

Closed mroshanaei closed 4 years ago

mroshanaei commented 4 years ago

Hi,

I'm running an example using MonteCarlo (power analysis) to check for the number of observations, etc. Therefore we don't have any data. Our model is working on Mplus, but when I run it on R is not working, the output is empty. Any idea what is the problem? We don't have any data, Mplus is also simulating the data, which should be the same here right?

Here is the code:

montecarlo <- mplusObject( TITLE = "EMA Power Analysis;", MONTECARLO = " NAMES are Stressed lag_Stressed NgDisRatio PsDisRatio; NOBSERVATIONS = 67200; NREPS = 100; SEED = 2020; CSIZES = 800 (84); WITHIN = lag_Stressed NgDisRatio PsDisRatio; MISSING = Stressed;", ANALYSIS = " TYPE = TWOLEVEL RANDOM;", MODELPOPULATION = " %WITHIN% slope | Stressed ON NgDisRatio; Stressed ON lag-Stressed0.54957; Stressed ON PsDisRatio-0.18219; [lag_Stressed3.131349]; lag_Stressed1.432338; [PsDisRatio0.3961094]; PsDisRatio0.2019174; [NgDisRatio0.3064143]; NgDisRatio0.1930179; %BETWEEN& [Stressed1.312]; Stressed0.046; [slope0.38058]; slope0.01574;", MODELMISSING = " [Stressed@-2]; Stressed ON lag-Stressed.4 NgDisRatio.5 PsDisRatio.5;", MODEL = " %WITHIN% slope | Stressed ON NgDisRatio; Stressed ON lag-Stressed0.54957; Stressed ON PsDisRatio-0.18219; [lag_Stressed3.131349]; lag_Stressed1.432338; [PsDisRatio0.3961094]; PsDisRatio0.2019174; [NgDisRatio0.3064143]; NgDisRatio0.1930179; %BETWEEN& [Stressed1.312]; Stressed0.046; [slope0.38058]; slope*0.01574;", OUTPUT = "TECH9;" )

fitMonteCarlo <- mplusModeler(montecarlo, modelout = "montecarlo.inp", run = 1L, writeData = "always", hashfilename = FALSE)

library(texreg) screenreg(fitMonteCarlo, summaries = c("Observations", "CFI", "SRMR"), single.row=TRUE)

snlstanford commented 4 years ago

Any answer here?

michaelhallquist commented 4 years ago

Hi there,

Your Mplus syntax appears to have a problem. Take a look at fitMonteCarlo$results$errors. It looks like you need to specify NCSIZES. I've also attached here the full output file. In general, if you have a model that errors out, it is probably worth looking at the .out file directly to diagnose it, though the $results$errors field should parse these messages.

I'm going to close this for now, but if you identify a problem with the package itself for your application, feel free to reopen the issue.

Best, Michael

montecarlo.out.txt

> fitMonteCarlo$results$errors
[[1]]
[1] "The NCSIZES option must be specified to generate clustered data for" "TYPE=TWOLEVEL."                                                     
attr(,"section")
[1] "montecarlo"

attr(,"class")
[1] "list"         "mplus.errors"
snlstanford commented 4 years ago

Hi Michael,

It's not actually making any error! but it's not creating any output in R. In Mplus is working. My problem is that why it's working in Mplus but not in R?

Thanks, Mahnaz

michaelhallquist commented 4 years ago

Hi Mahnaz,

I can't help you figure this out unless you can upload a syntax that is valid in Mplus 8.3. The one you sent won't run for me, so I can't make it further in diagnosing the problem. What if you fix the NCSIZES problem and upload a working syntax file?

Michael

mroshanaei commented 4 years ago

Hi Michael,

Here is the results I can see in R. Can you please guide me how I can read it, since there is not any of outputs from MPlus, here. I'm wondering if you can send me any documentation that can help me to understand the output.

I appreciate your help.

Best, Mahnaz

fitMonteCarlo$results

$input $title [1] " EMA Power Analysis;"

$montecarlo $montecarlo$names [1] "Stressed lag_Stressed NgDisRatio PsDisRatio"

$montecarlo$nobservations [1] "67200"

$montecarlo$nreps [1] "100"

$montecarlo$seed [1] "2020"

$montecarlo$ncsizes [1] "67200"

$montecarlo$csizes [1] "800 (84)"

$montecarlo$within [1] "lag_Stressed NgDisRatio PsDisRatio"

$montecarlo$missing [1] "Stressed"

$model.population [1] "" ""

[3] " %WITHIN%" " slope | Stressed ON NgDisRatio;" [5] " Stressed ON lag-Stressed0.54957;" " Stressed ON PsDisRatio-0.18219;" [7] " [lag_Stressed3.131349]; lag_Stressed1.432338;" " [PsDisRatio0.3961094]; PsDisRatio0.2019174;" [9] " [NgDisRatio0.3064143]; NgDisRatio0.1930179;" " %BETWEEN%"

[11] " [Stressed1.312]; Stressed0.046;" " [slope0.38058]; slope0.01574;"

$model.missing [1] "" ""

[3] " [Stressed@-2];" " Stressed ON lag-Stressed.4 NgDisRatio.5 PsDisRatio*.5;"

$analysis $analysis$type [1] "TWOLEVEL RANDOM"

$model [1] "" ""

[3] " %WITHIN%" " slope | Stressed ON NgDisRatio;" [5] " Stressed ON lag-Stressed0.54957;" " Stressed ON PsDisRatio-0.18219;" [7] " [lag_Stressed3.131349]; lag_Stressed1.432338;" " [PsDisRatio0.3961094]; PsDisRatio0.2019174;" [9] " [NgDisRatio0.3064143]; NgDisRatio0.1930179;" " %BETWEEN%"

[11] " [Stressed1.312]; Stressed0.046;" " [slope0.38058]; slope0.01574;"

$output [1] "" " TECH9;" ""

$data $data$file character(0)

attr(,"class") [1] "list" "mplus.inp" attr(,"start.line") [1] 6 attr(,"end.line") [1] 52

$warnings list() attr(,"class") [1] "list" "mplus.warnings"

$errors [[1]] [1] "The number of pairs of cluster size and cluster per size does match the" [2] "number of clusters specified in the NCSIZES option."

attr(,"section") [1] "montecarlo"

attr(,"class") [1] "list" "mplus.errors"

$data_summary list() attr(,"class") [1] "list" "mplus.data_summary"

$sampstat list() attr(,"class") [1] "list" "mplus.sampstat"

$covariance_coverage list()

$summaries Mplus.version Title AnalysisType DataType Filename 1 8.3 EMA Power Analysis; TWOLEVEL RANDOM MONTECARLO montecarlo.out

$invariance_testing list()

$parameters list()

$class_counts list()

$indirect list()

$residuals list()

$tech1 list()

$tech3 list()

$tech4 list()

$tech7 list()

$tech8 $psr data frame with 0 columns and 0 rows

attr(,"class") [1] "list" "mplus.tech8"

$tech9 list() attr(,"class") [1] "list" "mplus.tech9"

$tech12 list() attr(,"class") [1] "list" "mplus.tech12"

$tech15 $conditional.probabilities character(0)

attr(,"class") [1] "list" "mplus.tech15"

$fac_score_stats list() attr(,"class") [1] "list" "mplus.facscorestats"

$gh5 list()

attr(,"class") [1] "mplus.model" "list" attr(,"filename") [1] "montecarlo.out"

On Wed, Oct 23, 2019 at 2:27 PM michaelhallquist notifications@github.com wrote:

Hi Mahnaz,

I can't help you figure this out unless you can upload a syntax that is valid in Mplus 8.3. The one you sent won't run for me, so I can't make it further in diagnosing the problem. What if you fix the NCSIZES problem and upload a working syntax file?

Michael

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/michaelhallquist/MplusAutomation/issues/110?email_source=notifications&email_token=AAY4C6F4G5PTAXIQUO4JV7TQQC6VDA5CNFSM4I76ZMYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECC537A#issuecomment-545644028, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY4C6DOVAAPTSS2P4LC3ALQQC6VDANCNFSM4I76ZMYA .

mroshanaei commented 4 years ago

Hi Micheal,

It worked, still if there is a good documentation would be great if you can send it to me.

I really appreciate your help.

Best, Mahnaz

On Fri, Nov 22, 2019 at 2:57 PM Mahnaz Roshanaei < Mahnaz.Roshanaei@colorado.edu> wrote:

Hi Michael,

Here is the results I can see in R. Can you please guide me how I can read it, since there is not any of outputs from MPlus, here. I'm wondering if you can send me any documentation that can help me to understand the output.

I appreciate your help.

Best, Mahnaz

fitMonteCarlo$results

$input $title [1] " EMA Power Analysis;"

$montecarlo $montecarlo$names [1] "Stressed lag_Stressed NgDisRatio PsDisRatio"

$montecarlo$nobservations [1] "67200"

$montecarlo$nreps [1] "100"

$montecarlo$seed [1] "2020"

$montecarlo$ncsizes [1] "67200"

$montecarlo$csizes [1] "800 (84)"

$montecarlo$within [1] "lag_Stressed NgDisRatio PsDisRatio"

$montecarlo$missing [1] "Stressed"

$model.population [1] "" ""

[3] " %WITHIN%" " slope | Stressed ON NgDisRatio;" [5] " Stressed ON lag-Stressed0.54957;" " Stressed ON PsDisRatio-0.18219;" [7] " [lag_Stressed3.131349]; lag_Stressed1.432338;" " [PsDisRatio0.3961094]; PsDisRatio0.2019174;" [9] " [NgDisRatio0.3064143]; NgDisRatio0.1930179;" " %BETWEEN%"

[11] " [Stressed1.312]; Stressed0.046;" " [slope0.38058]; slope0.01574;"

$model.missing [1] "" ""

[3] " [Stressed@-2];" " Stressed ON lag-Stressed.4 NgDisRatio.5 PsDisRatio*.5;"

$analysis $analysis$type [1] "TWOLEVEL RANDOM"

$model [1] "" ""

[3] " %WITHIN%" " slope | Stressed ON NgDisRatio;" [5] " Stressed ON lag-Stressed0.54957;" " Stressed ON PsDisRatio-0.18219;" [7] " [lag_Stressed3.131349]; lag_Stressed1.432338;" " [PsDisRatio0.3961094]; PsDisRatio0.2019174;" [9] " [NgDisRatio0.3064143]; NgDisRatio0.1930179;" " %BETWEEN%"

[11] " [Stressed1.312]; Stressed0.046;" " [slope0.38058]; slope0.01574;"

$output [1] "" " TECH9;" ""

$data $data$file character(0)

attr(,"class") [1] "list" "mplus.inp" attr(,"start.line") [1] 6 attr(,"end.line") [1] 52

$warnings list() attr(,"class") [1] "list" "mplus.warnings"

$errors [[1]] [1] "The number of pairs of cluster size and cluster per size does match the" [2] "number of clusters specified in the NCSIZES option."

attr(,"section") [1] "montecarlo"

attr(,"class") [1] "list" "mplus.errors"

$data_summary list() attr(,"class") [1] "list" "mplus.data_summary"

$sampstat list() attr(,"class") [1] "list" "mplus.sampstat"

$covariance_coverage list()

$summaries Mplus.version Title AnalysisType DataType Filename 1 8.3 EMA Power Analysis; TWOLEVEL RANDOM MONTECARLO montecarlo.out

$invariance_testing list()

$parameters list()

$class_counts list()

$indirect list()

$residuals list()

$tech1 list()

$tech3 list()

$tech4 list()

$tech7 list()

$tech8 $psr data frame with 0 columns and 0 rows

attr(,"class") [1] "list" "mplus.tech8"

$tech9 list() attr(,"class") [1] "list" "mplus.tech9"

$tech12 list() attr(,"class") [1] "list" "mplus.tech12"

$tech15 $conditional.probabilities character(0)

attr(,"class") [1] "list" "mplus.tech15"

$fac_score_stats list() attr(,"class") [1] "list" "mplus.facscorestats"

$gh5 list()

attr(,"class") [1] "mplus.model" "list" attr(,"filename") [1] "montecarlo.out"

On Wed, Oct 23, 2019 at 2:27 PM michaelhallquist notifications@github.com wrote:

Hi Mahnaz,

I can't help you figure this out unless you can upload a syntax that is valid in Mplus 8.3. The one you sent won't run for me, so I can't make it further in diagnosing the problem. What if you fix the NCSIZES problem and upload a working syntax file?

Michael

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/michaelhallquist/MplusAutomation/issues/110?email_source=notifications&email_token=AAY4C6F4G5PTAXIQUO4JV7TQQC6VDA5CNFSM4I76ZMYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECC537A#issuecomment-545644028, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY4C6DOVAAPTSS2P4LC3ALQQC6VDANCNFSM4I76ZMYA .