You are here

Error Message - LCGA 1 Class

5 posts / 0 new
Last post
Aivil's picture
Offline
Joined: 03/14/2019 - 09:44
Error Message - LCGA 1 Class

Hello,
Could you help me understanding the following error message when fitting a 1class LCGA (Script and summary attached)?
Eventually, I obtain the results, but I am a bit skeptical due to the error message.

Fit attempt 10, fit=364650.77991012, new current best! (was 366100.551846931)Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), :
'data' must be of a vector type, was 'NULL'

Retry limit reached; solution not found. Best fit=364650.78 (started at 1881335.6) (11 attempt(s): 9 valid, 2 errors)

Thank you very much for your time!!

> mxVersion()
OpenMx version: 2.12.2 [GIT v2.12.2]
R version: R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32
Default optimizer: CSOLNP
NPSOL-enabled?: Yes
OpenMP-enabled?: No

AdminRobK's picture
Online
Joined: 01/24/2014 - 12:15
no idea about error; suggestions for your script

I have no idea how to interpret the error message you report. It doesn't look familiar to me. You may be able to get more information about what caused it if you run traceback() right after your call to mxTryHard(). Since you seem to have successfully assigned the output from mxTryHard() to symbol mxTryHard_lcga.1.means.fit and were able to run summary() on it, I'm guessing the error wasn't fatal, and probably accounts for 1 of the 2 fit attempts that mxTryHard() says ended in errors.

I should warn you that your model is unidentified. Specifically, the parameter labeled 'p1' shouldn't be free. Just fix it to 1.

Also, I suggest either using simulated annealing without mxTryHard(), or using one of the main gradient-based optimizers with mxTryHard(). One way to interpret what mxTryHard() does is that it crudely approximates simulated annealing with a deterministic gradient-based optimizer. However, if you're actually using simulated annealing, you are better off letting it do one very long run; consult the manual page for mxComputeSimAnnealing(), regarding in particular the control parameters tempStart, tempEnd, and stepsPerTemp. In fact, if you put the following compute plan into your MxModel, you can do a global search with simulated annealing and follow it up with a local search using one of the gradient-based optimizers:

plan <- omxDefaultComputePlan()
plan$steps <- list(
    SA=mxComputeSimAnnealing(),
    GD=plan$steps$GD,
    ND=plan$steps$ND,
    SE=plan$steps$SE,
    HQ=plan$steps$HQ,
    RD=plan$steps$RD,
    RE=plan$steps$RE
)
Aivil's picture
Offline
Joined: 03/14/2019 - 09:44
Thank you so much for your detailed reply.

Very helpful comments, I'll check everything out!!!!

Aivil's picture
Offline
Joined: 03/14/2019 - 09:44
Implementation of Simulated Annealing - Question

Hello,
I have tried implementing the Simulated Annealing as suggested.

However, I am having a hard time in finding examples out in the forum or in the internet. The only source I have found is this one: https://rdrr.io/github/OpenMx/OpenMx/src/inst/models/passing/DogChain.R

I have tried running this piece of code for a GMM instead that for a LCGA, and after one day waiting it was still running. Is there something wrong with my code related to mxComputeSimAnnealing? Any advice?

gmm.2.means <- mxModel('2Class Means Growth Mixture Model',
mxData(observed=OpenMx_dfwide_poster1, type='raw'),
class1, class2, classRP, classP, algObj, obj, mxComputeSimAnnealing(plan = plan, method='tsallis1996', control=list(stepsPerTemp=3)))

Attached the whole code.
Many thanks for your help.

AdminRobK's picture
Online
Joined: 01/24/2014 - 12:15
plan

Define plan like this:

plan <- omxDefaultComputePlan()
plan$steps <- list(
  SA=mxComputeSimAnnealing(method='tsallis1996', control=list(stepsPerTemp=3)),
  GD=plan$steps$GD,
  ND=plan$steps$ND,
  SE=plan$steps$SE,
  HQ=plan$steps$HQ,
  RD=plan$steps$RD,
  RE=plan$steps$RE
)

And, define your main MxModel like this:

gmm.2.means <- mxModel('2Class Means Growth Mixture Model',
                       mxData(observed=OpenMx_dfwide_poster1, type='raw'),
                       class1, class2, classRP, classP, algObj, obj,  plan)

Note that simulated annealing is not user-interruptible in OpenMx v2.12.2. That's a bug that has been repaired in the source repository, and will be repaired in the next release of OpenMx (which will likely happen by the end of the month).