Hello guys!

I am currently working with decomposition of concentration index by employing a Recentered Influence Function (RIF) with bootstrapped standard errors developed by Heckley, Gerdtham & Kjellson (2016) see the link; https://www.sciencedirect.com/scienc...67629616300066.

I have written a program by modifying the Stata codes provided by Heckley to conduct the decomposition using the Household Surveys from four sub Saharah Africa. However, when I estimate the Bootstrap RIFdecompl program for standard OLS RIF regressions, STATA gives me an error message " invalid syntax an error occurred when bootstrap executed RIFdecompI" r(198);. STATA also gives me another error message " last estimates not found" when I type ereturn displayon thecommand window after running a program from the do file.

Can someone please help me understand why I get this error or possible mistakes that I have made in the codes I have attached.


Code:
// This code provides RIF-I-OLS estimates with bootstrap standard errors for:
// The absolute concentration index (AC)
// The Concentration index (CI)
// The Erreygers index (EI)
// The Wagstaff Index (WI)
// the Attainment relative index (AR)
// the shortfall relative index (SR)

// Administrative commands
clear all
set more off
// read in dataset
use "C:\Users\Documents\DATA\2008_E.dta"
// set area
cd "/Users/Documents/DATA/"

///// set-up: macros
/// health variable
global h haz06
/// Socioeconomic ranking variable
global y expm

/// Explantory variables
global x Age Sex foodOUT


// Set the (theoretical) bounds for bounded health variables
*lower bound
sca ah=0
*upper bound
sca bh=1


// The following is the program "RIFdecompI" which allows estimation RIF-I-OLS with parametric bootstrapped standard errors //

****************************
/* RIF program - RIFdecompI */
capture program drop RIFdecompI
program define RIFdecompI, eclass
version 13.0

        quiet {
        local weightexp ""
// set up temporary variables
        tempvar eweight incsort har hsr cum_wt cumwh glp pvar b2 c2 if_AC rif_AC if_E rif_E if_W_CI if_C rif_C if_W_CAR if_CAR rif_CAR if_W_CSR if_CSR rif_CSR Z2 Z3 if_W_WI W_a W_b if_W rif_W
        gen `eweight' = 1.0

// rank data according to the socioeconomic variable ensuring no missing values in ranking variable are used
        gen `incsort'=0
        replace `incsort'=1 if $y==.
        sort  `incsort' $y

// generate empirical function estimates
        sum $h if $touse
        sca tot_wt=r(sum_w)                         /*sample size scalar*/
        sca hbar= r(mean)                             /*sample mean of y scalar*/
        gen `har'=$h-ah if $touse                     /*generate attainment relative mean*/
        sum `har'        
        sca harbar=r(mean)                             /* attainment relative mean of y scalar*/
        gen `hsr'=bh-$h if $touse                     /* generate shortfall mean of y scalar*/
        sum `hsr'        
        sca hsrbar=r(mean)                             /* shortfall relative mean of y scalar*/
        sca twovm=2/hbar  
        sca W_EI=4/(bh-ah)                             /* Erreygers index weighting function */
        sca W_CI=1/hbar                             /* concentration index weighting function */
        sca W_CAR = 1/harbar                        /* attainment relative concentration index weighting function */
        sca W_CSR = 1/hsrbar                        /* shortfall relative concentration index weighting function */
        sca W_WI=(bh-ah)/((bh-hbar)*(hbar-ah))         /* Wagstaff index weighting function */
        gen `cum_wt' = sum(`eweight') if $touse      /* sample weighted rank */
        gen double `cumwh' = sum($h) if $touse         /* cumulative health */
// generalised lorenz co-ordinate
        gen double `glp'=`cumwh'/tot_wt if $touse                                    
// fractional rank of individual i
        gen double `pvar' = `cum_wt'/tot_wt  if $touse                                

///// define the IF and RIF functions for the common forms of I /////
// if-AC
        corr `pvar' $h if $touse , cov                /* calculate covariance of rank and health */
        sca cov_H    =r(cov_12)                         /* Store covariance */
        sca AC1        =2*cov_H                        /* Absolute concentration index is 2*covariance(health,rank) */
        gen `b2'    =-$h+hbar if $touse
        gen `c2'    =2*($h*(`pvar')-`glp') if $touse
        gen `if_AC'    =-2*AC1 + `b2' + `c2' if $touse /* IF for AC = 2*AC + b2 + c2 */
