Announcement

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

  • Replication: qreg gives very different results to authors' program

    Hi everyone, I'm new to this forum, so if there is any issue with my post, please feel free to let me know!

    I am doing a replication exercise for this paper, "Estimating the Impact of Microcredit on Those Who Take It Up: Evidence from a Randomized Experiment in Morocco" (https://www.aeaweb.org/articles?id=10.1257/app.20130535) - data and the replication package is available here: https://www.openicpsr.org/openicpsr/...ersion/V1/view.

    To replicate figure 1 in the paper, I ran qreg2 as follows:

    Code:
    set maxiter 16000
    xi: qreg2 profit_total treatment $householdcontrols $respondentcontrols i.paire if samplemodel == 1, quantile(.9) cluster(demi_paire)
    But the results I got are quite different from the results in the paper - the authors wrote their own program for the quantile treatment effect regression.
    Click image for larger version

Name:	qreg.PNG
Views:	1
Size:	9.6 KB
ID:	1730964



    The authors' program for quantile treatment effect regression:

    Code:
    tab1 paire,gen(p)
    
    capture program drop NewregqM
    prog def NewregqM, rclass
    args var
    clear matrix
    sca drop _all
    local sca var Varb Varbs n
    count if treatment==1
    sca ntot1=r(N)
    count if treatment==0
    sca ntot0=r(N)
    matrix T=J(81,1,1)#(0\1)
    matrix P=I(81)#J(2,1,1)
    matrix X=(T,P)
    matrix Isig=J(162,162,0)
    foreach i of numlist 1 2 3 4 5 {
            matrix Sig`i'=J(162,162,0)
            }
    matrix  q_0=J(5,1,0)
    matrix  q_1=J(5,1,0)
    foreach nump of numlist 1/81 {
            foreach val of numlist 0 1 {
                    quietly centile `var' if p`nump'==1 & treatment==`val',centile(10 25 50 75 90) level(95)
                    sca n`val'=r(N)
                    matrix q_`val'=q_`val'+n`val'*(r(c_1)\r(c_2)\r(c_3)\r(c_4)\r(c_5))/ntot`val'
                    foreach i of numlist 1 2 3 4 5 {
                            matrix Isig[(`nump'-1)*2+`val'+1,(`nump'-1)*2+`val'+1]=n`val'
                            matrix theta`i'=nullmat(theta`i')\r(c_`i')
                            sca var`i'=((r(ub_`i')-r(lb_`i'))/(invnormal((1+.95)/2)-invnormal((1-.95)/2) ))
                            matrix Vecvar`i'=nullmat(Vecvar`i')\var`i'
                            matrix Sig`i'[(`nump'-1)*2+`val'+1,(`nump'-1)*2+`val'+1]=var`i'
                            }
                    }
            }
    
    foreach i of numlist 1 2 3 4 5 {
            matrix b=invsym(X'*Isig*X)*X'*Isig*theta`i'
            matrix b1=b[1,1]
            disp `i'
            matrix list b1
            matrix uhat=theta`i'-X*b
    
            matrix uhat2=hadamard(uhat,uhat)
            matrix uhatres=uhat2-Vecvar`i'
            matrix RegT=(J(162,1,1),T)
            matrix Sig01=invsym(RegT'*RegT)*RegT'*uhatres
            matrix Dsig01=J(2,2,0)
            matrix Dsig01[1,1]=Sig01[1,1]
            matrix Dsig01[2,2]=Sig01[1,1]+Sig01[2,1]
            matrix Sig2=Sig`i'+I(81)#Dsig01
            matrix Isig2=invsym(Sig2)
    
            matrix Sig3=J(162,162,0)
            foreach nump of numlist 1/81 {
            
                    foreach val of numlist 0 1 {
                            matrix Sig3[(`nump'-1)*2+`val'+1,(`nump'-1)*2+`val'+1]=uhat2[(`nump'-1)*2+`val'+1,1]
                            }
                    }
    
    
            matrix b2=invsym(X'*Isig2*X)*X'*Isig2*theta`i'
            matrix Varb2R=invsym(X'*Isig2*X)*X'*Isig2*Sig3*Isig2*X*invsym(X'*Isig2*X)
            sca b2=b2[1,1]
            sca Varb2R=Varb2R[1,1]
            sca sb2R=sqrt(Varb2R)
            matrix res=nullmat(res)\(b2,sb2R,b2/sb2R,2*(1-normal(abs(b2/sb2R))))
            }
    matrix res=((10\25\50\75\90),(res,q_0,((res[1,1]/q_0[1,1])\(res[2,1]/q_0[2,1])\(res[3,1]/q_0[3,1])\(res[4,1]/q_0[4,1])\(res[5,1]/q_0[5,1]))))
    
    
    end
      
    gen id=.
    gen vars=""
    gen N=.
    gen n_surveyed=.
    gen mean_surveyed=.
    
    
    gen coef10=.
    gen coef25=.
    gen coef50=.
    gen coef75=.
    gen coef90=.
    
    gen se10=.
    gen se25=.
    gen se50=.
    gen se75=.
    gen se90=.
    
    global variables_quantile profit_total assets_total consumption income income_dep
    Below is a data extract of the variables used in the regression:


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(profit_total treatment paire)
       6200 1 10
          0 0 66
          0 0 66
          0 0 66
       -151 1 19
          0 0 66
          0 0 66
          0 0 66
       3580 0 66
          0 0 66
      19200 0 66
          0 1 32
          0 0 10
      -1200 1 32
      21940 0 66
          0 0 66
          0 0 66
          0 1 13
      -2240 0 66
          0 0 66
          0 0 66
       4800 1 32
          0 0 66
          0 0 66
      -2100 0 76
          0 0 66
       2482 1  9
      21478 0 66
          0 0 66
          0 0 66
          0 0 66
          0 0 66
          0 0 10
        680 1 19
          0 0 32
          0 1 80
      79920 0 66
          0 0 66
       8560 1 80
       1590 0 66
          0 0 66
     -30040 0 32
          0 0 10
          0 0 10
     -17007 1 80
          0 1 66
          0 1 66
          0 1 66
          0 1 66
    14135.5 1 80
       3880 1 66
     -12600 0 32
          0 1 66
       1550 1 66
          0 0 32
        300 1 66
       3480 1 66
          0 1 66
       2400 0 32
          0 1 66
          0 1 66
          0 1 31
          0 1 66
     1227.5 0 13
          0 1 31
          0 1 31
          0 1 31
          0 1 66
          0 1 31
          0 1 31
          0 1 66
          0 1 31
          0 1 31
          0 1 31
          0 1 31
      -4900 1 31
          0 1 66
          0 1 31
        250 1 31
      -2490 1 31
          0 1 31
          0 1 31
       -428 1 31
        955 1 31
       2300 1 31
      84000 1 66
          0 1 66
      48024 0 76
          0 1 66
      21400 0 31
          0 1 66
      -1880 0 31
          0 1 66
        -80 0 31
          0 1 66
          0 1 66
       -100 0 31
      -2550 0 31
       1000 0 31
       2000 0 31
    end
    Household control variables:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(members_resid_bl nadults_resid_bl head_age_bl act_livestock_bl act_business_bl borrowed_total_bl members_resid_d_bl nadults_resid_d_bl head_age_d_bl act_livestock_d_bl act_business_d_bl borrowed_total_d_bl)
     7  2 75 1 0 0 0 0 0 0 0 0
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     6  4 52 1 0 1 0 0 0 0 0 0
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     6  4 60 1 0 0 0 0 0 0 0 0
     2  2 27 1 0 0 0 0 0 0 0 0
     6  4 49 1 0 0 0 0 0 0 0 0
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     7  5 80 1 1 0 0 0 0 0 0 0
     0  0  0 0 0 0 1 1 1 1 1 1
     1  1 22 1 0 1 0 0 0 0 0 0
     7  2 40 0 0 1 0 0 0 0 0 0
     3  2 34 0 0 0 0 0 0 0 0 0
     7  6 45 0 0 1 0 0 0 0 0 0
     3  2 59 0 1 0 0 0 0 0 0 0
     6  4 55 0 0 0 0 0 0 0 0 0
     3  2 23 0 0 1 0 0 0 0 0 0
     0  0  0 0 0 0 1 1 1 1 1 1
     3  2 28 0 1 1 0 0 0 0 0 0
     5  2 43 0 0 1 0 0 0 0 0 0
     5  2 25 0 0 0 0 0 0 0 0 0
     6  2 38 0 0 1 0 0 0 0 0 0
     3  2 37 0 0 0 0 0 0 0 0 0
     1  1 40 0 0 0 0 0 0 0 0 0
     6  5 45 1 0 1 0 0 0 0 0 0
     5  2  1 0 1 0 0 0 0 0 0 0
     1  1 70 0 0 1 0 0 0 0 0 0
     4  2 37 0 1 1 0 0 0 0 0 0
     6  2 35 0 0 1 0 0 0 0 0 0
     1  1 75 1 0 1 0 0 0 0 0 0
     9  5 55 0 0 1 0 0 0 0 0 0
     7  4 45 0 0 1 0 0 0 0 0 0
    11  9 47 1 1 0 0 0 0 0 0 0
    10  7 62 1 0 1 0 0 0 0 0 0
     7  7 47 0 1 0 0 0 0 0 0 0
     1  1 43 1 0 1 0 0 0 0 0 0
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     1  1 45 1 0 1 0 0 0 0 0 0
     0  0  0 0 0 0 1 1 1 1 1 1
     6  2 38 0 1 0 0 0 0 0 0 0
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     2  2 66 1 0 0 0 0 0 0 0 0
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     3  2 30 0 1 0 0 0 0 0 0 0
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     0  0  0 0 0 0 1 1 1 1 1 1
     3  2 24 0 1 0 0 0 0 0 0 0
     0  0  0 0 0 0 1 1 1 1 1 1
     7  6 50 1 0 1 0 0 0 0 0 0
     0  0  0 0 0 0 1 1 1 1 1 1
     7  2 38 0 0 1 0 0 0 0 0 0
     5  5 77 0 0 1 0 0 0 0 0 0
     7  3 40 0 0 1 0 0 0 0 0 0
     5  3 45 0 0 0 0 0 0 0 0 0
     5  2 44 1 0 1 0 0 0 0 0 0
     6  4 60 0 0 1 0 0 0 0 0 0
     8  6 29 1 0 0 0 0 0 0 0 0
    11 10 57 0 0 1 0 0 0 0 0 0
     7  4 44 0 0 1 0 0 0 0 0 0
    end
    Respondent control variables:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(ccm_resp_activ other_resp_activ ccm_resp_activ_d other_resp_activ_d)
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    1 0 0 0
    0 0 0 0
    0 0 1 1
    0 0 0 0
    0 0 1 1
    0 0 1 1
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    1 0 0 0
    1 0 0 0
    0 1 0 0
    0 0 1 1
    0 0 0 0
    0 0 0 0
    0 0 1 1
    0 0 0 0
    1 0 0 0
    0 0 1 1
    0 0 0 0
    1 0 0 0
    0 0 1 1
    0 0 1 1
    0 0 1 1
    0 0 1 1
    0 0 0 0
    1 0 0 0
    0 0 0 0
    0 0 1 1
    0 0 0 0
    0 0 1 1
    0 0 1 1
    0 0 0 0
    0 0 1 1
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 1 1
    1 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 1 1
    0 0 1 1
    0 0 0 0
    0 0 0 0
    0 1 0 0
    0 1 0 0
    0 0 0 0
    1 0 0 0
    0 0 1 1
    0 0 0 0
    0 0 1 1
    0 0 0 0
    0 0 0 0
    0 0 1 1
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 1 1
    0 1 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 1 1
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 1 1
    0 0 0 0
    0 0 1 1
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 1 1
    0 0 0 0
    0 0 0 0
    0 0 1 1
    0 0 0 0
    0 1 0 0
    0 0 0 0
    1 0 0 0
    end
    Thank you very much for your help.
Working...
X