Announcement

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

  • New on SSC: - prodest - module for production function estimation

    Code:
    ssc install prodest
    prodest is a new and comprehensive Stata module for production function estimation based on the control function approach. It includes Olley-Pakes (OP 1996), Levinshon-Petrin (LP 2003), Wooldridge (WRDG 2009) and Ackerberg-Caves-Frazer (ACF 2015) estimation techniques, plus a brand new methodology (Mollisi-Rovigatti, MR forthcoming) in order to better deal with short panels.
    Its basic usage is similar to that of existing modules like opreg or levpet, but adds many features to control the optimization procedures and address estimation issues - gross output vs. value added, endogenous variables, attrition in the data. Type
    Code:
    help prodest
    for a complete overview of options and features of the program, plus some clickable examples.

    prodest is an ongoing project and the current version (1.0.2) is not meant not be definitive. Therefore suggestions, impressions and bug reporting are more than welcome.

    Below some examples of the program usage

    Code:
    . insheet using https://raw.githubusercontent.com/GabBrock/prodest/master/prodest.csv, names clear
    (8 vars, 1,758 obs)
    
    
    . prodest log_y, free(log_lab1 log_lab2) state(log_k) proxy(log_investment) va met(op) poly(4) opt(
    > bfgs) reps(40) id(id) t(year)
    .........10.........20.........30.........40
    
    
    op productivity estimator
    
    Dependent variable: value added                 Number of obs      =      1758
    Group variable (id): id                         Number of groups   =       386
    Time variable (t): year
                                                    Obs per group: min =         1
                                                                   avg =       4.6
                                                                   max =        12
    
    ------------------------------------------------------------------------------
           log_y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        log_lab1 |   .2602104   .0454651     5.72   0.000     .1711005    .3493204
        log_lab2 |   .1609835   .0492148     3.27   0.001     .0645242    .2574428
           log_k |   .2963724   .0824046     3.60   0.000     .1348624    .4578824
    ------------------------------------------------------------------------------
    
    . prodest log_y, free(log_lab1 log_lab2) state(log_k) proxy(log_investment) va met(op) acf opt(nm)
    > reps(50) id(id) t(year)
    .........10.........20.........30.........40.........50
    
    
    op productivity estimator
    ACF corrected
    Dependent variable: value added                 Number of obs      =      1758
    Group variable (id): id                         Number of groups   =       386
    Time variable (t): year
                                                    Obs per group: min =         1
                                                                   avg =       4.6
                                                                   max =        12
    
    ------------------------------------------------------------------------------
           log_y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        log_lab1 |   .2161255   .0995254     2.17   0.030     .0210593    .4111917
        log_lab2 |   .2362255   .0637043     3.71   0.000     .1113673    .3610836
           log_k |   .4552823   .0930899     4.89   0.000     .2728295     .637735
    ------------------------------------------------------------------------------
    
    . prodest log_y, free(log_lab1 log_lab2) state(log_k) proxy(log_materials) va met(lp) opt(dfp) reps
    > (50) id(id) t(year)
    .........10.........20.........30.........40.........50
    
    
    lp productivity estimator
    
    Dependent variable: value added                 Number of obs      =      1758
    Group variable (id): id                         Number of groups   =       386
    Time variable (t): year
                                                    Obs per group: min =         1
                                                                   avg =       4.6
                                                                   max =        12
    
    ------------------------------------------------------------------------------
           log_y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        log_lab1 |   .2262627   .0386052     5.86   0.000     .1505978    .3019276
        log_lab2 |   .1518426   .0389601     3.90   0.000     .0754821     .228203
           log_k |   .2155473   .0409458     5.26   0.000     .1352951    .2957996
    ------------------------------------------------------------------------------

  • #2
    EDIT: method(mr) raises an error - esample() invalid - in Stata version 14.2 . Unfortunately, there is no way to fix it at the moment - it is a gmm failure due to improper tempvar initialization within the gmm.ado code.
    Thanks to Kit Baum, who managed to contact the tech support, the issue will be fixed with the next update. Since then, though, guys running 14.2 will have to live without the amazing mr method

    Comment


    • #3
      The new version of prodest is now available on SSC:
      We fixed a major bug with bootstrap repetitions - which could badly bias the estimates - plus added an error handling (now the program only stops in case of optimization failure on the baseline estimation, otherwise skips the boot repetition) and we added some useful options:

      - fsresiduals(varname) option to store first stage residuals in varname after the estimation;

      - seed(#) option to set the seed;

      - evaluator(eval_type) to set the evaluator type - default is gf0 for bhhh and d0 for other optimizators.

      Type ​​​
      Code:
      ssc install prodest, replace
      to replace the old code with the new version.

      Best,

      Gabriele

      Comment


      • #4
        Dear Gabriele and everyone else using this code,
        I have just downloaded your package and am looking forward to using it soon!
        When installing it though I encounter a problem (I only have this problem when it run the ado files on stata on the server where the data I use is stored on, I dont have this problem on my stata desktop version); I get an error claiming that all the variables listed under the first paragraph in the mata section are undeclared
        (I cannot post the excepts of the code due to strict privacy reasons, but hopefully this is pretty straightforward nonetheless).
        Would you have an idea how to sort this out?
        Your answer would be much appreciated.

        Samira

        Comment


        • #5
          Dear Samira,

          thanks for your message. I hope that you will find prodest useful.

          I am not sure what you mean with "installing" the package: in general, as you know to install a Stata package you need to either run ssc install prodest on your Stata (you must have a working internet connection to do that) or copy/paste the file prodest.ado in the ~/ado/plus/p folder on your machine. You mentioned privacy reasons - which seem to be quite strict, given that you cannot even copy the error codes - so I suppose that you had to do the latter.

          What is unclear, though, is if the error comes out when you call prodest on your data or if you directly run prodest.ado and it raised the error - which unfortunately I cannot reproduce. In the former case I will inverstigate the issue further if you send me a minimal example (the error code would be the very least); in the second case, I would strongly recommend not to do that, and just rely on the usual installing procedure.

          Best,

          Gabriele

          Comment


          • #6
            Hey Gabriele,

            Thanks for your reply.
            Yes you were correct, I uploaded the ado files (there are two as far as I am aware) to the server and then called them via the do command via the path to it.
            I have done this also with other packages (xtabond2, opreg, levpet etc.) but didn't incur this problem previously.
            The error I get is variable ..... undeclared where the dots here represent all the variables listed under the first paragraph in the mata section (so there are 9 of these variables listed as undeclared), followed by r(3000).
            If I get the same error when calling prodest on the data I am unaware at this point, since at this point I don't even get to the install the package properly.
            If you have any idea, it would be much appreciated, thanks again.

            Greetings,

            Samira

            Comment


            • #7
              Dear Samira,

              the adofiles are indeed 2; however, mata is used in prodest.ado only, so I'd focus on it.
              Unfortunately I cannot reproduce the error on my machine (Stata 13.1 or 14.2, Windows), and if you are using a server I suspect that it is a Linux machine - can you confirm that your OS is Unix-based? Furthermore, it would be very helpful if you could tell me whether the module is working once properly installed (not with the do command).

              I hope to be able to come back to you as soon as I will have the possibility to test the command on a server next week.

              Best,

              Gabriele

              Comment


              • #8
                Hey Gabriele,
                Many thanks once more for helping me out, I really appreciate it! Also you are correct, this is only a problem with respect to the prodest.ado, the prodest_p.ado runs without any problem, so I suspect the issue is with the mata in some way.
                When I do the ado file on my desktop, which is a Mac with Stata 14 on it, there is no problem. The problem is only on the server, which I am not sure if it is Unix based, I will contact the people responsible for the server and double check, I suspect it might be though.
                Given that I couldn't install it on the server yet, I am not sure if it runs smoothly, but on my computer (the Mac) it runs without problems once installed.

                Greetings,

                Samira

                Comment


                • #9
                  Thanks to Kit Baum, a new version of prodest is now available on SSC:

                  - Fixed a major bug in MrEst, which on the one hand speeds up the computation and solves major inconsistencies in previous results, on the other prevents Stata versions previous to the 14.2 to run the method (i.e. met(mr) only works in Stata 14.2);

                  - Fixed a minor bug on Wooldridge, now fully consistent using control variables:

                  - Fixed a minor bug on Wooldridge and MrEst results table names;

                  - Added an option to estimate ACF corrected model with a translog production function;

                  - Fixed a minor bug allowing the estimation of models with multiple state AND multiple proxy variable (though it is possible to estimate model with either multiple state OR multiple proxy);

                  - Added an option allowing the specification of estimation starting points.


                  Type ​​​
                  Code:
                  ssc install prodest, replace
                  to replace the old code with the new version.


                  A working paper version describing the module as well as the new MrEst estimator has been published and is available here. For all prodest users, please cite:

                  Mollisi, Vincenzo and Rovigatti, Gabriele, 2017. "Theory and Practice of TFP Estimation: The Control Function Approach Using Stata", CEIS Working Paper No. 399.


                  Best,

                  Gabriele

                  Comment


                  • #10
                    HI i want to ask a question

                    If I already run the op methods, how do i to predict the TFP?

                    have any command

                    Thanks

                    Comment


                    • #11
                      Dear Gabriele,
                      I am estimation a production function using your command "prodest". Actually, I have a question, after running the regression. How could I predict the TFP?
                      Is the option "fsresidual(newname)", in your command predicts the TFP automatically?
                      I will do it using the same command in "levpet" i.e. predict varname , omega? Or there is another command o predict TFP using your command.

                      Many thanks,
                      Aya
                      Last edited by Aya Elewa; 20 Apr 2017, 12:51.

                      Comment


                      • #12
                        I think I got the answer.
                        Code:
                        predict newvarname, resid
                        will predict the log value of TFP.

                        Thanks,
                        Aya

                        Comment


                        • #13
                          Dear Gabriele,

                          You said in a previous post that you've been inspired by the levpet (SSC) program to develop your own prodest.
                          I have though a remark on the way to compute TFP from the residual of the two programs.

                          It appears that the levpet program gives the TFP in value, while prodest seems to give it in logs (see example below to see the code).

                          Could you confirm that the residual of the prodest estimation is the log(TFP)? This doesn't appear clearly in the help file.

                          Anyway, thanks for your great program it works fine (although takes some time to run, but that's certainly not your fault).

                          Best,
                          Charlie


                          Code:
                          levpet logVA, free(logL) proxy(logInput) capiral(logK) i(id) t(year) value
                          predict TFP,omega
                          
                          prodest logVA, free(logL) proxy(logInput) state(logK) method(wrdg) i(id) t(year) value
                          predict tfp, residual



                          Comment


                          • #14
                            Dear Chin, Aya and Charlie,

                            I am very sorry for the late reply: I have not been notified your messages by email, hence I have only saw them now.

                            Aya Elewa is right - and this should answer Chin Yi 's question, if I have correctly interpreted:
                            Code:
                            predict newvarname, resid
                            will compute the estimated TFP and as Charlie Joyez remarked, it is in LOG.

                            Let me stress, though, that the predict_p.ado command that you all have downloaded with prodest is still a work in progress: that's the reason why it is not properly documented in the helpfile, nor it has some nice features I am planning to add in the near future (like, to get to Charlie's point, add an option to compute TFP either in levels as in levpet or in logs as it is now).

                            Last point: prodest, met(wrdg) is in fact a little bit slower than levpet, whereas - in all but a couple of tryouts - prodest, met(lp) appears to be faster. Obviously, the choice of the mathod matters, and the system GMM is quite cumbersome in terms of computational time. I will be releasing an R version of prodest very soon: I can already tell that it is way faster than Stata's, though still less customizable. Given the nature of this forum (Stata-related) I will not write here any other information on the R version: for all those interested, either look at new packages on CRAN or shoot me an email in the next few weeks.

                            Best,

                            Gabriele

                            Comment


                            • #15
                              Dear Gabriele,
                              Thanks for your answer, I'll be very interested in looking at the R version.
                              Best,
                              Charlie

                              Comment

                              Working...
                              X