Announcement

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

  • DEA by industry and MatSize Error

    Hi I want to calculate firm efficiency score for firms in my sample. My data looks like this
    FirmA IndustryA I.V 1 I.V 2 O.V
    Firm B Industry B I.V 1 I.V2 O.V
    Firm Z Industry C I.V 1 I.V2 O.V

    Data consist of 1500 observations (firm years). Each firm has been classified by 1 out of 8 industry groups. I am able to run DEA for each firm to get firm efficiency score successfully for a small sample (around 9 firms) of my sample by using following command.

    dea i.v1 i.v2 = o.v

    But when I run dea command for around 700 firms it gives an error of "matsize too small to create a [2119,6] matrix" I am using Stata 12 standard version having maximum matsize of 800. DEA result provide a number of columns in output, please have a look at picture. Now my first question is, if there is any option where I can get only the theta (Efficiency score) column against each DMU in my DEA result instead of getting a large amount results (probably it is increasing matsize). If the problem of Matsize will be solved if only theta column against each DMU is obtained in results.

    Second I tried to run DEA by industry using following command by "industry, sort: dea i.v1 i.v2 = o.v" Stata gives me an error that "dea may not be combined with by". can you please guide me how can I run DEA by industry to get efficiency score for each firm. Thanks

  • #2
    The photo is unreadable to me: see standing advice in FAQ that photos are to be avoided in favour of copy and paste as CODE.

    Numbering your problems:

    1. I guess you need to upgrade to at least Stata 13 SE or clone and rewrite dea (SJ, as you are asked to explain) to write around the matsize limit.

    2. Loop using foreach or forval and a method in http://www.stata.com/support/faqs/da...-with-foreach/ (assuming #1 does not bite).

    Comment


    • #3
      Hi Nick thanks for reply. I tried with following code, can you please tell me where I am doing mistake

      foreach i in 0 1{
      2. if industry == 'i'
      3. dea i.v 1 i.v2 = o.v
      4. }
      it gives an error of ('i' invalid name)

      Thanks

      Comment


      • #4
        Look at the help e.g. http://www.stata.com/help.cgi?ifcmd

        The if command needs to be followed by a left brace { or a command. You missed out the brace.

        Comment


        • #5
          But this loop won't do what Ali wants anyway. He has used an if command, when what he needs is an if qualifier on his -dea- command:

          Code:
          forvalues j = 0/1 {
              dea i.v1 i.v2 = o.v if industry == `j'
          }
          Note: I am unfamiliar with the -dea- command and I do not know whether the syntax proposed is legitimate or not. In the event that -dea- does not accept -if- qualifiers, then something a bit more drastic is required:

          Code:
          forvalues j = 01 {
              preserve
              keep if industry == `j'
              dea i.v1 i.v2 = o.v
              restore
          }
          Finally, I'll just note that that whole -dea i.v1 i.v2 = o.v- syntax feels weird. It is a very odd use of factor variable notation and I particularly do not understand the use of the o. prefix here. But, as I say, I don't know the -dea- command.

          Comment


          • #6
            Clyde's absolutely right. I didn't look past the immediate syntax question.

            Comment


            • #7
              Hi Clyde and Nick. Thanks for your reply. First answering your question about o.v - prefix, according to my understanding it is the requirement of DEA to to identify input and output variables with i and o. I tried with following command to run DEA by industry it worked well for me. But result for firm efficiency of each firm is still same if the simple DEA command is used without entering the option of "by industry, the code is as follows.


              Code:

              foreach i in industry{
              dea i_v_1 i_v = o_v if industry == `i'
              }

              Now i am only confuse why results are same in both cases for firm efficiency score of each firm, if my code is correct??? or any other reason. Thanks.

              Comment


              • #8
                The commands mentioned by Clyde did not work, May be the reason that my industry variable is a string type.....

                Comment


                • #9
                  Warning

                  I have never used dea (SJ) or even studied its code or help file. I guess Clyde is exactly in the same situation. Judging from the lack of other posts, it is a rarely used command. So, what happens is that you will get reactions when it appears that you are missing some point of general Stata syntax. Understanding what dea requires remains your responsibility.

                  Your #8


                  You are correct. If industry is of type string, then the syntax mentioned will fail. You need to use " " around string constants.

                  But this was your syntax, written in #3, in which you were cycling over industries 0 1 precisely as if they were numeric codes.

                  Your #7

                  Your loop is legal but

                  Code:
                  foreach i in industry {
                       dea i_v_1 i_v = o_v if industry == `i'
                  }
                  boils down to

                  Code:
                  dea i_v_1 i_v = o_v if industry == industry
                  and the if condition there is always satisfied, with the result you report. foreach ... in does not mean that the loop looks inside a variable mentioned and cycles over its distinct values. For an easier way to cycle over groups, see the Method 1 in the FAQ cited in #2.

                  Factor variable notation and variable names

                  It now seems that you were using, or trying to use, factor variable notation using dot operators where no such notation is required by dea. Clyde reasonably signalled that this seemed a very surprising syntax.

                  Note that underscores _ are allowed in variable names in Stata, but dots or periods . are not. But they are allowed in factor variable notation. (If you have more experience with other statistical programs, you will know that periods with no special meaning are allowed in names in some other software.)

                  For more on factor variables, see http://www.stata.com/help.cgi?factor_variable

                  It's even possible that your difficulties with matrix size were a bizarre side-effect of using factor variable notation where it didn't apply, but I really don't know.

                  On reporting problems

                  Your questions are more difficult to understand than they need be because

                  1. A reports such as "did not work" is not itself informative. Please re-read FAQ Section 12 to see explicit advice on always reporting the exact syntax used and exactly what happened, including error messages.

                  2. You should use CODE mark-up as used by Clyde and myself. CODE mark-up was mentioned in #2 and is explained in the FAQ Advice. It takes two minutes to learn.

                  It's in your interests to make your questions readable and more likely to be read!
                  Last edited by Nick Cox; 26 Mar 2015, 04:19.

                  Comment


                  • #10
                    Hi Nick and Clyde, Thank you so much for your help. Now I am able to perform this task successfully. Heaps of Thanks

                    Comment


                    • #11
                      Hi Nick and Clyde. Thanks again for your help. I was able to successfully run DEA command and got my results as well, but suddenly I started getting error regarding subscript invalid. It will be great if you can please help me to get out of this error. Thanks


                      Command:
                      . dea i_variable = o_variable
                      --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                      name: dealog

                      log type: text
                      opened on: 12 Apr 2015, 15:54:59
                      rankdea(): 3301 subscript invalid
                      <istmt>: - function returned error

                      Comment


                      • #12
                        Ir's best to think that you're addressing the forum, not particular people who happened to answer a question. In this case, you are getting a message from deep inside the program. It's a program I don't use and your data aren't visible. I'd advise contacting the program authors.

                        Comment


                        • #13
                          Ok Thanks a lot.

                          Comment

                          Working...
                          X