Announcement

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

  • estimate probit with variable factor in parameter

    Hi everyone,
    I want to run this probit model and estimate parameters B1 and B2:
    Y = ((1-pi)B1 + (pi)B2)X + e
    which pi is a binary variable in data (0 or 1) and X is independent variable(s).
    Can anyone help me in STATA syntax?
    (I know that I can separate data in pi=1 and pi=0 but I have made some assumptions about error term that do not allow this.)
    thanks
    Last edited by Paul Taylor; 11 Dec 2021, 12:50.

  • #2
    One way is to generate interactions between X and pi, and between X and (1-pi), as below.

    Code:
    gen X_pi = X*pi
    gen X_1_pi = X*(1-pi)
    probit Y X_1_pi X_pi
    But I would recommend another way, as below.

    Code:
    probit Y X c.X#c.pi
    where the coefficient of X is B1, and B2 can be obtained by summing up the coefficients of X and c.X#c.pi. This way is convenient for further partial effects derivation with -margins-.

    Comment


    • #3
      In addition to Fei's two approaches, you can get the two coefficients directly with factor variable notation omitting the base category and a no-constant option in the regression command. See below for an example. (Begin at the "Begin here" comment; the stuff above is just to create a toy dataset for illustration. Variables out, pre and pie are Y, X and pi in your post.)


      .ÿ
      .ÿversionÿ17.0

      .ÿ
      .ÿclearÿ*

      .ÿ
      .ÿ//ÿseedem
      .ÿsetÿseedÿ717321674

      .ÿ
      .ÿquietlyÿsetÿobsÿ10000

      .ÿ
      .ÿgenerateÿdoubleÿpreÿ=ÿruniform(-0.5,ÿ0.5)

      .ÿgenerateÿbyteÿpieÿ=ÿmod(_n,ÿ2)

      .ÿ
      .ÿquietlyÿgenerateÿdoubleÿxbÿ=ÿ-2ÿ*ÿpreÿifÿ!pie

      .ÿquietlyÿreplaceÿxbÿ=ÿ2ÿ*ÿpreÿifÿpie

      .ÿ
      .ÿgenerateÿbyteÿoutÿ=ÿ(xbÿ+ÿrnormal())ÿ>ÿ0ÿ//ÿrbinomial(1,ÿnormal(xb))

      .ÿ
      .ÿ*
      .ÿ*ÿBeginÿhere
      .ÿ*
      .ÿprobitÿoutÿibn.pie#c.pre,ÿnoconstantÿnolog

      ProbitÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿ10,000
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWaldÿchi2(2)ÿÿ=ÿ1684.13
      Logÿlikelihoodÿ=ÿ-6014.8608ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿ=ÿÿ0.0000

      ------------------------------------------------------------------------------
      ÿÿÿÿÿÿÿÿÿoutÿ|ÿCoefficientÿÿStd.ÿerr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿconf.ÿinterval]
      -------------+----------------------------------------------------------------
      ÿÿÿpie#c.preÿ|
      ÿÿÿÿÿÿÿÿÿÿ0ÿÿ|ÿÿ-1.933382ÿÿÿ.0680644ÿÿÿ-28.41ÿÿÿ0.000ÿÿÿÿ-2.066786ÿÿÿ-1.799979
      ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ2.048288ÿÿÿÿ.069155ÿÿÿÿ29.62ÿÿÿ0.000ÿÿÿÿÿ1.912747ÿÿÿÿ2.183829
      ------------------------------------------------------------------------------

      .ÿ
      .ÿexit

      endÿofÿdo-file


      .


      I'm curious about your mention of assumption for the error term. Unless you're proposing a heteroscedastic probit model, then the error term is fixed at unity for identification purposes.

      Comment


      • #4
        Thank you very much for your help, Fei and Joseph.
        these are good ideas, especially the last one.

        about error term assumption, In fact I have 2 probit regression that their error terms are correlated. and this regression is one of those. so, I could not separate data. (I want to calculate corr. of 2 error terms ,finally)

        Comment

        Working...
        X