Announcement

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

  • Lag operator behaving strangely

    Dear all,
    Today I am experiencing an error which is quite strange (STATA 18 SE). I have the following code:

    Code:
    reghdfe d.Y (L(0/2)(${xlist2}))                      ///
                        (L(0/2)(${xlist2}))#i.orig_ht_exp_cat,                           ///
                        absorb(orig_isic_aux orig_iso_aux#year) vce(cluster orig_iso_aux)
    where ${xlist2}) is a global containing a set of variables names - this works well in other codes.

    This code yields the following error:
    string variables not allowed in varlist;
    is a string variable


    Note that the space on the second line before "is a string variable" is not a typo, but it is in the error I get. This is strange as it seems that a variable name is not read properly.

    I was initially thinking that the error was driven by the interacted categorial variable (strange because this is a float variable which has been previously encoded). However, I have realised that it is driven by the "0" in the lag operator when it is combined with my interacted variable. Specifically, the code works when:
    • I remove the interacted categorical variable, OR
    • I substitute 0 with 1 in the lag operator
    This is quite strage to me and I really don't know how to explain it. I don't think this is a syntax error as the alternative

    Code:
    reghdfe d.Y ${xlist2}                                ///
                        ${xlist2}#i.orig_ht_exp_cat                ///
                        (L(1/2)(${xlist2}))                                   ///
                        (L(1/2)(${xlist2}))#i.orig_ht_exp_cat,                           ///
                        absorb(orig_isic_aux orig_iso_aux#year) vce(cluster orig_iso_aux)
    Yields the same error.

    Thanks in advance for your help

  • #2
    Can you show the results of
    Code:
    tsset
    di "${xlist2}"
    dataex Y ${xlist2} orig_ht_exp_cat orig_isic_aux orig_iso_aux year

    Comment


    • #3
      Hi Nils Enevoldsen thank you for your availability! I get the error "factor-variable and time-series operators not allowed".

      I guess it is because I have variables expressed with the first difference operator in my globals:

      Code:
      global xlist1_t  c.d.yearly_avg_t
      global xlist2_t  ${xlist1_t} c.d.yearly_avg_t_ord2
      global xlist3_t  ${xlist2_t} c.d.yearly_avg_t_ord3
      global xlist4_t  ${xlist3_t} c.d.yearly_avg_t_ord4
      
      global xlist1_p  c.d.tot_prep_year
      global xlist2_p  ${xlist1_p} c.d.tot_prep_year_ord2
      global xlist3_p  ${xlist2_p} c.d.tot_prep_year_ord3
      global xlist4_p  ${xlist3_p} c.d.tot_prep_year_ord4
      
      global xlist1  ${xlist1_t} ${xlist1_p}
      global xlist2  ${xlist2_t} ${xlist2_p}
      global xlist3  ${xlist3_t} ${xlist3_p}
      global xlist4  ${xlist4_t} ${xlist4_p}
      Do you want me to try without the D. operator?

      Moreover, the code works smoothly on my University cloud computer, which is even more strange.

      Comment


      • #4
        Alright, then just report -tsset- and:
        Code:
        dataex Y yearly_avg_t_ord2 tot_prep_year_ord2 orig_ht_exp_cat orig_isic_aux orig_iso_aux year

        Comment

        Working...
        X