Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Saving error message

    Hi all,

    I am using a plug-in called traj from https://www.andrew.cmu.edu/user/bjones/strtxmpl2.htm. It is a group based trajectory model, an example of a finite mixture model, using maximum likelihood estimation to estimate the model parameters. I am at the moment running loops to establish the correct number of trajectories and their polynomial order. Basically it runs thousands of combinations and based on different criterias (BIC, AIC entropy) which I will use to decide on the appropriate number of trajectories (groups) and polynomials. I am saving all combinations in a matrix for later evaluation.

    However.
    Some of the combinations does not converge and others are to sparse (to few members in one cluster/trajectory). When this happens I get a warning message in red text in the Results window (for example "Warning: variance matrix is nonsymmetric or highly singular"). This is important information for me, since this indicates that the specific groupsize - polynomial combination might not be appropiate to use in the final model.
    But is there a way to save the warning message in to a matrix? It is not reported in e() according to the help file...

    All the best,

    /Jesper


  • #2
    Will the -capture- command do what you want? It stores any return codes in a scalar.

    Comment


    • #3
      Originally posted by Paul Dickman View Post
      Will the -capture- command do what you want? It stores any return codes in a scalar.
      Unfortunately not. I hoped so, but the warning message does not contain an error code and as such is not possible to save to a scalar via capture. When I try, scalar _rc is "0" (menaning no error code).
      The warning message simply states ""Warning: variance matrix is nonsymmetric or highly singular" in red. No error code.

      Thanks anyway, appreciate that you tried to help!

      /Jesper

      Comment


      • #4
        if the warning is issued by the plugin, you may need the program author to change the code. Depends what language it is written in, and what Stata hooks are allowed, but one ideal option is to send a local macro to the caller space.

        Comment


        • #5
          Originally posted by Nick Cox View Post
          if the warning is issued by the plugin, you may need the program author to change the code. Depends what language it is written in, and what Stata hooks are allowed, but one ideal option is to send a local macro to the caller space.
          It is written in C.

          Thanks, but I don't understand what you mean by sending a local macro to the caller space. Can you guide me in the right direction?
          Last edited by Jesper Eriksson; 17 Dec 2019, 12:58.

          Comment


          • #6
            I have never used the plug-in question. However, here are some thoughts:

            1. Some estimation commands, e.g., sem return in e(converged) whether the model has converged. The plug-in might return something similar. Run a model, then type

            Code:
            ereturn , all
            return , all
            to inspect all returned results.

            2. If the problem can be inferred from the variance matrix and if the variance matrix is returned, you could inspect the matrix outside of the trja environment.

            3. If everything else fails, you might want to log the output and parse the log-file to extract the respective warning message.

            Best
            Daniel

            Comment


            • #7
              Originally posted by daniel klein View Post
              I have never used the plug-in question. However, here are some thoughts:

              1. Some estimation commands, e.g., sem return in e(converged) whether the model has converged. The plug-in might return something similar. Run a model, then type

              Code:
              ereturn , all
              return , all
              to inspect all returned results.

              2. If the problem can be inferred from the variance matrix and if the variance matrix is returned, you could inspect the matrix outside of the trja environment.

              3. If everything else fails, you might want to log the output and parse the log-file to extract the respective warning message.

              Best
              Daniel
              Thanks Daniel, i tried ereturn and return. Unfortunately it only saves an error code of "0" in e(rc), regardless of error actually presented or not. It seems that the code only states a message but is not linking the message to an error code. It always produces e(rc) = 0.

              I think I have to log the results and scan them for the various error messages. Thanks all!

              Comment


              • #8
                I had in mind pushing a local macro as a flag into the caller space perhaps using (some equivalent of) c_local

                https://www.stata.com/statalist/arch.../msg00385.html

                but I have never written or modified or even used plugins and I can't see the source code here, so all that disqualifies me from adding more. I think you need to contact the program authors, not obviously active here,

                Comment


                • #9
                  Hello all,

                  I am having similar issues with the traj command. Specifically, I am looking at thousands of medical patients across time and trying to understand dose across time. What I am hoping to see is that there might be people starting at a 1) high dose, ending at a low dose 2) starting at a high dose, ending at a high dose, 3 ) starting at a low dose, ending at a low dose, 4) starting at a low dose, ending at a high dose. Im not sure if this is how the model works, or I am just biased in the content area that I am looking into. From my understanding, stata will eventually tell me how many groups the data could give me.

                  I am receiving the same error message as above " Warning: variance matrix is nonsymmetric or highly singular". The plot output is basically several horizontal straight lines across the x axis.

                  Im not quite sure what is wrong...I dont fully understand the trajectory code since Ive just started playing around with it. Could it be because of the distribution of the data? needing to fit a poisson model? If I try a poisson model it asks for start date because it cannot estimate that on its own.

                  Any help to get me started? im quite in the dark here
                  Last edited by Alexandra Kritikos; 04 Feb 2020, 08:59.

                  Comment


                  • #10
                    Originally posted by Alexandra Kritikos View Post
                    Hello all,

                    I am having similar issues with the traj command. Specifically, I am looking at thousands of medical patients across time and trying to understand dose across time. What I am hoping to see is that there might be people starting at a 1) high dose, ending at a low dose 2) starting at a high dose, ending at a high dose, 3 ) starting at a low dose, ending at a low dose, 4) starting at a low dose, ending at a high dose. Im not sure if this is how the model works, or I am just biased in the content area that I am looking into. From my understanding, stata will eventually tell me how many groups the data could give me.

                    I am receiving the same error message as above " Warning: variance matrix is nonsymmetric or highly singular". The plot output is basically several horizontal straight lines across the x axis.

                    Im not quite sure what is wrong...I dont fully understand the trajectory code since Ive just started playing around with it. Could it be because of the distribution of the data? needing to fit a poisson model? If I try a poisson model it asks for start date because it cannot estimate that on its own.

                    Any help to get me started? im quite in the dark here
                    Hi, sorry for the late reply.

                    Could you provide an example of your dataset and your code? Use the command "dataset" in Stata, just type help dataset and install.

                    Regarding start date, how do you specify your time variable?

                    All the best,

                    Jesper

                    Comment

                    Working...
                    X