-
Notifications
You must be signed in to change notification settings - Fork 0
/
MOMENT.fjg
67 lines (55 loc) · 1.62 KB
/
MOMENT.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
63
64
65
66
67
/*
Weighted MOMENT December/99 - R2: May/14
*/
COM [STRING] %%MOMENT = 'MOMENT - Version R2: May/14'
PROC MOMENT Y TBEGP TENDP
TYPE SERIES Y
LOCAL SERIES A S W P SMPL M
LOCAL REAL C D
LOCAL INTEGER TBEG TEND
OPTION SWITCH CENTER 1
OPTION SWITCH ABSOLUTE 0
OPTION SWITCH PRINT 1
OPTION SERIES SMPLL
OPTION SERIES WEIGHT
OPTION REAL ORDER 2.
* Globals
COM %%MOMENTR = %NA, %NOBS = 0
IF ORDER.LE.0
{
DIS %%MOMENT; DIS "Sintax Error: Exponent should be positive"
HALT MOMENT
}
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
INQ(SER=S) * %NOBS
COM C = %IF(CENTER==1,%M(S,W),0), D = %V(S,W)
IF ABSOLUTE
SET M 1 %NOBS = ABS(S - C)**ORDER
ELSE
SET M 1 %NOBS = (S - C)**ORDER
STA(NOPRINT,WEI=W) M 1 %NOBS
COM %%MOMENTR = %MEAN
IF PRINT
{
DIS 'Sample moment of order' #.* ORDER 'on Series' %L(Y) %IF(%DEFINED(WEIGHT),'weighted by '+%LABEL(WEIGHT),'')
IF ABSOLUTE
DIS 'Absolute moment'
IF CENTER
DIS 'Centered at mean value (' @-1 *.#### C @-1 ')'
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 'Sample moment ' %%MOMENTR @41 'Standarized' ABS(%%MOMENTR/(D**(ORDER/2)))
DIS
}
CLEAR A S W P SMPL M
END PROC MOMENT