Announcement

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

  • Scalar option not allowed error

    #delimit;
    probit smoker smkban female age age_squared hsdrop hsgrad colsome colgrad black hispanic, r
    scalar x0=_b[smkban]*0 /*there is no ban*/
    + _b[female]* .5637
    + _b[age]* 38.6932
    + _b[age_squared]* 1643.893
    + _b[hsdrop]* .0912
    + _b[hsgrad]* .3266
    + _b[colsome]*.2802
    + _b[colgrad]* .1972
    + _b[black]*.0769
    + _b[hispanic]*.1134
    + _b[_cons];
    scalar x1= x0+ _b[smkban]*1;
    dis "Probability for no smoking ban at means ="normprob(x0);
    dis "Probability for smoking ban at means ="normprob(x1);
    dis "Difference in probabilities ="normprob(x1)-normprob(x0);
    #delimit cr

    Hello everyone, thanks in advance for you help, I am trying to compute this but I'm getting the error "option scalar not allowed" when i try to compute scalar x1
    I really have no clue of what could be the possible error as i computed the same lines for a logit regression and they are exaclty the same and everything is working fine.
    I will copy the working logit code too:

    #delimit ;
    summarize smoker smkban female age age_squared hsdrop hsgrad colsome colgrad black hispanic;
    logit smoker smkban female age age_squared hsdrop hsgrad colsome colgrad black hispanic, r;
    scalar w0= _b[smkban]*0 /*there is no ban*/
    + _b[female]* .5637
    + _b[age]* 38.6932
    + _b[age_squared]* 1643.893
    + _b[hsdrop]* .0912
    + _b[hsgrad]* .3266
    + _b[colsome]*.2802
    + _b[colgrad]* .1972
    + _b[black]*.0769
    + _b[hispanic]*.1134
    + _b[_cons];
    scalar w1= w0+ _b[smkban]*1;
    dis "Probability for no smoking ban at means =" 1/(1+exp(-w0));
    dis "Probability for smoking ban at means =" 1/(1+exp(-w1));
    dis "Difference in probabilities =" 1/(1+exp(-w1))-1/(1+exp(-w0));
    #delimit cr

  • #2
    I also do not see what could be the problem here.

    Try to generate the error with some minimal dataset, and post the dataset (using -dataex-) and the exact code you are using.

    Comment


    • #3
      Cross=posted and answered at https://www.reddit.com/r/stata/comme...t_valid_error/

      You need a semi-colon after

      Code:
      probit smoker smkban female age age_squared hsdrop hsgrad colsome colgrad black hispanic, r
      Please note our policy on cross-posting, which is that you are asked to tell us about it. https://www.statalist.org/forums/help#crossposting

      Comment

      Working...
      X