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.
85 stars 46 forks source link

usevariables error #203

Open barneyricca opened 7 months ago

barneyricca commented 7 months ago

I am getting the following error message when trying to do parallel process latent growth curve analysis in MplusAutomation; it appears to occur in mplusModeler() and is due to an issue with usevariables:

Error in .cleanHashData(df = object$rdata, keepCols = object$usevariables, :

Assertion on 'df' failed: Must be of type 'data.frame', not 'NULL'.

The behavior:

I have confirmed that the Mplus object runs in the Mplus editor. I reproduce the object here exactly as it is in the .inp for Mplus and in the call to mplusObject(). The dataset is simulated data, but includes all 26 variables. TITLE = "PP-LCGM;", DATA = "File is schools.dat", VARIABLE = "Names are ID class AUT1-AUT8 RET1-RET8 COT1-COT8; USEVARIABLES ARE AUT1-AUT8 RET1-RET8 COT1-COT8; CLUSTER = class; CLASSES = c (5);",

ANALYSIS = "TYPE = COMPLEX MIXTURE;

ITERATIONS = 1000; PROCESSORS = 4(STARTS); STARTS = 1000 50;",

MODEL = "%OVERALL% i1 s1 |AUT1@0 AUT2@1 AUT3@2 AUT4@3 AUT5@4 AUT6@5 AUT7@6 AUT8@7; i1 @ 0; s1 @0;

i2 s2 |RET1@0 RET2@1 RET3@2 RET4@3 RET5@4 RET6@5 RET7@6 RET8@7; i2 @ 0; s2 @0;

i3 s3 |COT1@0 COT2@1 COT3@2 COT4@3 COT5@4 COT6@5 COT7@6 COT8@7; i3 @ 0; s3 @0;

AUT1 with RET1 COT1; RET1 with COT1; AUT2 with RET2 COT2; RET2 with COT2; AUT3 with RET1 COT3; RET3 with COT3; AUT4 with RET4 COT4; RET4 with COT4; AUT5 with RET5 COT5; RET5 with COT5; AUT6 with RET6 COT6; RET6 with COT6; AUT7 with RET7 COT7; RET7 with COT7; AUT8 with RET8 COT8; RET8 with COT8;",

OUTPUT = "TECH11 STDYX TECH7 ;", PLOT =
"series=AUT1-AUT8() RET1-RET8() COT1-COT8(*); type= plot3;",

SAVEDATA = "FILE is class_outcomes.csv; save=CPROB;"

JWiley commented 7 months ago

Hi,

It is looking for rdata and usevariables to be passed. The intention of mplusModeler() and mplusObject() is that the data are in R and get created for Mplus for you. If you are just trying to run existing Mplus code, you're better off with runModels()

Look at examples from ?mplusModeler() for how it generally gets setup.

Best wishes,

Josh

On Tue, 9 Apr 2024 at 21:44, Bernard (Barney) Ricca < @.***> wrote:

I am getting the following error message when trying to do parallel process latent growth curve analysis in MplusAutomation; it appears to occur in mplusModeler() and is due to an issue with usevariables:

Error in .cleanHashData(df = object$rdata, keepCols = object$usevariables, : Assertion on 'df' failed: Must be of type 'data.frame', not 'NULL'.

The behavior:

  • If I include a line such as "USEVARIABLES ARE AUT1-AUT8 RET1-RET8 COT1-COT8;" in the VARIABLE definition, the call to mplusObject() throws the error. If I leave that line out, mplusObject() does not throw the error, but the call to mplusModeler() does.
  • If I include that line but also add a "usevariables = colnames(schools)" (where schools is a defined data frame) then the error is thrown by mplusModeler()

I have confirmed that the Mplus object runs in the Mplus editor. I reproduce the object here exactly as it is in the .inp for Mplus and in the call to mplusObject(). The dataset is simulated data, but includes all 26 variables. TITLE = "PP-LCGM;", DATA = "File is schools.dat", VARIABLE = "Names are ID class AUT1-AUT8 RET1-RET8 COT1-COT8; USEVARIABLES ARE AUT1-AUT8 RET1-RET8 COT1-COT8; CLUSTER = class; CLASSES = c (5);",

ANALYSIS = "TYPE = COMPLEX MIXTURE;

ITERATIONS = 1000; PROCESSORS = 4(STARTS); STARTS = 1000 50;",

MODEL = "%OVERALL% i1 s1 @. @. @. @. @. @. @. @.; i1 @ 0; s1 @0 https://github.com/0;

i2 s2 @. @. @. @. @. @. @. @.; i2 @ 0; s2 @0 https://github.com/0;

i3 s3 @. @. @. @. @. @. @. @.; i3 @ 0; s3 @0 https://github.com/0;

AUT1 with RET1 COT1; RET1 with COT1; AUT2 with RET2 COT2; RET2 with COT2; AUT3 with RET1 COT3; RET3 with COT3; AUT4 with RET4 COT4; RET4 with COT4; AUT5 with RET5 COT5; RET5 with COT5; AUT6 with RET6 COT6; RET6 with COT6; AUT7 with RET7 COT7; RET7 with COT7; AUT8 with RET8 COT8; RET8 with COT8;",

OUTPUT = "TECH11 STDYX TECH7 ;", PLOT = "series=AUT1-AUT8() RET1-RET8() COT1-COT8(*); type= plot3;",

SAVEDATA = "FILE is class_outcomes.csv; save=CPROB;"

— Reply to this email directly, view it on GitHub https://github.com/michaelhallquist/MplusAutomation/issues/203, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACOZHHSNJDT3MGLBVVEPI3Y4PIATAVCNFSM6AAAAABF6NCMI6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGIZTGMRVGI3TANY . You are receiving this because you are subscribed to this thread.Message ID: @.***>