Announcement

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

  • opreg with If

    Hi Profs and Colleagues,

    I wonder if there is any difference between these two codes #1 & #2. I run #2 the result is fine though I have not run #1 because I don't know what "naf2" is. Is there anyone of statists who could assist me to read the first code? I mean what would look like "di "********** INDUSTRIA `industry' " in practice?


    Code:
    #1
    local ind2 "17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36"
    
    foreach industry of local ind2 {
        
          di "********** INDUSTRIA `industry' "
          opreg lntotal_production if naf2==`industry', exit(exit) state(lnk) proxy(lnInvtot) free(lnmaterials lnemp_tot)  cvars(trend)  vce(bootstrap, seed(1) reps(50))
          predict aux_op
          replace tfp_op_output=ln(aux_op)
          drop aux_op
    
    #2
    opreg lntotal_production, exit(exit) state(lnk) proxy(lnInvtot) free(lnmaterials lnemp_tot)  cvars(trend)  vce(bootstrap, seed(1) reps(50))
          predict aux_op
          replace tfp_op_output=ln(aux_op)
          drop aux_op
    All my thanks.
    Paris
    Last edited by Paris Rira; 19 Jan 2023, 13:52.

  • #2
    Your first block of code (with some corrections applied)
    Code:
    local ind2 "17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36"
    generate tft_op = .
    
    foreach industry of local ind2 {
          display "********** INDUSTRIA `industry' "
          opreg lntotal_production if naf2==`industry', exit(exit) state(lnk) proxy(lnInvtot) free(lnmaterials lnemp_tot)  cvars(trend)  vce(bootstrap, seed(1) reps(50))
          predict aux_op
          replace tfp_op_output=ln(aux_op) if naf2==`industry'
          drop aux_op
    }
    will run the opreg command 20 times, each time including only those observations for which the variable naf2 (presumably in you dataset, and containing an industry code) is equal to a single value from the list of industries in the local macro ind2, and creating industry-specific predictions.

    Your second block of code (again with corrections applied)
    Code:
    opreg lntotal_production, exit(exit) state(lnk) proxy(lnInvtot) free(lnmaterials lnemp_tot)  cvars(trend)  vce(bootstrap, seed(1) reps(50))
    predict aux_op
    generate tfp_op_output=ln(aux_op)
    drop aux_op
    will run opreg one time including all industries, and will use that model for all predictions.

    Comment


    • #3

      Prof William, thank you so much. You are perfect. In the second code, whats the correction? I am afraid I did not get it.

      Comment


      • #4
        You are correct, I started to simplify the second code, but I decided I wanted the two codes to as similar as possible to each other and your original code.

        I think the second code could be simplified to
        Code:
        opreg lntotal_production, exit(exit) state(lnk) proxy(lnInvtot) free(lnmaterials lnemp_tot)  cvars(trend)  vce(bootstrap, seed(1) reps(50))
        predict tfp_op_output, tfp
        but I am not an expert on the opreg command or the statistics behind it. The output of help opreg suggests that using the tfp option for predict will produce logged results.

        Comment


        • #5
          Thank you for flagging 'log form'.
          In the LP article in SJ, p120, the author notes that 'Predict assumes that the production function inputs are in log levels and adjusts ωt accordingly'. So the predict option produces TFP itself, not Ln (TFP).
          Therefore, for opreg I assume would be so. On the other hand, you mentioned help opreg says the other way around which put me in a dilemma...

          Comment


          • #6
            I found help opreg confusing with regard to the predict command, and my code was just following your code to produce ln(TFP). The explanation from the SJ article suggests that if what you want is TFP, that is what predict apparently gives without using the tfp option when the opreg inputs are logged, then I think what you want is as simple as
            Code:
            opreg lntotal_production, exit(exit) state(lnk) proxy(lnInvtot) free(lnmaterials lnemp_tot)  cvars(trend)  vce(bootstrap, seed(1) reps(50))
            predict tfp_op_output
            with none of the messing about with logs that you show in post #1.

            Comment


            • #7
              Well, if I understood properly, I can say that predict option in both opreg and Levpet does not produce log results. In case of a need a log form, I should code that separately. What I seek is Ln TFP, btw.

              Comment

              Working...
              X