Announcement

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

  • xml_tab error message

    Dear All,

    I estimate different panel data models and then I try to export the results to excel using xml_tab user-written command (I know that there are possibly better ways to do that including the new table command. But I have been using xml_tab for so many years that I am familiar with it).

    When doing so, I receive the following error message:

    Code:
    year: factor variable base category conflict
    My estimates include year dummies, which I introduce via i.year. I understand the meaning of that message. In fact, I checked my estimates and 4 of them contains year dummies from 1993 to 2013, while one containes year dummies from 1989 to 2013. What I cannot understand is why this error message pops up. . The command I use to export results is:

    Code:
    xml_tab     tab4_a tab4_b tab4_c tab4_d_1 tab4_d_2 tab4_d_3, title ("Tab4") wide below sd
                     stats (N r2_p) font ("dcr10" 11) sheet(mytable)
                     keep ($H $ownH lncr lnlev lnfm lnrg_cap_r lnta) notes("None.")
                     save("Tables\Tables.xml")
    As you can see I am not including any time dummy in the tables. Instead, I specify only the variables that I want to display - see keep ($H $ownH lncr lnlev lnfm lnrg_cap_r lnta), where $H and $ownH are some global macros, which do not contain any time dummy. So:

    1) Do you have any idea why this happens;

    2) How can I fix it?

    Thanks in advance,

    Dario
    Last edited by Dario Maimone Ansaldo Patti; 07 Dec 2022, 16:00.

  • #2
    As you can see I am not including any time dummy in the tables. Instead, I specify only the variables that I want to display
    Factor variables are not necessarily time dummies. Without seeing your variable lists, it will be difficult to diagnose the issue. You can try to identify the specific problem with

    Code:
    set trace on
    ADDED IN EDIT:

    In fact, I checked my estimates and 4 of them contains year dummies from 1993 to 2013, while one containes year dummies from 1989 to 2013.
    The default in Stata is to use the lowest value as the base. You may also try specifying

    Code:
    ib1993.year
    in each estimation and see if it resolves it.
    Last edited by Andrew Musau; 07 Dec 2022, 16:15.

    Comment


    • #3
      Andrew Musau thanks for your reply. i.year is the only factor variable which I use. In fact, if i estimate all the above model imposing the condition that year>1991, the error message disappears, since in this case Stata will take 1992 as base year. So my curiosity now is how to fix this point. I thought to include the time dummies "manually":

      Code:
      tab year, gen(t)
      ​​​​​Then I may add the set of "t" in my regression. But i am not sure it can work.

      Comment


      • #4
        Originally posted by Dario Maimone Ansaldo Patti View Post
        I thought to include the time dummies "manually":

        Code:
        tab year, gen(t)
        ​​​​​Then I may add the set of "t" in my regression. But i am not sure it can work.
        It should work, but I think that is unnecessary. What happens if you have

        ib1993.year
        in each regression as I suggested in #2?

        Comment


        • #5
          Andrew Musau honestly, i did not have time to check this point today. I will do it in the next few hours and i will reply to you. If i understand correctly, what you suggest is to fix "manually" the base category. Am I right? Anyway, i will reply later after checking your suggestion. Thanks again

          Comment


          • #6
            Andrew Musau Hello, I tried the way you suggested. But I receive the same error message. I estimated the following models:

            Code:
            * model (a)
            xtreg lnroa $H lncr lnlev lnfm i.year ib1993.year, fe r
            test lnppe+lnpce+lnafr=0
            est store tab3_a
            
            * model (b)
            xtreg lnroa $H lncr lnlev lnfm lnrg_cap_r i.year ib1993.year, fe r
            test lnppe+lnpce+lnafr=0
            est store tab3_b
            
            * model (c)
            xtreg lnroa $H lncr lnlev lnfm lnrg_cap_r lnta i.year ib1993.year, fe r
            test lnppe+lnpce+lnafr=0
            est store tab3_c
            
            * model (d)
            xtreg lnroe $H lncr lnlev lnfm i.year ib1993.year, fe r
            test lnppe+lnpce+lnafr=0
            est store tab3_d
            
            * model (e)
            xtreg lnroe $H lncr lnlev lnfm lnrg_cap_r i.year ib1993.year, fe r
            test lnppe+lnpce+lnafr=0
            est store tab3_e
            
            * model (f)
            xtreg lnroe $H lncr lnlev lnfm lnrg_cap_r lnta i.year ib1993.year, fe r
            test lnppe+lnpce+lnafr=0
            est store tab3_f
            Then,

            Code:
            #delimit ;
            
            xml_tab     tab3_a tab3_b tab3_c tab3_d tab3_e tab3_f tab3_lnroa_typ1 tab3_lnroa_typ2
                        tab3_lnroa_typ3 tab3_lnroe_typ1 tab3_lnroe_typ2 tab3_lnroe_typ3, title ("Tab3")
                        wide below sd stats (N r2_p) font ("dcr10" 11) sheet(slm_dW, nogridlines)
                        keep ($H lncr lnlev lnfm lnrg_cap_r lnta) notes("None.")
                        save("Tables\Tables.xml") replace ;
            
            #delimit cr
            I obtained:

            Code:
            year: factor variable base category conflict
            r(198);
            So maybe, as I said previously, I need to include time dummies "manually".

            Thanks for your help,

            Dario

            EDIT:

            Interestingly, I did not receive the same error message if I try to export the table in LaTex:

            Code:
            esttab      tab3_a tab3_b tab3_c tab3_d tab3_e tab3_f tab3_lnroa_typ1 tab3_lnroa_typ2
                        tab3_lnroa_typ3 tab3_lnroe_typ1 tab3_lnroe_typ2 tab3_lnroe_typ3 using
                        "Tables\T3.tex", replace star(* 0.10 ** 0.05 *** 0.01) parentheses plain nogaps
                        depvars b(%9.3f) legend noabbrev style(tex) booktabs title("Table1" \label{T1})
                        t keep ($H $ownH lncr lnlev lnfm lnrg_cap_r lnta) order($H $ownH lncr lnlev lnfm
                        lnrg_cap_r lnta)
            So I could even guess, is it a problem with xml_tab?
            Last edited by Dario Maimone Ansaldo Patti; 09 Dec 2022, 02:41.

            Comment


            • #7
              Andrew Musau My bad! It works. I forgot to add ib1993.year in the other models I estimate and include in the command above (from tab3_lnroa_typ1 onwards). Thanks again, Problem solved!

              Comment

              Working...
              X