Announcement

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

  • xtprobit error

    I am trying to work on a xtprobit model with Stata, using the SHARE dataset, which is an unbalanced panel. I am trying to do xtprobit model with smoking as the dependent variable, and quality of life (casp) and education as independent, but I get the error outcome does not vary r(2000). As it is possible to see from the tab, the outcome varies and I have tried aswell to check if there is variation over time for individuals, and I found at least one individual with variation over time. Can you help me?


    This are my prompt results:

    cd "C:\Users\diber\Desktop\SHARE_Data\sharewX_rel 8-0-0_easySHARE_stata"
    C:\Users\diber\Desktop\SHARE_Data\sharewX_rel8-0-0_easySHARE_stata

    . use easySHARE_rel8-0-0, clear
    (easySHARE release 8.0.0 waves 1 2 3 4 5 6 7 8 doi 6103./SHARE.easy.800)

    .
    . keep mergeid wave smoking casp eduyears_mod

    .
    . mvdecode smoking casp eduyears_mod, mv(-1/-20)
    smoking: 122038 missing values generated
    casp: 66347 missing values generated
    eduyears_mod: 37246 missing values generated

    .
    . bysort mergeid: gen mergeid_n = _n ==1

    . replace mergeid_n = sum(mergeid_n)
    (412,109 real changes made)

    .
    . xtset mergeid_n wave
    panel variable: mergeid_n (unbalanced)
    time variable: wave, 1 to 8, but with gaps
    delta: 1 unit

    .
    . xtprobit smoking casp eduyears_mod
    outcome does not vary; remember:
    0 = negative outcome,
    all other nonmissing values = positive outcome
    r(2000);

    end of do-file

    r(2000);


    . tab smoking

    Smoke at the present time | Freq. Percent Cum.
    --------------------------------------+-----------------------------------
    1. Yes | 46,267 15.95 15.95
    5. No | 243,805 84.05 100.00
    --------------------------------------+-----------------------------------
    Total | 290,072 100.00

  • #2
    The convention in Stata is that \(y=0\) indicates a negative outcome whereas \(y\neq 0\) and nonmissing indicates a positive outcome. The error message tells you exactly this:

    outcome does not vary; remember:
    0 = negative outcome,
    all other nonmissing values = positive outcome
    r(2000);
    So you need to recode your outcome variable. From


    . tab smoking

    Smoke at the present time | Freq. Percent Cum.
    --------------------------------------+-----------------------------------
    1. Yes | 46,267 15.95 15.95
    5. No | 243,805 84.05 100.00
    --------------------------------------+-----------------------------------
    Total | 290,072 100.00
    you need


    Code:
    recode smoking (5=0), gen(smoker)
    xtprobit smoker ...
    See

    Code:
    help recode

    Comment


    • #3
      Thank you a lot for the help, it was quite a basic mistake and now is working!

      Comment

      Working...
      X