Announcement

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

  • Bootstrap DEA Results

    Hello,
    I'm using dea command in Stata to compute efficiency: dea x1 x2 x3 = y1 y2. For x1, x2 and x3: inputs variables; y1 and y2: outputs variables. The result returns a matrix r(dearslt), that the second column indicates the results.

    I'm interested to run a bootstrap with my data, so in Stata:

    bootstrap ex_list, rep (#): dea x1 x2 x3 = y1 y2

    So, how I indicate to Stata to use this column in exp_list. Better saying, what I put in exp_list do run the DEA's bootstrap?

    Thank you very much!

  • #2
    You can't put a matrix into an expression list for -bootstrap-. You will need to write a wrapper program for -dea- that extracts the relevant outputs and stores them in scalars, and then put those scalars in the expression list. So, if for the sake of example I assume that dea returns a matrix with (at least) 2 columns (of which the 2nd is the relevant output) and 5 columns, it would be like this:

    Code:
    capture program drop dea_wrap
    program define dea_wrap, rclass
        dea x1 x2 x3 = y1 y2
        tempname M
        matrix `M' = r(dearslt)
        forvalues i = 1/5 {
            return scalar result`i' = `M'[`i', 2]
        }
        exit
    end
    
    bootstrap result1 result2 result3 result4 result5, rep(#): dea_wrap
    Note: not tested. Beware of typos, unbalanced braces, etc.

    Comment


    • #3
      Thank You!

      Comment


      • #4
        Dear Schechter, the following message appears: matrix operation not found. I'm new to programming and I do not know why this problem is appearing. I think I will migrate to R. rsrsrsrsr

        Comment


        • #5
          Dear Schechter, I fixed the problem about Matrix. But now appears the follow message: result not found.

          Comment


          • #6
            If you want more help with this, you'll have to show an example of your data, using the -dataex- command to do so, and show the exact code you are running, and the complete output from that code up to and including the error message. Read the FAQ, with attention to #12 on the most helpful ways of doing this. All of this information is needed because it isn't possible to debug how imaginary code works with imaginary data.

            Comment


            • #7
              Professor Schechter, I'm using the dea command in Stata 14. The return list is a matrix called r(dearslt).
              follow the data base from dataex and the code that I'm using.

              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input str5 dmu byte(x1 x2 x3 y1 y2)
              "DMU1"  85 19 34 51 80
              "DMU2"  75 14 10 60 71
              "DMU3"  74 25 15 53 82
              "DMU4"  61 21  8 49 79
              "DMU5"  76 35 13 43 76
              "DMU6"  79 81 54 31 29
              "DMU7"  45 47 92 30 82
              "DMU8"  92 90 73 42 20
              "DMU9"  41 73 38 30 62
              "DMU10" 48 29 96 27 80
              "DMU11" 41 54 66 79 86
              "DMU12" 53 62 76 93 32
              "DMU13" 60 60 62 95 34
              "DMU14" 48 27 53 21 86
              "DMU15" 93 33 69 85 64
              "DMU16" 53 86 23 95 75
              "DMU17" 68 30 45 40 21
              "DMU18" 22 41 34 37 54
              "DMU19" 44 53 57 24 54
              end

              Code:
              capture program drop dea_wrap
              program define dea_wrap, rclass
                  dea x1 x2 x3 = y1 y2
                  tempname M
                  matrix `M' = r(dearslt)
                  forvalues i = 1/19 {
                      return scalar result`i' = `M'[`i', 2]
                  }
                  exit
              end
              
              bootstrap result1 result2 result3 result4 result5 result6 result7 result8 ///
              result9 result10 result11 result12 result13 result14 result15 ///
              result16 result17 result18 result19 , rep(100): dea_wrap

              *The Output of Stata
              [CODE]
              bootstrap result1 result2 result3 result4 result5 result6 result7 result8 ///
              > result9 result10 result11 result12 result13 result14 result15 ///
              > result16 result17 result18 result19 , rep(100): dea_wrap
              (running dea_wrap on estimation sample)
              options: RTS(CRS) ORT(IN) STAGE(2)
              result1 not found
              error in expression: result1
              r(111);
              [ /CODE]


              Professor, I ran the return list after the boostrap above and I found the problem. Really, the result1 resul2 ... result19 should be like this: r(result1) r(result2) ... r(result19).

              Sorry for the setbacks. And about R was a joke. I love Stata!

              Thank You very much for your time. You help very much.





              Comment


              • #8
                Sorry, my error in the coding for -bootstrap-. The results list has to mention the returned scalars specifically as being in r(). So, for example:

                Code:
                bootstrap result1 = r(result1) result2 = r(result2) result3 = r(result3) result4 = r(result4) ///
                    result5 = r(result5), reps(100): dea_wrap
                Now, for 19 results, that's quite a bit of typing and likely to contain errors. So it is better to actually generate this results list in a loop creating a local macro and then referencing that local macro in the -bootstrap- command. Beginning to end it looks like this:

                Code:
                * Example generated by -dataex-. To install: ssc install dataex
                clear
                input str5 dmu byte(x1 x2 x3 y1 y2)
                "DMU1"  85 19 34 51 80
                "DMU2"  75 14 10 60 71
                "DMU3"  74 25 15 53 82
                "DMU4"  61 21  8 49 79
                "DMU5"  76 35 13 43 76
                "DMU6"  79 81 54 31 29
                "DMU7"  45 47 92 30 82
                "DMU8"  92 90 73 42 20
                "DMU9"  41 73 38 30 62
                "DMU10" 48 29 96 27 80
                "DMU11" 41 54 66 79 86
                "DMU12" 53 62 76 93 32
                "DMU13" 60 60 62 95 34
                "DMU14" 48 27 53 21 86
                "DMU15" 93 33 69 85 64
                "DMU16" 53 86 23 95 75
                "DMU17" 68 30 45 40 21
                "DMU18" 22 41 34 37 54
                "DMU19" 44 53 57 24 54
                end
                
                capture program drop dea_wrap
                program define dea_wrap, rclass
                    dea x1 x2 x3 = y1 y2
                    tempname M
                    matrix `M' = r(dearslt)
                    forvalues i = 1/19 {
                        return scalar result`i' = `M'[`i', 2]
                    }
                    exit
                end
                
                local results
                forvalues i = 1/19 {
                    local results `results' result`i' = r(result`i')
                }
                
                bootstrap `results' , rep(100): dea_wrap
                Note: Tested and runs without errors or breaks. As I don't know anything about -dea- and have never used it before, I can't say whether the results it generates are correct or make sense.

                Comment


                • #9
                  Thank You, Professor Schechter.

                  Comment


                  • #10
                    hello Professor Schechter, I work on the efficiency of hospitals, I need to know the order stata for regressions.

                    Comment


                    • #11
                      Please read the Forum FAQ for excellent advice on how to post questions in ways that maximize your probability of getting a timely and helpful response.

                      Among the things you will learn there are:

                      1. It is unwise to address your question to a specific person unless you are specifically asking about something that person said earlier on the forum (and in that case you should provide a link or reference to what was said). By addressing one person, you reduce the chance that others who might be even more helpful will bother to read your question, let alone respond.

                      2. Questions added to an existing thread should represent continuation of the topic of that thread. Your post in #10 does not appear to be related to the preceding posts in this thread, although your question is sufficiently vague that perhaps it does relate in some way that is difficult to perceive.

                      3. Questions should be clear and focused. It is unclear what "the order stata for regressions" even means. Describe your research goals and your data. If you are asking for help with code, be sure to include example data in your post, and be sure to use the -dataex- command to do that. Identify clearly what you want to compute and provide an example of what the results should look like. If you have already tried some code but have not gotten the results you want, show the code you tried (exactly as it was--don't edit it at all) and the results it gave you, along with an explanation of how the results you got differ from what you are looking for.

                      Comment

                      Working...
                      X