Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Kolmogorov-Smirnov-Lilliefors Test statistics
Replies: 10   Last Post: Jun 8, 2013 7:39 PM

 Messages: [ Previous | Next ]
 Luis A. Afonso Posts: 4,758 From: LIsbon (Portugal) Registered: 2/16/05
Re: Kolmogorov-Smirnov-Lilliefors Test statistics
Posted: Jun 8, 2013 7:39 PM

Aim: To inspect how Jarque-Bera (LM, ALM) and Lilliefors tests in what concerns how well normal/ Gaussian Distributions can fit data.
___1___JB__
We found LM= 0.429,
5% significance critical value (1 tail) = 4.9757 (n=50)
_______ALM= 0.319__________crit= 6.5533 (n=50)
The conclusion is that data could be had drawn from a Normal Distribution.
___2___Lilliefors_____Dmax=0.51459, D2max=0.50929
5% critical value = 0.1256 (Molin, Abdi)
Final Conclusion:
As before JB test is unable to detect no normality even if it is indisputably present.

Luis A. Afonso
REM "JB-TIMBER"
CLS
DEFDBL A-Z
RANDOMIZE TIMER
PRINT : PRINT
PRINT "__________________________ JB-TIMBER "
n = 49
DIM x(n)
DEF fng (z, j) = -.5 * z * z * (2 * j + 1) / ((j + 1) * (2 * j + 3))
pi = 4 * ATN(1): c = 1 / SQR(2 * pi)
c1 = 6 * (n - 2) / ((n + 1) * (n + 3))
c2 = 3 * (n - 1) / (n + 1)
c3 = 24 * n * (n - 2) * (n - 3) / ((n + 1) ^ 2 * (n + 3) * (n + 5))
REM
DATA 2.50, 1.96, 1.58, .97, 1.60
DATA 1.37, 1.70, 1.78, 1.07, 1.63
DATA 1.57, 2.03, 2.02, .91, 1.68
DATA 1.29, 2.26, 2.22, 2.05, 1.34
DATA 1.64, 1.60, 1.51, 1.70, 1.56
DATA 1.37, 1.70, 2.59, 1.70, 1.91
DATA 2.07, 2.10, 1.93, 1.17, 1.86
DATA 2.11, 1.79, 1.36, 2.02, 1.44
DATA 1.00, 1.66, 2.31, 2.26, 2.37
DATA 1.72, 2.09, 1.36, 1.78
mean = 0: ss = 0
FOR i = 1 TO n: READ x(i)
mean = mean + x(i) / n
ss = ss + x(i) * x(i)
NEXT i
ssd = ss - n * mean * mean
var = ssd / (n - 1): sd = SQR(var)
PRINT : PRINT : PRINT : PRINT : PRINT
PRINT " ";
PRINT " mean, sdev. ";
PRINT USING "###.### "; mean; sd
REM
FOR i1 = 1 TO n: d = x(i1) - mean
m(2) = m(2) + d * d / n
m(3) = m(3) + d * d * d / n
m(4) = m(4) + d * d * d * d / n
NEXT i1
skw = m(3) / (m(2) ^ 1.5)
kurt = m(4) / (m(2) ^ 2)
REM
REM
alm = (skw ^ 2) / c1 + ((kurt - c2) ^ 2) / c3
REM
lmm = (skw ^ 2) / 6 + ((kurt - 3) ^ 2) / 24
lm = n * lmm
REM
REM
PRINT : PRINT : PRINT
COLOR 12
PRINT " LM= ";
PRINT USING "###.### "; lm;
PRINT " 4.9757 (n=50) "
PRINT " ALM= ";
PRINT USING "###.### "; alm;
PRINT " 6.5533 (n=50) "
END

REM "TIMBER"
CLS
DEFDBL A-Z
RANDOMIZE TIMER
PRINT : PRINT
PRINT "___________________ TIMBER "
n = 49
DIM x(n), xx(n), diff(n), F(n)
DEF fng (z, j) = -.5 * z * z * (2 * j + 1) / ((j + 1) * (2 * j + 3))
pi = 4 * ATN(1): c = 1 / SQR(2 * pi)
FOR h = 1 TO n: F(h) = h / n: NEXT h
REM
REM
DATA 2.50, 1.96, 1.58, .97, 1.60
DATA 1.37, 1.70, 1.78, 1.07, 1.63
DATA 1.57, 2.03, 2.02, .91, 1.68
DATA 1.29, 2.26, 2.22, 2.05, 1.34
DATA 1.64, 1.60, 1.51, 1.70, 1.56
DATA 1.37, 1.70, 2.59, 1.70, 1.91
DATA 2.07, 2.10, 1.93, 1.17, 1.86
DATA 2.11, 1.79, 1.36, 2.02, 1.44
DATA 1.00, 1.66, 2.31, 2.26, 2.37
DATA 1.72, 2.09, 1.36, 1.78
mean = 0: ss = 0
FOR i = 1 TO n: READ x(i)
x(i) = x(i) + (.5 - RND) / 100000
mean = mean + x(i) / 100
ss = ss + x(i) * x(i)
NEXT i
ssd = ss - n * mean * mean
var = ssd / (n - 1): sd = SQR(var)
PRINT : PRINT : PRINT : PRINT : PRINT
PRINT " ";
PRINT " mean, sdev. ";
PRINT USING "###.### "; mean; sd
FOR i = 1 TO n: x(i) = (x(i) - mean) / sd
xx(i) = x(i): NEXT i
PRINT
REM
mmajor = -1E+20: second = -1E+20
REM
md = 0: soma2 = 0
REM
REM ordered values: xx( )
REM
FOR ii = 1 TO n: u = x(ii): w = 1
FOR jj = 1 TO n
IF x(jj) < u THEN w = w + 1
NEXT jj: xx(w) = u
NEXT ii
REM
REM "*********************"
REM phi calculation

FOR tt = 1 TO n: z = xx(tt)
zu = ABS(z): s = c * zu: ante = c * zu
FOR j = 0 TO 4444444
xx = ante * fng(zu, j)
s = s + xx
ante = xx
IF ABS(xx) < .00000049# THEN GOTO 20
NEXT j
20 IF z >= 0 THEN FF = .5 + s
IF z < 0 THEN FF = .5 - s
b = ABS(FF - F(tt - 1))
bb = ABS(F(tt) - FF): REM F(tt=0)=0
major = b
IF bb > b THEN major = bb
diff(tt) = major
NEXT tt
REM local difference = diff(tt)
higher = -1
FOR ii = 1 TO n
IF diff(ii) <= higher THEN GOTO 22
higher = diff(ii): llocal = ii
22 NEXT ii
REM
REM
diff(llocal) = -2: high = -1
FOR i2 = 1 TO n
IF diff(i2) <= high THEN GOTO 33
high = diff(i2): i1 = i2
33 NEXT i2
LOCATE 14, 15
COLOR 14
PRINT " Dmax, D2max ";
PRINT USING " #.##### "; higher; high
COLOR 13
PRINT : PRINT " ";
PRINT " Dmax (5%significance) =0.1256 --> P.Molin & H. ABDI "
COLOR 7
END

Date Subject Author
9/16/12 Luis A. Afonso
9/18/12 Luis A. Afonso
9/20/12 Luis A. Afonso
9/20/12 Luis A. Afonso
9/22/12 Luis A. Afonso
9/22/12 Luis A. Afonso
6/4/13 Luis A. Afonso
6/5/13 Luis A. Afonso
6/5/13 Luis A. Afonso
6/7/13 Luis A. Afonso
6/8/13 Luis A. Afonso