// rif-AC
        gen `rif_AC' = AC1 + `if_AC' if $touse         /* RIF of AC = IF(AC)+AC */

// if-E
        sca EI         = W_EI*AC1                        /* Erreygers index = reweighted AC */
        gen `if_E'     = W_EI*`if_AC' if $touse
// rif-E
        gen `rif_E' = W_EI*`rif_AC' if $touse        /* RIF of EI = IF(EI)+EI */

// if-C
        sca C1         = W_CI*AC1                                    /* Concentration index = reweighted AC */
        gen `if_W_CI'    =(hbar-$h)/(hbar^2) if $touse            /*IF for concentration index weighting function */
        gen `if_C'    =`if_W_CI'*AC1 + W_CI*`if_AC' if $touse        /* IF for concentration index */
// rif-C
        gen `rif_C'    =`if_C'+C1                                    /* RIF of CI = IF(CI)+CI */

// if-AR
        sca CAR     = W_CAR*AC1                                    /* Attainment relative Concentration index = reweighted AC */
        gen `if_W_CAR'    =-(`har'-harbar)/(harbar^2) if $touse    /* IF for Attainment relative Concentration index weighting function */
        gen `if_CAR'=`if_W_CAR'*AC1 + W_CAR*`if_AC' if $touse    /* IF for Attainment relative Concentration index */
// rif-AR
        gen `rif_CAR'=`if_CAR'+CAR                                /* RIF of attainment relative CI = IF(CAR)+CAR */

// if-SR
        sca CSR     = W_CSR*AC1                                    /* Shortfall relative Concentration index = reweighted AC */
        gen `if_W_CSR'    =-(`hsr'-hsrbar)/(hsrbar^2) if $touse    /* IF for Shortfall relative Concentration index weighting function */
        gen `if_CSR'=`if_W_CSR'*AC1 + W_CSR*`if_AC' if $touse    /* IF for Shortfall relative Concentration index */
// rif-SR
        gen `rif_CSR'=`if_CSR'+CSR                                /* RIF of Shortfall relative CI = IF(CSR)+CSR */

// if-w
        sca WI2     = W_WI*AC1                                    /* Wagstaff index = reweighted AC */
        gen `Z2'     = ((bh+ah-2*hbar)*($h - hbar)) if $touse
        gen `Z3'    = ((bh-hbar)*(hbar-ah)) if $touse
        gen `if_W_WI' = (-(bh-ah)*`Z2')/(`Z3'*`Z3') if $touse    /* IF for Wagstaff index weighting function */
        gen `W_a'     = `if_W_WI'*AC1 if $touse
        gen `W_b'     = `if_AC'*W_WI if $touse
        gen `if_W'     = `W_a' + `W_b' if $touse                    /* IF for Wagstaff index */
// rif-W
        gen `rif_W' = `if_W'+ WI2 if $touse                        /* RIF of Wagstaff index = IF(WI)+WI */
}

tempname Eb

// Choose which index to decompose by removing the corresponding * and running the RIFdecompI program  //

xi: reg `rif_AC'     $x if $touse
*xi: reg `rif_E'     $x if $touse
*xi: reg `rif_C'      $x if $touse
*xi: reg `rif_CAR'     $x if $touse
*xi: reg `rif_CSR'     $x if $touse
*xi: reg `rif_W'     $x if $touse

*xi: xtreg `rif_AC'     $x if $touse, fe
*xi: xtreg `rif_E'         $x if $touse, fe
*xi: xtreg `rif_C'         $x if $touse, fe
*xi: xtreg `rif_CAR'     $x if $touse, fe
*xi: xtreg `rif_CSR'     $x if $touse, fe
*xi: xtreg `rif_W'         $x if $touse, fe
matrix `Eb'=e(b)
ereturn post `Eb'
ereturn local cmd="bootstrap"

end


// Bootstrap RIFdecompI program for standard OLS RIF regressions
bootstrap _b, reps(999) seed(12345) : RIFdecompI

// Bootstrap RIFdecompI program for Withing Twin pair RIF regressions
xi: bootstrap _b, reps(1000) seed(12345)  : RIFdecompI
outreg2 using CI_EQ5D_decomp, word dec(3)