-
Notifications
You must be signed in to change notification settings - Fork 0
/
THEIL.fjg
64 lines (53 loc) · 1.78 KB
/
THEIL.fjg
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
/*
THEIL INEQUALITY INDEX. March/96 - R6: March/07
*/
COM [STRING] %%THEIL = 'THEIL - Version R6: March/07'
PROC THEIL Y TBEGP TENDP OUTIND OUTINDSE
TYPE SER Y TBEGP TENDP
TYPE INTEGER TBEGP TENDP
TYPE REAL *OUTIND *OUTINDSE
*
LOCAL INTEGER TBEG TEND
LOCAL SERIES S W P SMPL
LOCAL REAL ATK
LOCAL VECTOR ATKSE
*
OPTION SWITCH PRINT 1
OPTION SWITCH SE 0
OPTION INTEGE REPLICAS 100
OPTION REAL BETA 0.
OPTION SERIES WEIGHT
OPTION SERIES SMPLL
INQUIRE(SERIES=Y) TBEG>>TBEGP TEND>>TENDP
IF %DEFINED(SMPLL)
SET SMPL TBEG TEND = %IF(SMPLL!=0.AND.%VALID(Y),1,0)
ELSE
SET SMPL TBEG TEND = %VALID(Y)
IF %DEFINED(WEIGHT)
SET P TBEG TEND = WEIGHT
ELSE
SET P TBEG TEND = 1
SAM(SMPL=SMPL) Y TBEG TEND S 1
SAM(SMPL=SMPL) P TBEG TEND W 1
IF SE; COM ATKSE = %THEIL_BOOTSE(S,W,REPLICAS,BETA)
* Globals
COM %MEAN = %NA, %NOBS = 0
INQ(SER=S) * %NOBS
COM ATK = %THEIL_INEQ(S,W,BETA), %MEAN = %M(S,W)
IF PRINT
{
DIS 'Theil Inequality index on Series' %L(Y) %IF(%DEFINED(WEIGHT),'weighted by '+%LABEL(WEIGHT),'')
DIS 'Observations' %NOBS @+5 '(' @-1 TEND-TBEG+1 'Total -' (TEND-TBEG+1)-%NOBS 'Skipped/Missing)'
DIS 'Sample period: From' %DATELABEL(TBEG) 'to' %DATELABEL(TEND)
DIS 'Inequality parameter' ###.## BETA
IF SE; DIS 'Bootstrap Standard Errors in brackets:' REPLICAS 'replications'
DIS 'Theil index ' ATK @41 'Welfare index' %MEAN*(1-ATK)
IF SE; DIS @21 #.##### '(' @-1 ATKSE(2) @-1 ')'
DIS 'Sample mean ' %MEAN
IF SE; DIS @15 '(' @-1 ATKSE(1) @-1 ')'
DIS;DIS
}
IF %DEFINED(OUTIND); COM OUTIND = ATK
IF %DEFINED(OUTINDSE); COM OUTINDSE = ATKSE(2)
CLE SMPL W S P
END PROC THEIL