Announcement

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

  • [__000000] not found an error occurred when simulate executed my2sls

    Dear Statalists,

    I have a problem with the tempvars in the monte carlo simulation of 2sls regression on Stata 13. The "do file" stops working with this error message:


    [__000000] not found
    an error occurred when simulate executed my2sls
    r(111);

    I have looked around the web, but almost all the cases were about using the "reshape" command, which is not related to this code. I would appreciate your kind tips. The code is below:


    clear all
    set seed 10101

    * Set the values of the parameters
    global numobs = 150 /*numobs = sample size*/
    global numsims = 1000 /*numsims = replication number*/

    capture program drop my2sls
    program my2sls, rclass
    version 13
    drop _all
    set obs $numobs

    tempvar x1 x2 x3 eps1 eps2 u1 u2 y1 y2

    generate `x1' = runiform()
    generate `x2' = runiform()
    generate `x3' = runiform()

    generate `eps1' = rnormal()
    generate `eps2' = rnormal()

    generate `u1' = 1.708*`eps1' + 1.404*`eps2'
    generate `u2' = 1.732*`eps2'

    generate `y1' = -1.412*`x1' - 0.588*`x2' - 2.118*`x3' - 0.588*`u1' - 0.882*`u2'
    generate `y2' = -1.412*`x1' - 0.588*`x2' - 2.118*`x3' - 0.882*`u1' - 0.558*`u2'

    ivregress 2sls `y2' (`y1' = `x2')

    return scalar b1 = _b[`x1']
    return scalar b2 = _b[`x2']
    return scalar b3 = _b[`x3']

    end

    set matsize 11000

    simulate b1=r(b1) b2=r(b2) b3=r(b3), reps($numsims) saving(results, replace) nolegend nodots: my2sls


    use results, clear
    summarize



    Thanks in advance,
    Homa


  • #2
    Well you ask Stata to return the coefficients for x1, x2 and x3, yet your model includes only y1 as a predictor and x2 as an instrument. Where do you expect Stata to get the requested coefficients from?

    As an aside: try using code delimiters when posting code.

    Best
    Daniel
    Last edited by daniel klein; 18 Mar 2016, 02:03.

    Comment


    • #3
      Dear Daniel,

      Thank you very much By changing components of the ivregress command, I could solve this problem.



      regards,
      Homa

      Comment


      • #4
        In this case the problem was pretty obvious. In other cases it often helps to use the -set trace on- command (perhaps accompanied by -set more off-). There have been plenty of times when I thought a local value had been set when it turned out I had made a mistake somewhere.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://academicweb.nd.edu/~rwilliam/

        Comment

        Working...
        X