Announcement

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

  • Boostrap error for a panel two step heckman process

    Dear all,
    I am starting my Ph.D and have some problems with a model, I hope you can help me. I am using an unbalance panel of 8 year to estimate the % of sales due to product innovation (Y2) (in logs) as a function of X1 (main variable in the analysis) and some firm characteristics say (Zi1). I am aware of a presence of selection due to that I can only observe Y2 (non-zero values) if the firm is product innovator (Y1) which is a dummy. I am trying to correct using a Heckman process as in Wooldridge, 1995. First I have to do a yearly probit of Y1=(X1, Zi, acti2d3-acti2d50) where Zi contains Zi1 plus some exclusion restrictions and acti2d3-acti2d50 are sectoral dummies, obtaining the yearly inverse Mill ratios. Then I need to put those ratios in the second step regression of Y2=(X1, Zi1, lambdas, acti2d3-acti2d50, i.time) only for the selected sample, say only for Y1==1, when all the explicative are lagged one period for avoiding simultaneity in both equations. As I am doing this process in two step the standard error must be corrected using boostrap errors. My problem is that the program I created does not work. I have been looking for others posts here in statalist with problems pretty similar to mine, for example: http://www.statalist.org/forums/foru...tandard-errors
    and I have tried to do what I read on those post, but still the error is there. I have 8 year, but only show you the program for two of them because of space. The program is the following:
    program drop myols
    program myols, eclass
    version 13
    syntax varlist [if] [in] [, Robust noCONStant ]
    gettoken y xvar : varlist
    display "varlist contains: " "`varlist´"
    display "and if contains: " "`ìf´"
    display "and in contains: " "`ìn´"
    display "and y contains: " "`y´"
    display "and xvars contains: " "`xvars´"
    probit Y1 X1 Zi acti2d3-acti2d50 if time==2005 /* selection equation */
    predict acltxb1_2005, xb
    gen lambda05=normalden(acltxb1_2005)/normprob(acltxb1_2005)
    probit Y1 X1 Zi acti2d3-acti2d50 if time==2006 /* selection equation */
    predict acltxb1_2006, xb
    gen lambda06=normalden(acltxb1_2006)/normprob(acltxb1_2006)
    reg Y2 X1 Zi1 lambda05 lambda06 acti2d3-acti2d50 i.time if Y1==1
    drop acltxb1_2005 lambda05 acltxb1_2006 lambda06
    end
    bootstrap _b, rep(500) seed(10101): myols X1 Zi1

    It gives me the following error: insufficient observations to compute bootstrap standard errors
    no results will be saved.
    If I put the option (noisily) in the bootstrap command then it gives me the following error:
    outcome does not vary; remember:
    0 = negative outcome,
    all other nonmissing values = positive outcome
    an error occurred when bootstrap executed myols, posting missing values. insufficient observations to compute bootstrap standard errors no results will be saved

    I also tried putting the cluster options for panels, when ident is my identificator:
    generate newid = ident
    tsset newid time
    generate sample=1-missing(Y2,Y1,X1,Zi,acti2d2-acti2d50)
    keep if sample
    bootstrap _b, rep(500) seed(10101) cluster(ident) idcluster(newid) nowarn: myols X1 Zi1
    insufficient observations to compute bootstrap standard errors no results will be saved


    I have tried without the (if Y1==1) and also without the sectoral dummies in the main regression (Y2) and then it compute the bootstrap, but the methodology says that the second equation must be for the selected sample (Y1==1) (as in the post I have referenced at the beginning).
    Any hint or help will be more than welcome.
    Thanks in advance.

    pd. sorry for the long post.

  • #2
    Dear statalisters,
    Since I believe that my last post was too long (perhaps the reason of no answer was that one) and I don´t think that it´s allowed to start a new post for the same, I´ll try to ask again here in a shorter one (including this time the paste of the program from the results viewer). My apologize in advance for this.
    I want to estimate a Heckman model for an unbalanced panel. I perform a yearly probit for the selection (dummy) and compute the IMR (those ratios should be computed only for selection==1) and then, I must include them in my main regression (Pooled OLS) but this regression is only for selection==1 (selected subsample). My problems comes when I put the selection==1 option in the main equation (inside the program). Please, can anyone tells me what am I doing wrong? I think the problem comes from the fact that the bootstrap command is computing everything for selection==1 and then it cannot recompute the probits (needs cero and one values), but then how should I say the program that the main equation and also the creation of IMR must be for the selected subsample? I have also tryied with a balanced panel and dropping missing values, but it´s the same. Generally the error is: insuficient observations to compute bootstrap error r(2000). And using the noisily opction the error is: outcome does not vary: remember 0=negative outcome, all other nonmissing values =positive outcome.
    . program myols, eclass
    1. version 13
    2. syntax varlist [if] [in] [, Robust noCONStant ]
    3. gettoken y xvar : varlist
    4. display "varlist contains: " "`varlist´"
    5. display "and if contains: " "`ìf´"
    6. display "and in contains: " "`ìn´"
    7. display "and y contains: " "`y´"
    8. display "and xvars contains: " "`xvars´"
    9. probit innprod l1loffintensity l1FACneed1 l1marketshareyear l1grupo l1pat l1inten2mod l1ltamano l1ltamano2 l1permanent l1foreign2 l1openness l1demandpullRay acti2d2-acti2d50 if time==2005 /* selection equation */
    10. predict acltxb1_2005, xb
    11. gen lambda2005=normalden(acltxb1_2005)/normprob(acltxb1_2005)
    12. probit innprod l1loffintensity l1FACneed1 l1marketshareyear l1grupo l1pat l1inten2mod l1ltamano l1ltamano2 l1permanent l1foreign2 l1openness l1demandpullRay acti2d2-acti2d50 if time==2006 /* selection equation */
    13. predict acltxb1_2006, xb
    14. gen lambda2006=normalden(acltxb1_2006)/normprob(acltxb1_2006)
    15. probit innprod l1loffintensity l1FACneed1 l1marketshareyear l1grupo l1pat l1inten2mod l1ltamano l1ltamano2 l1permanent l1foreign2 l1openness l1demandpullRay acti2d2-acti2d50 if time==2007 /* selection equation */
    16. predict acltxb1_2007, xb
    17. gen lambda2007=normalden(acltxb1_2007)/normprob(acltxb1_2007)
    18. probit innprod l1loffintensity l1FACneed1 l1marketshareyear l1grupo l1pat l1inten2mod l1ltamano l1ltamano2 l1permanent l1foreign2 l1openness l1demandpullRay acti2d2-acti2d50 if time==2008 /* selection equation */
    19. predict acltxb1_2008, xb
    20. gen lambda2008=normalden(acltxb1_2008)/normprob(acltxb1_2008)
    21. probit innprod l1loffintensity l1FACneed1 l1marketshareyear l1grupo l1pat l1inten2mod l1ltamano l1ltamano2 l1permanent l1foreign2 l1openness l1demandpullRay acti2d2-acti2d50 if time==2009 /* selection equation */
    22. predict acltxb1_2009, xb
    23. gen lambda2009=normalden(acltxb1_2009)/normprob(acltxb1_2009)
    24. probit innprod l1loffintensity l1FACneed1 l1marketshareyear l1grupo l1pat l1inten2mod l1ltamano l1ltamano2 l1permanent l1foreign2 l1openness l1demandpullRay acti2d2-acti2d50 if time==2010 /* selection equation */
    25. predict acltxb1_2010, xb
    26. gen lambda2010=normalden(acltxb1_2010)/normprob(acltxb1_2010)
    27. probit innprod l1loffintensity l1FACneed1 l1marketshareyear l1grupo l1pat l1inten2mod l1ltamano l1ltamano2 l1permanent l1foreign2 l1openness l1demandpullRay acti2d2-acti2d50 if time==2011 /* selection equation */
    28. predict acltxb1_2011, xb
    29. gen lambda2011=normalden(acltxb1_2011)/normprob(acltxb1_2011)
    30. probit innprod l1loffintensity l1FACneed1 l1marketshareyear l1grupo l1pat l1inten2mod l1ltamano l1ltamano2 l1permanent l1foreign2 l1openness l1demandpullRay acti2d2-acti2d50 if time==2012 /* selection equation */
    31. predict acltxb1_2012, xb
    32. gen lambda2012=normalden(acltxb1_2012)/normprob(acltxb1_2012)
    33. forvalues i = 2005/2012 {
    34. generate lambdax`i' = lambda`i'*time`i'
    35. }
    36.
    . reg tlnewmer l1loffintensity l1inten2mod l1ltamano l1ltamano2 l1permanent l1foreign2 l1openness l1demandpullRay lambda2005 lambda2006 lambda2007 lambda2008 lambda2009 lambda2010 lambda2011 lambda2012 lambdax2005 lambdax2006 lambdax2007 lambdax2008 lambdax2009 lambdax2010 lambdax2011 lambdax2012 acti2d2-acti2d50 i.time if innpro==1
    37. testparm lambda2005-lambda2012 lambdax2005-lambdax2012
    38. drop acltxb1_2005 lambda2005 lambdax2005 acltxb1_2006 lambda2006 lambdax2006 acltxb1_2007 lambda2007 lambdax2007 acltxb1_2008 lambda2008 lambdax2008 acltxb1_2009 lambda2009 lambdax2009 acltxb1_2010 lambda2010 lambdax2010 acltxb1_2011 lambda2011 lambdax2011 acltxb1_2012 lambda2012 lambdax2012
    39. end

    . bootstrap _b, rep(800) seed(10101): myols l1loffintensity l1inten2mod l1ltamano l1ltamano2 l1permanent l1foreign2 l1openness l1demandpullRay


    Any help will be more than appreciated, thanks a lot in advance again.

    Comment


    • #3
      Dear Damian,
      have you found a solution to your problem yet? If yes, I would very much apprechiate you sharing it, since I am struggling with a very similar issue.

      Thank you!

      Johann

      Comment

      Working...
      X