-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBWIDTH.fjg
53 lines (45 loc) · 1.8 KB
/
BWIDTH.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
/*
BWIDTH May/00 - R2: May/14
*/
COM [STRING] %%BWIDTH = 'BWIDTH - Version R2: May/14'
PROC BWIDTH S TBEGP TENDP H
TYPE SERIES S
TYPE REAL *H
*
LOCAL INTEGER N TBEG TEND
LOCAL REAL V IQ
LOCAL SERIES W SMPL
*
OPTION SWITCH INTERPOL 1
OPTION SWITCH SILVERMAN 1
OPTION CHOICE SPREAD 3 SIGMA IQR ROBUST
OPTION CHOICE KERNEL 5 EPANECHNIKOV BIWEIGHT 3WEIGHT TRIANGULAR GAUSSIAN RECTANGULAR
OPTION SERIES WEIGHT
OPTION SERIES SMPLL
INQUIRE(SERIES=S) TBEG>>TBEGP TEND>>TENDP
IF %DEFINED(SMPLL)
SET SMPL TBEG TEND = %IF((SMPLL.NE.0).AND.(%VALID(S)),1,0)
ELSE
SET SMPL TBEG TEND = %VALID(S)
IF %DEFINED(WEIGHT)
SET W TBEG TEND = WEIGHT
ELSE
SET W TBEG TEND = 1
@MEANVAR(SMPL=SMPL,NOPRI,WEI=W) S TBEG TEND
COM V = %VARIANCE, N = %NOBS
IF %DEFINED(WEIGHT)
@IQR(Q=.25,SMPL=SMPL,INT=INTERPOL,WEI=W,NOPRI) S TBEG TEND IQ
ELSE
@IQR(Q=.25,SMPL=SMPL,INT=INTERPOL,NOPRI) S TBEG TEND IQ
COM IQ = IQ/(%INVNORMAL(.75)-%INVNORMAL(.25))
IF SPREAD.EQ.1; COM H = SQRT(V) *N**(-.2)
ELSE IF SPREAD.EQ.2; COM H = IQ *N**(-.2)
ELSE; COM H = %MIN(SQRT(V),IQ)*N**(-.2)
IF KERNEL.EQ.1; COM H = ( 40*SQRT(%PI) )**.2 *H ;* EPANECHNIKOV
ELSE IF KERNEL.EQ.2; COM H = ( 280*SQRT(%PI)/ 3 )**.2 *H ;* BIWEIGHT
ELSE IF KERNEL.EQ.3; COM H = (25200*SQRT(%PI)/143 )**.2 *H ;* 3WEIGHT
ELSE IF KERNEL.EQ.4; COM H = ( 64*SQRT(%PI) )**.2 *H ;* TRIANGULAR
ELSE IF KERNEL.EQ.5; COM H = %IF(SILVERMAN.EQ.1,.9,(4./3)**.2)*H ;* GAUSSIAN
ELSE; COM H = ( 12*SQRT(%PI) )**.2 *H ;* RECTANGULAR
CLEAR W SMPL
END PROC BWIDTH