Announcement

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

  • How to estimate Modified Jones by each country from a cross-country dataset

    I tried to use the following command, but it does not work.

    gen preta_c=.
    xtset c_id_new year
    tempvar ta
    levelsof two_sic_code,local(levels)
    foreach x of local levels{
    foreach z of numlist 2009/2020{
    capture bys country_id: reg ta mdj_x1 mdj_x2 mdj_x3 if two_sic_code==`x' & year==`z'
    if !_rc {
    predict `ta'
    replace preta_c=`ta' if e(sample)
    drop `ta'
    }
    }
    }

  • #2
    Jack:
    welcome to this forum.
    Surely what follows does not explain why your code did not get you what you wanted, but why -xtset- your dataset and then go -regress-?
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Carlo:
      Thank you. I want to generate the coefficients by country, industry, and year. However, I did know how to write the command.
      Kind regards,
      Jack

      Comment


      • #4
        Jack:
        1) see https://www.statalist.org/forums/for...r-syntax-error ;
        2) consider the community-contributed module -reghdfe- if your want to estimate multiple fixed effects.
        Last edited by Carlo Lazzaro; 27 Dec 2023, 01:44.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          I appreciate your help. Thank you.

          Comment


          • #6
            I tried to use this command, but it did not work.

            vallist two_sic_code
            local a =r(list)
            vallist year
            local b =r(list)
            vallist country_id
            local c =r(list)
            gen uhat=.

            xtset
            foreach i in `a' {
            foreach x in `b' {
            foreach j in `c' {
            capture noisily reg ta mdj_x1 mdj_x2 mdj_x3 if two_sic_code==`i' & year==`x' & country_id= `j', nocons
            capture noisily predict uhat_2, resid
            capture noisily replace uhat= uhat_2
            capture noisily drop uhat_2
            di `i'
            di `x'
            di `j'
            }
            }
            }

            invalid syntax
            last estimates not found

            Comment


            • #7
              first, please read the FAQ on why "it did not work" is not sufficient information and what you should say instead

              second, see
              Code:
              h trace
              for a way to find out where in your code the problem is (note that you should also read about "tracedepth" (same help file))

              Comment

              Working...
              X