Announcement

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

  • "Mata object __000002 already exists" after ivreg2

    Dear Statalist fellows,

    Stata/MP 17, macOS

    After loading a csv file and generating some interactions and labelling others, I ran this:

    Code:
    ivreg2 depvar t1##(v1 v2 v3) t2##(v1 v2 v3) t3##(v1 v2 v3) t4##(v1 v2 v3) t5##(v1 v2 v3) (endogreg = iv1 iv2) i.year i.sic, first gmm2s rob endog(endogreg) orthog(iv2) redundant(iv1 iv2)
    ... which works fine. Then:

    Code:
    estimates store A
    , with no errors and correspondent creation of an additional item in the variables list, then:

    Code:
    estimates table A
    , which gives the following error:

    Code:
    Mata object __000002 already existsr(110);
    This is the first and most important issues which I could not solve after a week searching for an answer.

    The second is the obviously weird syntax used for the regression. Using this notation:

    Code:
    ivreg2 depvar (t1-t3)##(v1 v2 v3) (endogreg = iv1 iv2)
    ... returns the following message:

    Code:
    syntax is "(all instrumented variables = instrument variables)"
    invalid syntax
    r(198)

    I appreciate any help with both, but especially the "already exists" error.

    Cheers
    Denis
    Last edited by Denis Alves; 23 Sep 2024, 06:25.

  • #2
    An upgrade to Stata 18 fixed the "already exists" issue. However, I would appreciate your kind help with the syntax

    Code:
    ivreg2 (t1-t3)##(v1 v2 v3) (endogreg= iv1 iv2)
    Is it really necessary to type in

    Code:
    ivreg2 t1##(v1 v2 v3) t2##(v1 v2 v3) t3##(v1 v2 v3) (endogreg= iv1 iv2)
    ?

    Comment


    • #3
      ivreg2 is from SSC (FAQ Advice #12). The parsing of parentheses can be tricky in IV regression. You can use fvexpand.

      Code:
      fvexpand (t1 t2 t3)##(v1 v2 v3)
      ivreg2 depvar `r(varlist)' (endogreg= iv1 iv2)

      Comment


      • #4
        Dear Andrew Musau, thank you so much. This is awesome.

        Comment

        Working...
        X