Announcement

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

  • Test monotonicity for a translog cost function

    Hello,

    I am trying to test the monotonicity of a translog cost function following "A Practitioner's Guide to Stochastic Frontier Analysis Using Stata (page 166)", but I could not understand a passage from the book. They estimated the following function:

    Click image for larger version

Name:	teste1.png
Views:	1
Size:	297.5 KB
ID:	1603984



    They obtained the following results:
    Click image for larger version

Name:	teste2.png
Views:	2
Size:	543.6 KB
ID:	1603986



    Finally, in order to do the monotonicity test, they run the following command:
    Click image for larger version

Name:	teste3.png
Views:	1
Size:	359.2 KB
ID:	1603987



    From what I know, to obtain the share equations that will be used to test for monotonicity it is necessary to take the partial derivative of the cost in relation to a given input. However, I think the code above does not correspond to a result of a derivate.

    I would appreciate it if someone could explain it to me or show me another way to test the monotonicity.
    Attached Files
    Last edited by Mateus Maciel; 16 Apr 2021, 09:08.

  • #2
    From what I know, to obtain the share equations that will be used to test for monotonicity it is necessary to take the partial derivative of the cost in relation to a given input. However, I think the code above does not correspond to a result of a derivate.
    It does. Recall that in your displayed equation, you have imposed price homogeneity by dividing \(tc\) and other input prices by \(wf\). Had you not done this, you would have written the translog cost function (dropping the subscript \(i\) as:

    \(ltC= \beta_{0}+ \beta_{y} ly+\beta_{l} lwl + \beta_{k} lwk + \beta_{f} lwf+\frac{1}{2} \beta_{yy} ly^2 + \frac{1}{2}\beta_{ll}lwl^{2} + \frac{1}{2}\beta_{kk}lwk^{2} + \frac{1}{2}\beta_{ff}lwf^{2}+\beta_{yl} ly*lwl +\beta_{yk} ly*lwk+\beta_{yf} ly*lwf+\beta_{lk} lwl*lwk+\beta_{lf} lwl*lwf+\beta_{kf} lwk*lwf+\eta_{i}+v_{i}.\;\;\;(Eq. 1)\)

    Taking the derivative with respect to one of the input prices, say \(wl\), we have:

    \(\frac{\partial ltC}{\partial lwl} = \beta_{l} + \beta_{ll}*lwl + \beta_{ly}*ly+ \beta_{lk}*lwk+ \beta_{lf}*lwf.\;\;\;(Eq. 2)\)

    As we estimate the equation after imposing price homogeneity (#1), there is no \(\hat{\beta_{lf}}\) which is needed to compute the derivative. However, we can recover this coefficient since the price homogeneity conditions imply \(\beta_{ll}+ \beta_{lk}+ \beta_{lf}=0\) and thus \(\beta_{lf}= -\beta_{ll}- \beta_{lk}\).

    Comment


    • #3
      Andrew Musau, thank you so much for the explanation. Now I understand.

      I saw that you helped other users with questions related to the translog and I think you could help me with another doubt.

      In the book, the authors say that we can check how many observations violating the monotonicity condition by running the command:
      Code:
      list if mono_wl <0
      .

      Is there any other command to check it? Because the command suggested by the book gave me a strange output.

      Comment


      • #4
        What does "strange" in this context mean? You either find that no observations violate the monotonicity condition for a particular input price or some observations do, and this therefore warrants further investigation of why such violations occur. Any different approach should lead to the same conclusion, but this is how it is usually done.

        Comment


        • #5
          Andrew Musau, the monotonicity test worked, and thanks for the help. However, I cannot run the code for the concavity test. Here is the code provided in the book:

          Click image for larger version

Name:	conc1.png
Views:	1
Size:	147.2 KB
ID:	1605218


          I tried to type a similar code:

          Code:
          matrix C = (_b[K_2], _b[K_Q], _b[e_p_K], _b[w_p_K], (-_b[K_2] -_b[w_p_K] -_b[e_p_K])\ _b[K_Q], _b[Q_2], _b[e_p_Q], _b[w_p_Q], (-_b[Q_2] -_b[w_p_Q] -_b[e_p_Q])\_b[e_p_K], _b[e_p_Q], _b[e_p_2], _b[e_p_w_p], (-_b[e_p_2] -_b[e_p_w_p] -_b[e_p_K])\_b[w_p_K], _b[w_p_Q], _b[e_p_w_p], _b[w_p_2], (-_b[w_p_2] -_b[e_p_w_p] -_b[w_p_K])\(-_b[K_2] -_b[w_p_K] -_b[e_p_K]), (-_b[Q_2] -_b[w_p_Q] -_b[e_p_Q]), (-_b[e_p_2] -_b[e_p_w_p] -_b[e_p_K]), (-_b[w_p_2] -_b[e_p_w_p] -_b[w_p_K]), (_b[w_p_2] + _b[e_p_2] + _b[K_2] + 2*_b[e_p_w_p] + 2*_b[w_p_K] + 2*_b[e_p_K]))
          
          forvalues i = 1/`nofobs' {
          matrix S = (mono_KKKK[`i'], mono_eEEE[`i'], mono_wWWW[`i'], mono_QQQQ[`i'],mono_ppPP[`i'])'
          matrix A = C - diag(S) + S*S'
          matrix symeigen x v = A 
          scalar docheck = 1
          forvalues j = 1/5 { 
          if v[1,`j']>0.0001 & docheck ==1 {
          scalar violation = violation + 1
          scalar docheck = 0
           }
           }
           }
          
          display violation
          Nevertheless, Stata says that the syntax is invalid. What am I doing wrong?

          Comment


          • #6
            You can trace where the error occurs by including the command

            Code:
            set trace on
            before running the code. See

            Code:
            help trace

            One thing that I can spot is that you have not defined the local `nofobs'. If this is the number of observations in the dataset, you can replace this with `=_N'. Otherwise, you need to attach a data example to accompany the full code for help in debugging.

            Comment


            • #7
              Thanks, Andrew. I attached the dataset that I am using and here are my codes:

              Code:
              egen Ce_mean = mean(despesa_exploracao)
              
              egen Ct_mean = mean(despesa_total)
              
              egen Q_mean = mean(volume_produzido_agua)
              
              egen K_mean = mean(extensao_rede)
              
              egen p_mean = mean(materiais)
              
              egen w_mean = mean(salario)
              
              egen e_mean = mean(energia)
              
              generate Ce_p = (log(despesa_exploracao) - log(Ce_mean))/(log(materiais) - log(p_mean))
              
              generate Ct_p = (log(despesa_total) - log(Ce_mean))/(log(materiais) - log(p_mean))
              
              generate Ce = log(despesa_exploracao) - log(Ce_mean)
              
              generate Ct = log(despesa_total) - log(Ce_mean)
              
              generate Q = log(volume_produzido_agua) - log(Q_mean)
              
              generate K = log(extensao_rede) - log(K_mean)
              
              generate Q_2 = 0.5*(Q)^2
              
              generate K_2 = 0.5*(K)^2
              
              generate K_Q = K*Q
              
              generate e = log(energia) - log(e_mean)
              
              generate p = log(materiais) - log(p_mean)
              
              generate w = log(salario) - log(w_mean)
              
              generate e_p = (log(energia) - log(e_mean))/(log(materiais) - log(p_mean))
              
              generate w_p = (log(salario) - log(w_mean))/(log(materiais) - log(p_mean))
              
              generate e_p_2 = 0.5*(e_p)^2
              
              generate w_p_2 = 0.5*(w_p)^2
              
              generate e_p_w_p = e_p*w_p
              
              generate e_p_Q = e_p*Q
              
              generate e_p_K = e_p*K
              
              generate w_p_Q = w_p*Q
              
              generate w_p_K = w_p*K
              
              
              xtset code_7 ano
              
              xtreg Ct_p price_cap_1 price_cap_2 cost_plus_1 cost_plus_2 cost_plus_3 Q K Q_2 K_2 K_Q e_p w_p e_p_2 w_p_2 e_p_w_p e_p_Q e_p_K w_p_Q w_p_K, fe
              
              quietly generate double mono_KKKK = _b[K] + _b[K_2]*K + _b[K]*Q + _b[e_p_K]*e + _b[w_p_K]*w + (-_b[K_2] -_b[w_p_K] -_b[e_p_K])*p
              
              quietly generate double mono_eEEE = _b[e_p] + _b[e_p_2]*e_p + _b[e_p_Q]*Q + _b[e_p_K]*K + _b[e_p_w_p]*w + (-_b[e_p_2] -_b[e_p_w_p] -_b[e_p_K])*p
              
              quietly generate double mono_wWWW = _b[w_p] + _b[w_p_2]*w_p + _b[w_p_Q]*Q + _b[w_p_K]*K + _b[e_p_w_p]*e + (-_b[w_p_2] -_b[e_p_w_p] -_b[w_p_K])*p
              
              quietly generate double mono_QQQQ = _b[Q] + _b[Q_2]*Q + _b[Q]*K + _b[e_p_Q]*e + _b[w_p_Q]*w + (-_b[Q_2] -_b[w_p_Q] -_b[e_p_Q])*p
              
              quietly generate double mono_ppPP = 1 +(_b[w_p_2] + _b[e_p_2] + _b[K_2] + 2*_b[e_p_w_p] + 2*_b[w_p_K] + 2*_b[e_p_K])+ (-_b[e_p_2] -_b[e_p_w_p] -_b[e_p_K])*e + (-_b[K_2] -_b[w_p_K] -_b[e_p_K])*K + (-_b[Q_2] -_b[w_p_Q] -_b[e_p_Q])*Q
              
              summarize mono_KKKK mono_eEEE mono_wWWW mono_QQQQ mono_ppPP
              
              count if mono_KKKK <0
              
              count if mono_eEEE <0
              
              count if mono_wWWW <0
              
              count if mono_QQQQ <0
              
              count if mono_ppPP <0
              
              
              **Concavidade
              
              matrix C = (_b[K_2], _b[K_Q], _b[e_p_K], _b[w_p_K], (-_b[K_2] -_b[w_p_K] -_b[e_p_K])\ _b[K_Q], _b[Q_2], _b[e_p_Q], _b[w_p_Q], (-_b[Q_2] -_b[w_p_Q] -_b[e_p_Q])\_b[e_p_K], _b[e_p_Q], _b[e_p_2], _b[e_p_w_p], (-_b[e_p_2] -_b[e_p_w_p] -_b[e_p_K])\_b[w_p_K], _b[w_p_Q], _b[e_p_w_p], _b[w_p_2], (-_b[w_p_2] -_b[e_p_w_p] -_b[w_p_K])\(-_b[K_2] -_b[w_p_K] -_b[e_p_K]), (-_b[Q_2] -_b[w_p_Q] -_b[e_p_Q]), (-_b[e_p_2] -_b[e_p_w_p] -_b[e_p_K]), (-_b[w_p_2] -_b[e_p_w_p] -_b[w_p_K]), (_b[w_p_2] + _b[e_p_2] + _b[K_2] + 2*_b[e_p_w_p] + 2*_b[w_p_K] + 2*_b[e_p_K]))
              
              forvalues i = `N' {
              matrix S = (mono_KKKK[`i'], mono_eEEE[`i'], mono_wWWW[`i'], mono_QQQQ[`i'],mono_ppPP[`i'])'
              matrix A = C - diag(S) + S*S'
              matrix symeigen x v = A 
              scalar docheck = 1
              forvalues j = 1/5 { 
              if v[1,`j']>0.0001 & docheck ==1 {
              scalar violation = violation + 1
              scalar docheck = 0
               }
               }
               }
              
              display violation


              Attached Files

              Comment


              • #8
                forvalues i = `N' {
                matrix S = (mono_KKKK[`i'], mono_eEEE[`i'], mono_wWWW[`i'], mono_QQQQ[`i'],mono_ppPP[`i'])
                matrix A = C - diag(S) + S*S'
                matrix symeigen x v = A
                scalar docheck = 1
                forvalues j = 1/5 {
                if v[1,`j']>0.0001 & docheck ==1 {
                scalar violation = violation + 1
                scalar docheck = 0
                }
                }
                }
                display violation

                You have a number of problems with the last set of code:
                .
                1. The forval loop is not correct.

                2. I do not know why the mono_* variables have missing values, but the matrix "symeigen" cannot contain missing values. You have to figure this out and address it. For the sake of illustration, I will delete these missing values.

                3. You do not define a scalar "violation".

                Code:
                preserve
                egen Ce_mean = mean(despesa_exploracao)
                
                egen Ct_mean = mean(despesa_total)
                
                egen Q_mean = mean(volume_produzido_agua)
                
                egen K_mean = mean(extensao_rede)
                
                egen p_mean = mean(materiais)
                
                egen w_mean = mean(salario)
                
                egen e_mean = mean(energia)
                
                generate Ce_p = (log(despesa_exploracao) - log(Ce_mean))/(log(materiais) - log(p_mean))
                
                generate Ct_p = (log(despesa_total) - log(Ce_mean))/(log(materiais) - log(p_mean))
                
                generate Ce = log(despesa_exploracao) - log(Ce_mean)
                
                generate Ct = log(despesa_total) - log(Ce_mean)
                
                generate Q = log(volume_produzido_agua) - log(Q_mean)
                
                generate K = log(extensao_rede) - log(K_mean)
                
                generate Q_2 = 0.5*(Q)^2
                
                generate K_2 = 0.5*(K)^2
                
                generate K_Q = K*Q
                
                generate e = log(energia) - log(e_mean)
                
                generate p = log(materiais) - log(p_mean)
                
                generate w = log(salario) - log(w_mean)
                
                generate e_p = (log(energia) - log(e_mean))/(log(materiais) - log(p_mean))
                
                generate w_p = (log(salario) - log(w_mean))/(log(materiais) - log(p_mean))
                
                generate e_p_2 = 0.5*(e_p)^2
                
                generate w_p_2 = 0.5*(w_p)^2
                
                generate e_p_w_p = e_p*w_p
                
                generate e_p_Q = e_p*Q
                
                generate e_p_K = e_p*K
                
                generate w_p_Q = w_p*Q
                
                generate w_p_K = w_p*K
                
                
                xtset code_7 ano
                
                xtreg Ct_p price_cap_1 price_cap_2 cost_plus_1 cost_plus_2 cost_plus_3 Q K Q_2 K_2 K_Q e_p w_p e_p_2 w_p_2 e_p_w_p e_p_Q e_p_K w_p_Q w_p_K, fe
                
                quietly generate double mono_KKKK = _b[K] + _b[K_2]*K + _b[K]*Q + _b[e_p_K]*e + _b[w_p_K]*w + (-_b[K_2] -_b[w_p_K] -_b[e_p_K])*p
                
                quietly generate double mono_eEEE = _b[e_p] + _b[e_p_2]*e_p + _b[e_p_Q]*Q + _b[e_p_K]*K + _b[e_p_w_p]*w + (-_b[e_p_2] -_b[e_p_w_p] -_b[e_p_K])*p
                
                quietly generate double mono_wWWW = _b[w_p] + _b[w_p_2]*w_p + _b[w_p_Q]*Q + _b[w_p_K]*K + _b[e_p_w_p]*e + (-_b[w_p_2] -_b[e_p_w_p] -_b[w_p_K])*p
                
                quietly generate double mono_QQQQ = _b[Q] + _b[Q_2]*Q + _b[Q]*K + _b[e_p_Q]*e + _b[w_p_Q]*w + (-_b[Q_2] -_b[w_p_Q] -_b[e_p_Q])*p
                
                quietly generate double mono_ppPP = 1 +(_b[w_p_2] + _b[e_p_2] + _b[K_2] + 2*_b[e_p_w_p] + 2*_b[w_p_K] + 2*_b[e_p_K])+ (-_b[e_p_2] -_b[e_p_w_p] -_b[e_p_K])*e + (-_b[K_2] -_b[w_p_K] -_b[e_p_K])*K + (-_b[Q_2] -_b[w_p_Q] -_b[e_p_Q])*Q
                
                summarize mono_KKKK mono_eEEE mono_wWWW mono_QQQQ mono_ppPP
                
                count if mono_KKKK <0
                
                count if mono_eEEE <0
                
                count if mono_wWWW <0
                
                count if mono_QQQQ <0
                
                count if mono_ppPP <0
                
                egen missing= rowmiss(mono_*)
                
                keep if missing==0
                scalar violation =0
                
                forvalues i =1/ `=_N' {
                    matrix S = (mono_KKKK[`i'], mono_eEEE[`i'], mono_wWWW[`i'], mono_QQQQ[`i'],mono_ppPP[`i'])'
                    matrix A = C - diag(S) + S*S'
                    matrix symeigen x v = A
                    scalar docheck = 1
                    forvalues j = 1/5 {
                        if v[1,`j']>0.0001 & docheck ==1 {
                            scalar violation = violation + 1
                            scalar docheck = 0
                            }
                       }
                 }
                di violation
                Res.:

                Code:
                . forvalues i =1/ `=_N' {
                  2.     matrix S = (mono_KKKK[`i'], mono_eEEE[`i'], mono_wWWW[`i'], mono_QQQQ[`i'],mono_p
                > pPP[`i'])'
                  3.     matrix A = C - diag(S) + S*S'
                  4.     matrix symeigen x v = A
                  5.     scalar docheck = 1
                  6.     forvalues j = 1/5 {
                  7.         if v[1,`j']>0.0001 & docheck ==1 {
                  8.             scalar violation = violation + 1
                  9.             scalar docheck = 0
                 10.             }
                 11.        }
                 12.  }
                
                . di violation
                3152
                I advise you to patiently work through the codes in the book yourself, as I am unlikely to devote any more time on this. However, this does not preclude you from asking help from others in the forum.

                Comment


                • #9
                  No problem, Andrew Musau. You gave me a huge help here, thanks a lot.

                  Comment

                  Working...
                  X