-
Notifications
You must be signed in to change notification settings - Fork 7
/
DynUEI2.ado
106 lines (89 loc) · 2.42 KB
/
DynUEI2.ado
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
*! version 1.0.1 27Sep2014
capture program drop DynUEI2
program define DynUEI2
version 12.1
// syntax checking and validation-----------------------------------------------
// rts - return to scale, ort - orientation
// -----------------------------------------------------------------------------
// returns 1 if the first nonblank character of local macro `0' is a comma,
// or if `0' is empty.
if replay() {
dis as err "ivars and ovars must be inputed."
exit 198
}
// get and check invarnames
gettoken word 0 : 0, parse(" =:,")
while `"`word'"' != ":" & `"`word'"' != "=" {
if `"`word'"' == "," | `"`word'"'=="" {
error 198
}
local invars `invars' `word'
gettoken word 0 : 0, parse("=:,")
}
unab invars : `invars'
gettoken word 0 : 0, parse(" =:,")
while `"`word'"' != ":" & `"`word'"' != "=" {
if `"`word'"' == "," | `"`word'"'=="" {
error 198
}
local gopvars `gopvars' `word'
gettoken word 0 : 0, parse(" =:,")
}
unab gopvars : `gopvars'
syntax varlist(min=1),dmu(varname) time(varname) gind(varname)
set matsize 2000
set more off
disp("computing...")
disp("Pls wait... ...")
foreach j in UEIg UEIi UEIc EC BPC TGC MMUEI {
cap drop `j'
}
local bopvars "`varlist'"
local ninp: word count `invars'
local ngo: word count `gopvars'
local nbo: word count `bopvars'
local nout=`ngo'+`nbo'
disp("########################")
qui UEIg2 `invars'=`gopvars':`bopvars'
rename UEIg1 UEIg
tempvar gg
qui egen `gg'=group(`gind')
qui su `gg'
local gN=r(max)
disp("$$$$$$$$$$$$$$$$$$$$$$$$$")
forvalues i=1/`gN' {
preserve
qui keep if `gg'==`i'
qui UEIg `invars' = `gopvars' : `bopvars'
rename UEIg1 UEIi
*cap drop betaK1 betaL1 betaE1 betaY1 betaC1
qui UEI `invars' = `gopvars' : `bopvars', dmu(`dmu') time(`time')
rename UEI1 UEIc
if `i'==1 {
qui save tcp1,replace
}
else {
qui append using tcp1
qui save tcp1,replace
}
restore
}
qui {
merge 1:1 `dmu' `time' using tcp1
drop _merge
erase tcp1.dta
}
disp("xxxxxxxxxxxxxxxxxxxxxxxxx")
qui {
tempvar CUEIt
sort `dmu' `time'
bys `dmu' : gen MMUEI=UEIg/UEIg[_n-1]
bys `dmu' : gen `CUEIt'=UEIi/UEIi[_n-1]
bys `dmu': gen EC=UEIc/UEIc[_n-1]
gen BPC=`CUEIt'/EC
gen TGC=MMUEI/`CUEIt'
}
disp("Computation is completed!")
disp("Results are reported in the dataset.")
disp("Enjoy it!")
end