Announcement

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

  • could not calculate numerical derivatives -- discontinuous region with missing values encountered r(430)

    Please Everyone,

    I need help. I obtain this (below) error while running a regression. how to solve this issue?

    "....nearby values are missing
    Iteration 30: log pseudolikelihood = -325.77861 (not concave)
    numerical derivatives are approximate
    nearby values are missing
    numerical derivatives are approximate nearby values are missing
    Iteration 31: log pseudolikelihood = -325.77861 (not concave)
    could not calculate numerical derivatives -- discontinuous region with missing values encountered
    r(430);

    end of do-file

    r(430);"

    Thank

  • #2
    Roland: We ask for full real names here, meaning family names as well as given names. See the FAQ Advice. More crucially, the FAQ Advice suggests posting more information about your data and the exact command you typed (as well as Stata's response).

    There isn't much we can tell from this beyond what is flagged, namely that the model fit is not converging. Common problems, which are not mutually exclusive, are

    1. The model family is just not suitable for the data, or vice versa.

    2. You are trying to fit a model that is too complicated.

    3. The unnamed command you are using needs a better hint of starting values for parameters.

    4. The iteration is stuck in an awkward corner. For example, variables that are nearly constant can be problematic, or outliers can be problematic.

    5. Your dataset is too small compared with you are trying to fit. In many fields, it's recommended that the number of data points should be much greater than the number of parameters fitted.

    The best advice is often to retreat to a much simpler model that works, and then introduce complications one by one. I've seen that advice mocked, but I don't often see better advice for posts like this.

    Comment


    • #3
      Thank you very much,

      I will consider these requirements in my next posts.

      Also, I will modify my profile.

      I am very satisfied with your answers.

      Thank you once more.

      Comment


      • #4
        I'm also having this issue when trying to run a linear mixed regression model. I have 4 experiments with a total of 120 cases which were measured for cell growth and vegf (study main outcomes) during days 1, 2, 3, and 4 (380 observations in total). The other variables I have are: days, experiment, treatment (tx), and medium (i.e, serum free and serum) An interaction was observed between tx and days when using lrtest.

        Note: Hope this will help
        tx included no tx, only ICI (various doses), only PD (various doses), combination of doses for PD and ICI.
        Experiments 1-3, included only serum free (ie, medium ==0)
        Experiment 4 evaluated no tx and PD tx only during days 2 and 4 only. This experiment also included serum.

        Code:
        quietly: mixed log_vegf i.tx i.day1 i.tx##i.day1 if medium == 0 || id: , cov(identity)
        estimates store m3
        quietly: mixed log_vegf i.tx i.day1 if medium == 0 || id: , cov(identity)
        estimates store m4
        lrtest m3 m4
        
        Likelihood-ratio test                                 LR chi2(22) =     89.41
        (Assumption: m4 nested in m3)                         Prob > chi2 =    0.0000

        However, when I try to run the linear mixed models stratifiying by day, it only allows me to run the models for days 2 and 4. For days 1 and 3 this message appears:

        Code:
        mixed log_vegf i.tx if day1 == 1 & medium == 0 || id: , cov(identity)
        
        Performing EM optimization:
        
        Performing gradient-based optimization:
        
        could not calculate numerical derivatives -- discontinuous region with missing values
        encountered
        could not calculate numerical derivatives -- discontinuous region with missing values
        encountered
        r(430);
        
        end of do-file
        
        r(430);
        I verify the data and this is a segment for those days I'm having trouble with:

        Code:
        list vegf pd ici if day1 == 1 & medium ==0
        
             +---------------------+
             | vegf   pd   ici |
             |---------------------|
          1. |     1116    0     0 |
          2. |      984    0     1 |
          3. |      568    0    10 |
          4. |      528   10     0 |
          5. |      532   25     0 |
             |---------------------|
        
        list vegf pd ici if day1 == 3 & medium ==0
        
             +---------------------+
             | vegf   pd   ici |
             |---------------------|
         45. |      824    0     0 |
         46. |     1024    0     1 |
         47. |      540    0    10 |
         48. |      288   10     0 |
         49. |      244   25     0 |
             |---------------------|
        How can I fix this problem?? I would appreciate any advice.
        Thank you in advance

        Comment


        • #5
          Hi,

          I have an issue that is related to this statalist posting. I am trying to estimate the marginal effects of various covariates on the likelihood of a household using fuelwood as their source of energy. My data format is as such:

          Code:
          hhid    _mi_m    _mi_id    _mi_miss    predict_poor    quintile    educ_h    domicile    fuelwood_he    educ_spouse    no_primary_child    primary_child    secondary_child    vocational_child    higher_stud_child
          711    1    711        0    5    Higher (bachelor degree, master degree)    Urban    0        0    0    0    0    0
          670    5    670        0    3    Middle vocational (technical college, college)    Urban    1        0    0    0    0    2
          385    4    385        0    5    Middle vocational (technical college, college)    Urban    1    Middle vocational (technical college, college)    0    0    1    0    0
          405    6    405        0    3    Secondary    Urban    1    Secondary    0    0    1    0    0
          389    17    389        1    1    Secondary    Urban    1        0    0    0    0    0
          693    19    693        0    3    Secondary    Urban    1    Secondary    0    0    2    0    0
          667    15    667        0    4    Higher (bachelor degree, master degree)    Urban    1    Higher (bachelor degree, master degree)    0    0    1    0    0
          394    2    394        0    5    Middle vocational (technical college, college)    Urban    0        0    0    0    0    1
          407    7    407        0    2    Secondary    Urban    1    Higher (bachelor degree, master degree)    1    0    0    0    0
          393    12    393        0    3    Secondary    Urban    1    Higher (bachelor degree, master degree)    0    0    1    0    0
          I want to run a probit regression and calculate the marginal effects of the independent variables. Given that some of the independent variables here are imputed (predict_poor & quintile), I know I should be running the probit command appropriate for imputed datasets. Below is my code:

          Code:
          mi est: probit fuelwood_he i.domicile i.educ_h i.educ_spouse i.predict_poor ///
          no_primary_child primary_child secondary_child vocational_child higher_stud_child ///
          [pw=weight]
          mimrgns, dydx(*)
          When I run the mimrgns command, I get the following error message:

          note: option predict() not specified; predict(xb) assumed
          could not calculate numerical derivatives -- discontinuous region with missing values encountered
          an error occurred when mi estimate executed mimrgns_estimate on m=1
          r(459);



          I would appreciate any help as I am a bit confused. I haven't come across more than a couple of posts on Statalist on this particular error code. Thanks in advance!

          Comment


          • #6
            Hi,
            I have an issue on the same error: "could not calculate numerical derivatives -- discontinuous region with missing values encountered r(430)".
            I am trying to estimate the conditional variances and conditional correlations with the MGARCH-DCC model. My data sample is composed by banks' returns with daily frequency.
            I run the following commands:

            mgarch dcc (banki market =, arch(1) garch(1))
            predict var*, variance
            predict corr*, correlation
            predict res*, residuals

            However, the model worked for half of my sample, the other half showed me the same error r(430). I tried to do some basic statistics and the data I have are similar to the ones where the model worked. Do you have any idea?

            As solutions I already tried:

            1) to increase the lag of ARCH, GARCH , and both.
            2) to change the distribution from Gaussian to T-student
            3) to increase the interaction such as mgarch dcc (banki market =, arch(1) garch(1)), iterate(500).

            It worked for a few banks but I still have some problem with the others. I would like to understand what the problem could be.

            Thanks in advance,
            AV

            Comment


            • #7
              Hi, I am trying to solve this equation system, but I got the error "could not calculate numerical derivatives -- discontinuous region with missing values encountered".

              This is what I am typing.

              clear mata

              mata
              void mysolver(todo, p, lnf, S, H)
              {
              a = p[1]
              b = p[2]
              c = p[3]
              d = p[4]
              e = p[5]
              f = p[6]
              g = p[7]
              h = p[8]
              i = p[9]
              j = p[10]
              lnf = (b/a - 0.9) \
              (c/b - 0.9) \
              (d/c - 0.9) \
              (e/d - 0.9) \
              (f/e - 0.9) \
              (g/f - 0.9) \
              (h/g - 0.9) \
              (i/h - 0.9) \
              (j/i - 0.9) \
              (8453283315*(1+a)+ 15802940907*(1+b)+ 21202198453*(1+c)+ 26327683701*(1+d) + 31880099794*(1+e) + 38281856453*(1+f)+ 46468280577*(1+g)+ 58447428151*(1+h) + 80253368533*(1+i)+ 192033245049*(1+j) - 493192865686.441)
              }

              S = optimize_init()
              optimize_init_evaluator(S, &mysolver())
              optimize_init_evaluatortype(S, "v0")
              optimize_init_params(S,(1,1,1,1,1,1,1,1,1,1))
              optimize_init_which(S, "min" )
              optimize_init_tracelevel(S,"none")
              optimize_init_conv_ptol(S, 1e-16)
              optimize_init_conv_vtol(S, 1e-16)
              p = optimize(S)

              end




              Comment

              Working...
              X