Hi Gabriel Temesgen , and thanks, Chen Samulsion , for bringing this thread back up.
I ran the attached data and found two details in the do-file that explain much of what you are seeing.
First, teradial and teradialbc use outputs = inputs. If government spending is your input, gov_spd belongs on the right of the equals sign and the five development indicators belong on the left. I compared the two specifications using the same complete cases and a separate output-oriented VRS frontier for each year. Reversing the input and outputs changed 702 of the 744 country-year scores. On the 2020 cross-section, our DEA-Stata command and teradial agreed within 1e-6 on the uncorrected output expansion factors after putting them on the same scale.
Second, te() in your teradialbc call abbreviates tename(), which saves the original score. Use tebc() in that command to save its bias-corrected score. If you supply an external score to simarwilson as the dependent variable, you are using Algorithm 1. I reproduced the warning that tebc() is ignored in that case. The bias correction in teradialbc is a separate procedure. For Simar and Wilson's Algorithm 2, put the inputs and outputs inside simarwilson so the two bootstrap steps are carried out as part of that procedure.
Here is a self-contained do-file for the 2020 cross-section, tested in Stata 16.1. Download data.dta from Gabriel’s post #14 above and save the code as simarwilson_2020_portable.do in the same folder. In Stata, change to that folder and run do simarwilson_2020_portable.do. You can also pass the path to your copy of data.dta as the first argument. The default run uses the installed simarwilson and teradial commands and their platform-specific plug-in. On Apple Silicon, an r(199) also triggers a retry under Rosetta when the do-file and the Intel Stata executable can be found. The manual rosetta option is explained below.
In that run, 14 of the 31 countries had an uncorrected score of one, and none did after the Algorithm 2 correction. A score of one means that the observation lies on the estimated sample frontier. A score of 1.10 means the model estimates room for a 10% proportional expansion of all five outputs at the same input. For the second-stage regression on this scale, a positive coefficient shifts the location of the truncated distribution toward greater inefficiency. With your interaction, the sign of the association with human capital can depend on institutional quality.
A platform note for anyone who gets r(199): on my Apple Silicon Mac, Stata could find both ado-files, but the installed te_radial plug-in was built for Intel. The call completed in Intel Stata under Rosetta. If you encounter that combination, the optional branch lets you start from Apple Silicon Stata and bring the estimates and score variables back. From the folder containing the do-file, pass three arguments after its name in the do command: your data filename, rosetta, and the full path to your own Stata console executable in double quotes. The default command runs directly on Windows with a compatible plug-in. I tested the example on macOS.
I also checked that DEA-Stata's dea_sw2007 with backend(simarwilson) reproduced the direct simarwilson call on the same cross-section and seed in a separate, shorter run. The 2020 example shows how to run Algorithm 2 for one annual frontier. If you pool scores across years in a second-stage regression, the repeated observations for each country raise a separate inference question even with year indicators.
Badunenko and Tauchmann's Stata Journal article and command documentation
DEA-Stata
Best wishes,
Choonjoo
I ran the attached data and found two details in the do-file that explain much of what you are seeing.
First, teradial and teradialbc use outputs = inputs. If government spending is your input, gov_spd belongs on the right of the equals sign and the five development indicators belong on the left. I compared the two specifications using the same complete cases and a separate output-oriented VRS frontier for each year. Reversing the input and outputs changed 702 of the 744 country-year scores. On the 2020 cross-section, our DEA-Stata command and teradial agreed within 1e-6 on the uncorrected output expansion factors after putting them on the same scale.
Second, te() in your teradialbc call abbreviates tename(), which saves the original score. Use tebc() in that command to save its bias-corrected score. If you supply an external score to simarwilson as the dependent variable, you are using Algorithm 1. I reproduced the warning that tebc() is ignored in that case. The bias correction in teradialbc is a separate procedure. For Simar and Wilson's Algorithm 2, put the inputs and outputs inside simarwilson so the two bootstrap steps are carried out as part of that procedure.
Here is a self-contained do-file for the 2020 cross-section, tested in Stata 16.1. Download data.dta from Gabriel’s post #14 above and save the code as simarwilson_2020_portable.do in the same folder. In Stata, change to that folder and run do simarwilson_2020_portable.do. You can also pass the path to your copy of data.dta as the first argument. The default run uses the installed simarwilson and teradial commands and their platform-specific plug-in. On Apple Silicon, an r(199) also triggers a retry under Rosetta when the do-file and the Intel Stata executable can be found. The manual rosetta option is explained below.
Code:
version 16.1
set more off
* Default: run directly with data.dta in the current folder.
* Optional Mac workaround: pass data path, rosetta, and Intel Stata binary.
args datafile mode stata
if `"`datafile'"' == "" local datafile "data.dta"
if !inlist("`mode'", "", "rosetta", "intel-child") {
display as error "For direct execution, pass only the data path."
exit 198
}
capture confirm file "`datafile'"
if _rc {
display as error "Data file not found: `datafile'"
exit 601
}
if "`mode'" == "rosetta" {
if "`c(machine_type)'" != "Mac (Apple Silicon)" {
display as error "Use rosetta mode only from Apple Silicon Stata."
exit 198
}
if substr(`"`stata'"',1,1) != "/" {
display as error "Pass the full path to your Stata console executable."
exit 198
}
confirm file "`stata'"
local dofile "simarwilson_2020_portable.do"
capture confirm file "`dofile'"
if _rc {
display as error "Save `dofile' in the current Stata folder for rosetta mode."
exit 601
}
tempfile pointer
local pointer "`pointer'.sw2020-path"
tempname reader
quietly shell /usr/bin/mktemp -d /private/tmp/stata-sw2020.XXXXXXXX > "`pointer'"
capture file open `reader' using "`pointer'", read text
local open_rc = _rc
if `open_rc' == 0 {
file read `reader' work
file close `reader'
}
capture erase "`pointer'"
if strpos("`work'", "/private/tmp/stata-sw2020.") != 1 {
display as error "Could not create a temporary folder for Intel Stata."
exit 693
}
quietly copy "`datafile'" "`work'/input.dta"
quietly copy "`dofile'" "`work'/`dofile'"
tempname launcher
file open `launcher' using "`work'/stata.path", write text
file write `launcher' `"`macval(stata)'"' _n
file close `launcher'
file open `launcher' using "`work'/launch.sh", write text
file write `launcher' "IFS= read -r executable < stata.path || exit 1" _n
file write `launcher' "exec /usr/bin/arch -x86_64 " ///
(char(34)) (char(36)) "executable" (char(34)) " -b do `dofile' input.dta intel-child" _n
file close `launcher'
display as text "Running simarwilson in Intel Stata. Please wait for the bootstrap."
quietly shell cd "`work'" && /bin/sh ./launch.sh
capture confirm file "`work'/results.log"
if _rc == 0 type "`work'/results.log"
capture confirm file "`work'/scores.dta"
if _rc {
display as error "Intel Stata did not save results. Batch log: `work'/simarwilson_2020_portable.log"
exit 498
}
use "`work'/scores.dta", clear
estimates use "`work'/model.ster"
quietly estimates esample: year if year == 2020 & !missing(phi_bc_2020)
foreach file in launch.sh stata.path `dofile' input.dta scores.dta model.ster results.log simarwilson_2020_portable.log {
capture erase "`work'/`file'"
}
capture rmdir "`work'"
display as text "Estimates and score variables are now available in this Stata session."
exit
}
if "`mode'" == "intel-child" {
quietly log using "results.log", text replace name(sw2020)
}
which simarwilson
which teradial
use "`datafile'", clear
set seed 19023892
capture noisily simarwilson (lifeexp immun literacyrate enr_primar electricityaccess = gov_spd) ///
lnpercapita c.inst_qlty_ndex##c.hdindex debtgdp tradegdp ///
cpi_inf taxgdp nrgdp if year == 2020, ///
algorithm(2) base(output) rts(vrs) bcreps(100) reps(1000) ///
tename(phi_raw_2020) tebc(phi_bc_2020)
local sw_rc = _rc
if `sw_rc' {
if `sw_rc' == 199 & "`c(machine_type)'" == "Mac (Apple Silicon)" {
local install "`c(sysdir_stata)'"
if c(MP) {
local intel "`install'/StataMP.app/Contents/MacOS/stata-mp"
}
else if c(SE) {
local intel "`install'/StataSE.app/Contents/MacOS/stata-se"
}
else {
local intel "`install'/StataBE.app/Contents/MacOS/stata"
}
capture confirm file "`intel'"
local found = (_rc == 0)
capture confirm file "simarwilson_2020_portable.do"
if `found' & _rc == 0 {
display as text "The native call returned r(199). Retrying in Intel Stata under Rosetta."
do simarwilson_2020_portable.do "`datafile'" rosetta "`intel'"
exit
}
display as error "Check that the teradial plug-in supports Apple Silicon."
display as text "With an Intel-only plug-in, open Intel Stata or use the rosetta option."
display as text "Run the saved do-file from the folder containing it and data.dta."
}
exit `sw_rc'
}
summarize phi_raw_2020 phi_bc_2020
generate double radial_output_gap_pct = 100*(phi_raw_2020 - 1)
if "`mode'" == "intel-child" {
quietly estimates save "model.ster", replace
quietly save "scores.dta", replace
quietly log close sw2020
}
A platform note for anyone who gets r(199): on my Apple Silicon Mac, Stata could find both ado-files, but the installed te_radial plug-in was built for Intel. The call completed in Intel Stata under Rosetta. If you encounter that combination, the optional branch lets you start from Apple Silicon Stata and bring the estimates and score variables back. From the folder containing the do-file, pass three arguments after its name in the do command: your data filename, rosetta, and the full path to your own Stata console executable in double quotes. The default command runs directly on Windows with a compatible plug-in. I tested the example on macOS.
I also checked that DEA-Stata's dea_sw2007 with backend(simarwilson) reproduced the direct simarwilson call on the same cross-section and seed in a separate, shorter run. The 2020 example shows how to run Algorithm 2 for one annual frontier. If you pool scores across years in a second-stage regression, the repeated observations for each country raise a separate inference question even with year indicators.
Badunenko and Tauchmann's Stata Journal article and command documentation
DEA-Stata
Best wishes,
Choonjoo

Comment