Announcement

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

  • "Flat region resulting in a missing likelihood" - stpm2 - never had this issue before

    Dear all,
    I have been using -stpm2 - to produce some amazing graphs. Never had an issue before with my code. However, more recently I applied these changes
    1. Added more tvc covariates (see bold)
    2. I slightly modified my dataset recoding treatment variable: -procedure- from 0 to 1 due to previous incorrect coding.


    My code looks like this:

    Code:
    stset survivalt [pw=attweight], failure(failure==1)
    
    rcsgen opyear, df(3) gen(yearspl) orthog
    range temptime 0 10 200
    
    ///refit model with spline
    stpm2 procedure yearspl* age charlson gender provider, scale(h) df(5) eform tvc(procedure gender age charlson) dftvc(3)
    
    ERROR: FLAT REGION RESULTING IN A MISSING LIKELIHOOD. 
    r(430)
    As mentioned, I never obtained this error before and had no issues, and produced wonderful graphs.
    If this may help, my model without the -yearspl*- variable, works with no issues.

    Code:
    stpm2 procedure age charlson gender provider, scale(h) df(5) eform tvc(procedure gender age charlson) dftvc(3)
    I am really frustrated, and perhaps desperate, as I have never had issues with this part of my code, and in fact, I was ready to start writing up !

  • #2
    Martin:
    desperation is something that should not be devoted to such a negligible issue as an ill-behaving statistical procedure.
    That said, Stata is probably telling you that you would better off with a more parsimonious model.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thanks Carlo for your words of wisdom

      The thing is my model worked before and beautifully, i.e without -age charlson- as tvc and without the changes in Post 1 - No 2.
      THis is how my original code looked:

      Code:
      stpm2 procedure yearspl* age charlson gender provider, scale(h) df(5) eform tvc(procedure gender) dftvc(3)
      Now even if I retain the original model as above

      I still get the error
      ERROR: FLAT REGION RESULTING IN A MISSING LIKELIHOOD. r(430)

      What would be your advice, as I had produced beautiful graphs before the changes in 2 Now I can't plot...
      Last edited by Martin Imelda Borg; 31 Dec 2023, 05:46.

      Comment


      • #4
        Martin:
        it may well be that the small changes you made in your dataset/model specification are the culprits.
        That said, if your data generating process is captured in full in your first model (that is, the one that ran smoothly) I would stick with that one.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          I think I updated the post after your reply... sorry....

          Comment


          • #6
            I think the problem lies here in -opyear- and therefore creating a spline from here

            Code:
            rcsgen opyear, df(3) gen(yearspl) orthog
            I tried:

            Code:
            ///Include opyear - to check if the problem is from spline variable 
            
            stpm2 procedure opyear age charlson gender provider, scale(h) df(5) eform tvc(procedure gender age charlson) dftvc(3)
            
            ///ERROR: FLAT REGION RESULTING IN A MISSING LIKELIHOOD. 
            
            ///I then tried - no op year - **original pristine model ***
            stpm2 procedure age charlson gender provider, scale(h) df(5) eform tvc(procedure gender age charlson) dftvc(3)
            
            ///Works
            So my opyear is the problem... this is a variable that just has the year of operation.
            What is your advice?

            Comment


            • #7
              Carlo Lazzaro Hi, what did you mean by

              Stata is probably telling you that you would better off with a more parsimonious model.

              i wonder if you had any thoughts re post 6?
              i’m not sure how many people have worked with -stpm2- as I’ve been trying to google people who have used it to ask for their advice about this

              i’ve been told, to
              try tweaking the estimation options? Try different initial values.

              however, i don’t know what they mean. Perhaps someone has a clue so I could start working on this. Really eager to get my original looking graphs and sort this error (as you probably realised)

              Comment


              • #8
                Martin:
                let's read parsimonious model as a model that gives a fair and true view of the data generating process you're investigating without complaining about convergence problem. Oftentimes it boils down to reduce the number of predictors.
                In your case, I'd get a rid of -opyear-, as it seems to be the culprit.
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment


                • #9
                  Easy to say get rid of, and I would have.... but I need the variable -opyear- to model and plot my two graphs:

                  - Creating a male:female hazard ratio since year of surgery (opyear)

                  SImilar to here: (Prof D uses yydx - i use opyear)

                  https://www.pauldickman.com/software...erences-cox.do

                  - And I've got another graph creating 10-year age standardised models.

                  Comment


                  • #10
                    Martin/Denise:
                    sorry I cannot be more helpful.
                    Kind regards,
                    Carlo
                    (Stata 19.0)

                    Comment


                    • #11
                      It's hard to say exactly without seeing your dataset. But from my own experience of using stpm2, I might suggest:

                      a. Try lowering the degrees of freedom, particularly for the TVCs. So, e.g. try dftvc(2) or dftvc(1). Or, look at the significance levels of the various TVC factors, and vary them by covariate (that is, maybe age needs 3 d.f., but I doubt gender does, being (presumably) binary). You might also try lowering the baseline df from 5 down to 4 or 3.

                      b. You say opyear encodes year of operation. How many different values does this covariate take on -- might it be entered as a factor variable rather than as a continuous spline? Or if you must use a spline, might 2 d.f. be sufficient?

                      All this is just another way of thinking about parsimoniousness, as Carlo mentioned. Hope it's helpful!

                      Comment


                      • #12
                        Hello, so I first solved the problem by using -lininit - option
                        However, I then realised I had a mistake in terms of my failure variable (with encoding the label of failure got changed) - and I had forgotten to update it!
                        And alas, all my original graphs/code worked

                        Comment

                        Working...
                        X