Announcement

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

  • Please help: Error r(2000) when running svy logistic

    Hello,
    I am using Stata/1C 12.0 and have been having some difficulty running svy logistic. I would greatly appreciate any help.

    I am able to run the model no problem using:
    svy: logistic outcome mode i.agecat gender i.edcat i.incomecat i.prov

    however, when I add a propensity score as a covariate to my model, I get the following error:
    svy: logistic outcome mode i.agecat gender i.edcat i.incomecat i.prov propscore
    an error occurred when svy executed logistic
    r(2000);

    I've looked into this error, and confirmed that all my variables are numeric (not string) and also confirmed that the outcome is coded as 0,1.

    I'm stuck. Any ideas?

    Thanks in advance!
    Marcella


  • #2
    Besides the variables, svy: logistic will also look at the pweights that were identified in -svyset-. Observations with pweight = 0 are also excluded. It may be that the pweights are all zero for any observations where propscore is not missing. The other possibility is that propscore itself is all missing, or is a string variable.

    I would re-run the first regression, and then look at the distributions of propscore and pweight -if e(sample)-. Although propscore and pweight may look OK in the data set as a whole, within the estimation sample from the first regression they may be problems.

    Comment


    • #3
      Hi Clyde,
      Thank you very much for your response. I ran the first regression again, and took a look at the distributions for propscore and pweight (=wgt1) within the estimation sample. Both variables look fine to me, so I don't think they are contributing to the r(2000) error.


      . summarize propscore if e(sample)

      Variable | Obs Mean Std. Dev. Min Max
      -------------+--------------------------------------------------------
      propscore | 2027 .8069472 .1706035 .2430694 .9955032


      . summarize wgt1 if e(sample)

      Variable | Obs Mean Std. Dev. Min Max
      -------------+--------------------------------------------------------
      wgt1 | 2069 .9946641 .1093631 .69 1.48

      Comment


      • #4
        Let me ask the following, because it has to be asked, no matter how unlikely. Did you run the two logistics one after the other, or were there commands in between that may have accidentally changed your data?

        Or asked another way, have you tried launching Stata, loading your data, and running the second logistic, to make sure the r(2000) occurs again? And if it does occur again, then running the first logistic immediately to see that it succeeds again?

        If you're like me, you probably tried everything several times already, but if not, it's worth trying again, and mixing things up.

        Comment


        • #5
          Fair point. Thanks for checking.

          I've confirmed that I get the r(2000) when I run the two regressions one after another. To double check, I've relaunched Stata and ran both regressions back to back. I can also run the first logistic no problem immediately after producing the r(2000) for the second regression.

          Comment


          • #6
            Well, I'm grasping at straws here, but you were a good sport about trying my first suggestion, so here's one that builds on Clyde's thoughts.

            I notice that your propensity score is missing in 42 observations (= 2069-2027). The logistic command will throw an r(2000) error not only if there are zero observations after casewise omission due to missing values, but also if among the observations not omitted there is no variation in the outcome.

            So my next suggestion is to re-run the first regression, and then try
            Code:
            tab outcome if e(sample) & ! missing(propscore)
            to see if you lost all the successes (or all the failures) when the observations with missing propscore were omitted.

            Good luck!
            Last edited by William Lisowski; 27 Dec 2015, 14:24.

            Comment


            • #7
              Thanks William! You figured it out. All the successes are lost when the observations with missing propscore are omitted.

              That seems very strange to me, though, that all the observations with a successful outcome have a missing propscore. I'll look into this...

              Comment

              Working...
              X