Συμπερασματολογίακαιεπιλογήμεταβλητών...

97
Συμπερασματολογία και επιλογή μεταβλητών για μοντέλα ποσοστημοριακής παλινδρόμησης Πανεπιστήμιο Αθηνών Τμήμα Μαθηματικών Μεταπτυχιακό Στατιστικής και Επιχειρησιακής ΄Ερευνας Διπλωματική Εργασία Χαράλαμπος Χανιαλίδης Οκτώβριος 2010

Transcript of Συμπερασματολογίακαιεπιλογήμεταβλητών...

  • 2010

  • xi

    xiii

    1 11.1 . . . . . . . . . . . . . . 21.2 . . . . . . . . . . . 31.3 . . . 6

    2 92.1 . . . . . . . . . 92.2 . . . . . . . . . . . . . . . . . . 102.3 . . . . . . . . . . . . . . . . . . 112.4 142.5 . . . . . . . . . . . 18

    3 213.1 . . . . . . . . . . . . . . . . . . . . . 223.2 . . . . . . . . . . . . . . . . 233.3 . . . . . . . . 263.4 . . . . . 273.5 . . . . . . . 293.6 Bootstrap . . . 313.7 . . . . . . . . . . . . . . . . . . 333.8 . . . . . . . . . . . . . . . . . . . . . . 353.9 . . . . . . . . . . . . 363.10 . . . . . . . . . . . . . . 373.11 . . . . 383.12 Markov chain Monte Carlo . . . . . . . . . . . . . . 39

    3.12.1 Gibbs . . . . . . . . . . . . . . . . . . . . 403.12.2 Metropolis-Hastings . . . . . . . . . . . . 41

    iii

  • 4 - 454.1 -

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464.2 -

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494.3 -

    . . . . . . . . . . . . . . . . . . . . . . . 524.4 -

    . . . . . . . . . . . . . . . . . . . . . . . . . 53

    5 575.1 Akaike Information Criterion . . . . . . . . . . . . . . . . . . . 585.2 Bayesian Information Criterion . . . . . . . . . . . . . . . . . 595.3 Likelihood ratio test . . . . . . . . . . . . . . . . . . . . . . . 60

    6 636.1 . . . . . . . . . . . . . . . . . . . . . . . 646.2 . . 676.3 -

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 676.4 -

    . . . . . . . . . . . . . . . . . . . . . . . . 68

    Matlab 75.1 Matlab . . . . . . 75.2 Matlab . . . . . . . . . . . 75.3 Matlab . . . . . . . 78

  • 1.1 . . . . . . . . . . . . . . . 51.2 459 ( )

    . . . . . . . . . . . . . . . . . . . 7

    2.1 - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    2.2 Engel , 235 - . . . . . . . . . . . . . . . . . . . . . . . . 17

    3.1 . . . . . . 263.2 15% 4%

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

    v

  • 2.1 - . . . . . . . . . . . . . . . . . . . . . 12

    3.1 - . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    6.1 . 666.2 . . 706.3 -

    : . . . . . . . . . . . . . . . . . . . . . . . . . . 716.4 -

    : . . . . . . . . . . . . . . . . . . . . . . . . . . 726.5 -

    : . . . . . . . . . . . . . . . . . . . . . . . . . . 736.6 -

    : . . . . . . . . . . . . . . . . . . . . . . . . . . 74

  • .

  • . - , - . , (-, , ).

    . , ( ) : ( ) . , - . , , - , .,

    . , - AIC BIC, - .

    xi

  • - , . , , . ( ) . .,

    . , . email . . . .,

    , , , .

    xiii

  • 1

    There are three kinds of lies:lies, damned lies, and statistics.

    Benjamin Disraeli

    (regression analysis) (Y ) (X) (Xi i = 1, . . . , n). H Y (response variable) Xi (cova-riates).

    - , ; Y Xi (linear regression). . . - , -.

    1

  • 1.

    .

    (simple linear regression) , - (multiple linear regression). - .

    1.1

    n -. . {Yi, Xi1, . . . , Xik}, i = 1, . . . , n, n k . -

    yi = 0 + 1xi1 + . . .+ kxik + i, i = 1, . . . , n,

    0 - 0 1, . . . , n - Y , (.. 4 - Y X4 ). i ( ) . - . E(i) = 0, . - ( i i = 1, . . . , n).

    E(ij) =

    {

    2 i = j0 i 6= j

    -

    E(Y |X) = 0 + 1X1 + . . .+ kXk.

    2

  • 1.2.

    0, 1, . . . , k, (. ). . ,

    (.. yi = 0 + 1xi1 + 2x2i2 + . . . + nxik + i yi = 0 + 1xi1 + 22xi2 + . . .+ nxik + i)., . , , 1 X1 Y - , . - .

    yi = 0 + 1xi1 + . . .+ kxik + i i = 1, . . . , n.

    .

    Y =

    y1y2...yn

    , X =

    1 x11 . . . x1k1 x21 . . . x2k......

    ......

    1 xn1 . . . xnk

    , =

    01...k

    , =

    12...n

    Y = X + ,

    E() = 0 V () = 2I 2 I n n.

    1.2 -

    , - . (ordinary least squares) .1

    1 -(weighted least squares) .

    3

  • 1.

    - . 0, 1, . . . , k - Y ( ) . - i . ,

    =

    012...n

    ,

    Y = X

    i = Y X,

    Yi (fitted value) Yi - (observed value).

    1.1 - Y . (Yi, Xi)

    , Y = X (. Yi ). - , i = Yi Yi. , 0 ( ), .

    4

  • 1.2.

    Y

    X

    Yi

    Yi

    ii

    Yi

    Yi

    1.1:

    i2 = = (Y X)(Y X)= Y Y X Y Y X + X X= Y Y 2 X Y + X X.

    (Y Y 2 X Y + X X)

    = 0.

    X X = X Y

    X X ,

    = (X X)1X Y.

    E() = V () = 2(X X)1 .

    .

    5

  • 1.

    X X -, -. - Y . ( X X |(X X)| = 0) . - , , .

    (...) - (quadrative loss function)r(u) = u2,

    n

    i=1

    r(Y X) =n

    i=1

    (Y X)2.

    E[Y |X = x], Y E[(Y Y )2|X = x].

    1.3 -

    , . - , , . , - , Y . - Y , .

    6

  • 1.3.

    50

    60

    70

    80

    5 10 15 20 250 X

    Y

    1.2: 459 ( )

    , 459 - [;]. 1.2 ( ). X ( ) - Y (). - y = 0 + 1x+ 2x

    2 + .

    (...). (-) Y (outliers) , - . , E(Y |X = 25) 65 - 25 65000 . - , 25 . -

    7

  • 1.

    25 65000 . , , . 0.5 . ( ) 25 ( y) P (Y < y|X = 25) = 0.5. 80%

    25 ; 90% 15 2 . ; .

    (robust) .

    8

  • 2

    Is it safe? Is it safe?

    Marathon Man

    Dr Christian Szell

    2.1 -

    - , ., , ... -

    E[Y |X = x] , . ( ) - Y Xi. -. . . , Y Xi - (quantile regression).

    9

  • 2.

    -.

    {3, 6, 7, 8, 8, 10, 13, 15, 16, 20}

    (10 ). - 1 3 1

    4

    34 -

    . 7. () 1 1 . 8+10

    2= 9

    8 10 - 1. (10.6) . , p- p

    100 1p

    100 p (0, 100).

    90 90% 10%. , 50 .

    2.2

    - . 1978 Koenker Bassett[?] - , . , - , - , Y . -

    ,

    1 .. 2k+1 k k

    10

  • 2.3.

    - . - F F1 . ,

    , p100 , p (0, 1). , x

    P (X x) = p.

    p = 0.5 - (median regression). ()

    F (x) = 1 ex.

    F1(p, ) = ln{1 p}

    0 p 1.

    ,

    F1(0.25, ) =ln{4/3}

    ,

    F1(0.5, ) =ln{2}

    ,

    F1(0.75, ) =ln{4}

    .

    25% .

    P (X ln{2}

    ) = 0.5 .

    2.1 .

    2.3

    F1y (p|X) = Qy(p|X).

    11

  • 2.

    2.1: - .

    FY (y) QY (p)

    () 1 ex ln{1p}

    (, ) 1 (y) (1 p) 1

    (, ) y

    p( ) + (, s) 1

    1+e(y)/s s ln 1p

    p

    , p = 0.9 , Qy(0.9|X) 90 Y Xi 90% Y Xi P (Y y|X) = 0.9. -

    , Y .

    , . , . (low tail) -, (upper tail). - , . (..) . , ..., . , , Y .

    ... - ( i ) , -

    12

  • 2.3.

    50

    60

    70

    80

    5 10 15 20 250 X

    Y

    75%

    50%

    25%

    2.1: -

    , Y . -

    yi = 0,p + 1,pxi1 + . . .+ k,pxik + i,p i = 1, . . . , n.

    Qy(p|X) = 0,p + 1,pX1 + . . .+ k,pXk.

    Qy(i,p|X) = 0 ... E(i|X) = 0. . , -

    1.2, 459 , - Y ( ). 2.1 1.2 -

    (25%, 50%, 75%)

    13

  • 2.

    Y . , - .

    P (Y 60|X = 25) = 0.5

    0.5 25 60000 . ( ). 2.1 25%

    25 79000 . 75

    P (Y 79|X = 25) = 0.75

    P (Y > 79|X = 25) = 0.25 .

    - 50 . - Y Xi.

    2.4 -

    - ( ) Y Xi , - .

    , n

    i=1 r(Y X) r(u) = u2 .

    yi = 0,0.5 + 1,0.5xi1 + . . .+ k,0.5xik + i,p i = 1, . . . , n.

    14

  • 2.4.

    Y Xi.

    Y =

    y1y2...yn

    , X =

    1 x11 . . . x1k1 x21 . . . x2k......

    ......

    1 xn1 . . . xnk

    , 0.5 =

    0(0.5)1(0.5)...

    k(0.5)

    , 0.5 =

    1,0.52,0.5...

    n,0.5

    Y = X0.5 + 0.5.

    0.5 ( ) 0.5

    n

    i=1

    0.5(Y X0.5)

    0.5(u) = 0.5|u| (absolute lossfunction).

    0.5(u) = 0.5|u|= 0.5uI[0,)(u) (1 0.5)uI(,0)(u).

    IA(u) =

    {

    1 u A0 u / A

    A. p,

    p

    n

    i=1

    p(Y Xp)

    p(u) = p|u| .

    p(u) = p|u|= puI[0,)(u) (1 p)uI(,0)(u).

    (check function).

    15

  • 2.

    p p

    p = argminp

    {n

    i=1

    p(Y Xp)}

    0.5 = argmin0.5

    {n

    i=1

    0.5(Y Xp)}.

    , . . yi ,

    yi =

    K

    k=1

    k,pxik + i,p

    =K

    k=1

    (1k,p 2k,p)xik + (i,p i,p).

    1k,p 0, 2k,p 0 k = 1, . . . , K i,p 0, i,p 0 i = 1, . . . , n. ,

    min1k,p,

    2k,p,i,p,i,p

    n

    i=1

    pi,p + (1 p)i,p

    yi =K

    k=1

    (1k,p 2k,p)xik + (i,p i,p)

    1k,p,

    1k,p, i,p, i,p 0 (i, k).

    A = (X,X, I,I), z = (1k,p, 2

    k,p,

    i,p,

    i,p)

    c = (0, 0, pi, (1 p)i)

    minzcz

    16

  • 2.4.

    Y

    1000 30002000 4000 5000

    500

    1000

    1500

    2000

    2.2: Engel , 235

    Az = y (z 0)

    maxw

    wy

    wA c

    w (p1, p)n [;]. X (min cz = maxwy). -

    . Engel , . -, Engel X Y . 2.2 1857 235 - X Y [;]. - p {0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95}

    17

  • 2.

    ( ).

    . . ( ) ., -

    Y -. - . 2.2 , . , k , k . , - , .

    2.5 -

    - (labour economics). Chamberlain[?] , , 10 28% 90 0.3%. -

    18

  • 2.5.

    15.8% - .

    (reference charts) - , , ., (survival analysis) -

    (.. ) , .

    , , - . - 50 , - . qp(x) , p0 100(1 p0)% qp0(x), .

    , . - , , . Levin[?] - , - , , - . Tian[?] ( , , , -, , ..)

    19

  • 2.

    5 50. . - . , .

    20

  • 3

    You come at the king, you bestnot miss.

    The Wire

    Omar Devone Little

    2 - . - . -, . ( ) . - -, . , 2 : ( ) . .

    21

  • 3.

    3.1

    (likelihood function) - X1, X2, . . . , Xn

    L() = L(; x1, x2, . . . , xn) = f(x1, x2, . . . , xn; )

    . . X1, X2, . . . , Xn f(x; )

    L() = L(; x1, x2, . . . , xn) =n

    i=1

    f(xi; ).

    X1, X2, . . . , Xn Bernoulli().

    f(x; ) = x(1 )1x x = 0, 1 0 < < 1.

    L() =n

    i=1

    f(xi; )

    =

    n

    i=1

    xi(1 )1xi

    =

    xi(1 )n

    xi .

    X1, X2, . . . , Xn N(, 2) 2 ). = (, 2)

    f(x;, 2) =122

    exp{ 122

    (x )2} R, 2 0

    L(, 2) =

    n

    i=1

    f(xi;, 2)

    =n

    i=1

    122

    exp{ 122

    (xi )2}

    = (22)n/2exp{ 122

    n

    i=1

    (xi )2}.

    22

  • 3.2.

    - Xi, i = 1, . . . , n , .

    3.2

    ,

    L() = max

    L().

    , . . -

    l() = logL()

    .

    X1, X2, . . . , Xn Bernoulli(). L() =

    xi(1 )n

    xi.

    L(), l() = logL().

    l() = logL()

    =

    xi ln + (n

    xi) ln(1 ).

    l()

    = 0.

    l()

    =

    xi

    n

    xi1 = 0

    23

  • 3.

    xi

    xi = n

    xi

    n =

    xi =

    xin

    .

    = x l()

    2l()

    2|= < 0

    2l()

    2|= =

    xi

    2 n

    xi

    (1 )2

    =

    xix2

    n

    xi(1 x)2

    =

    xi

    (

    xin

    )2 n

    xi

    (1 (

    xin

    )2

    = . . .

    = n2( 1xi

    +1

    n xi) < 0.

    (...) X1, . . . , Xn Bernoulli() = x.

    -. -. l()

    , -

    . l() . ,

    , I()

    I() = 2

    2l()

    Fisher . - Fisher

    I() = E[ 2

    2l()]

    .

    24

  • 3.2.

    I(), .

    . l(),

    se() = I1/2(),

    . , X1, X2, . . . , Xn

    N(, 2) ,. =.

    L() = (22)n/2exp{ 122

    n

    i=1

    (xi )2}

    ,

    l()

    = 0,

    . ,

    2l()

    2|= < 0

    = x

    2l()

    2|= =

    n

    2< 0.

    ,

    I() =n

    2

    se() =n.

    25

  • 3.

    L()

    3.1:

    ,

    2l()2

    |= < 0 - , 3.1. .

    3.3 -

    -.

    I -

    (Invariance). u() - , u() u().

    26

  • 3.4.

    II ... , n .

    III ... I1().

    IV ...

    3.4

    - . Fisher .

    L() L()L()

    > C

    (cutoff point) C. , D() ..

    D() = 2(l() l())

    D() X2

    D() X21.

    ,

    Pr(L()

    L()> C) = Pr(log

    L()

    L()> logC)

    = Pr(logL()

    L()< logC)

    = Pr(2 logL()

    L()< 2logC)

    = Pr(D() < 2c)

    c = log(C).

    27

  • 3.

    0 < < 1 c = 12X21,(1) X

    21,(1)

    100(1 ) X21 ,

    Pr(L()

    L()> C) = Pr(X21 < X

    21,(1)) = 1

    c

    {, L()L()

    > C}

    100(1 )% . c

    Fisher 6.7% , = 0.05 0.01 c 0.15 0.04 . 95% 99% 15% 4%. .. X1, X2, . . . , X10 10 -

    , Xi = 1 i Xi = 0 . , - X =

    10i=1Xi = 8, ,

    , . .. X B(n, ) n = 10 ,

    f(x; ) =

    (

    n

    x

    )

    x(1 )nx, x = 1, 2, . . . , 10, 0 < < 1

    x = 8 .

    l() = x log + (n x) log(1 )

    =x

    n= 0.8 .

    3.2 . C = 0.04 C = 0.15. = 0.8 C = 0.04 (0.41, 0.98) c = 0.15 (0.50, 0.96). 99% 95%.

    28

  • 3.5.

    L()

    0.0

    0.2

    0.4

    0.6

    0.8

    1.0

    0.20.0 0.8 1.00.4 0.6

    3.2: 15% 4%

    - . 95% 95% - , 95% .

    3.5

    -, . = (1, 2, . . . , s) i 2. . = (1, 2, . . . , s) s- .

    Fisher -

    29

  • 3.

    .

    Iij() = 2

    ijl()|= i, j = 1, 2, . . . , s.

    Fisher

    Iij() = E[ 2

    ijl()]

    i, j = 1, 2, . . . , s.

    , l() ... I(). X1, X2, . . . , Xn -

    N(, 2) ( ). = (, 2)

    f(x;, 2) =122

    exp{ 122

    (x )2}, R, 2 0.

    L() = L(, 2) = (22)n/2exp{ 122

    n

    i=1

    (xi )2}.

    1, 2 = 1 2 = 2

    l(1, 2)

    1= 0

    l(1, 2)

    2= 0

    ,

    2l(1, 2)

    2i|i=i < 0 i = 1, 2.

    1 = x, 2 =1

    (xi x)2.

    30

  • 3.6. BOOTSTRAP

    - 2 , . Fisher

    I() =

    (

    n/2 00 n/(24)

    )

    , - . , PL(i), = (i, ),

    PL(i) = max

    L(i, ) = L(i, )

    PL(2) = (22)n/2exp{ 122

    n

    i=1

    (xi x)2}

    PL() =(2

    n

    n

    i=1

    (xi )2)n/2

    exp{n2}

    .

    3.6 Bootstrap

    Bootstrap Effron (1979) , . Bootstrap . X1, X2, . . . , Xn F

    X1 = x1, X2 = x2, . . . , Xn = xn. .

    31

  • 3.

    ( ) F . - Bootstrap , B, n F , - Fn . Fn (x1, x2, . . . , xn) - 1/n x1, x2, . . . , xn

    Fn =

    ni=1 I(xi x)

    n

    I(A) . n Fn (x1, x2, . . . , xn). B

    i, i = 1, 2, . . . , B. B ,

    B , .

    s =

    1

    B

    B

    i=1

    (i )2

    =1

    B

    B

    i=1

    i.

    F . n = 2 X1 = c < X2 = d

    . X1 , X2

    Pr(Xi = c) = Pr(Xi = d) =

    1

    2, i = 1, 2.

    n = 2 22

    (c, c), (c, d), (d, c), (d, d)

    14.

    i=

    X1 +X2

    2=

    c p = 14

    c+d2

    p = 12

    d p = 14

    i = 1, 2, . . . , B

    32

  • 3.7.

    i i

    B 2

    . = 1B

    Bi=1 i

    . -

    Bootstrap .

    1 2

    (

    )

    CovB(1, 2

    ) =

    1

    B

    B

    i=1

    (1i 1

    )(i2

    2)

    (1i, i2

    ) Bootstrap i

    . Bootstrap . , Bootstrap - . ( n nn

    ) . Bootstrap

    [;], [;], HungChen[?].

    3.7

    - . , , ()

    - () 0, .

    -

    ()d = 1

    () = 1.

    () (prior distribution) ( )

    33

  • 3.

    . , x =(x1, x2, . . . , xn) L(x|) = L(). , (posterior distribution) p(|x) Bayes

    p(|x) = L(x|)()L(x|)()d , .

    Bayes -

    p(|x) L(x|)().

    x = (x1, x2, . . . , xn) X Poisson() ,

    f(x|) = xe

    x!, 0.

    E(X) = V (X) = .

    L(x|) =n

    i=1

    exi

    xi!

    en

    xi

    Gamma(r, q),

    () =qr

    (r)r1e{q}, > 0,

    E() =r

    qV () =

    r

    q2.

    Bayes

    p(|x) r1exp{q} exp{n}

    xi

    = (r+

    xi1)exp{(q + n)}= R1exp{Q}

    34

  • 3.8.

    R = r +

    xi Q = q + n. ,

    |x Gamma(R,Q)

    , - . p(|x)

    Ep(|x) =

    L(x|)()d

    L(x|)()d

    .

    3.8

    (Credibility intervals ) - . , - C(x) 100(1 )%

    C(x)

    p(|x)d = 1 .

    1 - C(x). . ( ) . - 1 100(1)% . 1 . ( )

    C(x) = { : p(|x) }

    C(x)

    p(|x)d = 1 .

    35

  • 3.

    ( ) - (highest posterior density intervals/regions). - (a, b). .

    3.9 -

    , L(x|) (). . , , .

    . - , - . (uninformative prior ) , - prior . , - .

    I prior .

    II prior ( posterior prior).

    III prior (.. ), . () .

    IV , prior .

    36

  • 3.10.

    3.10

    , () . Bayes

    L(x|)()d

    . x = (x1, x2, . . . , xn)

    X Poisson() . [0, 1], , () = 1, 0 1

    L(|x) exp(n)

    xi .

    1

    0

    exp(n)

    xid.

    , . - . Gamma(r, q), |x Gamma(R,Q). ()

    p(|x) (), () (conjugate prior).

    , . -

    (exponential family).

    L(x|) = h(x)g()exp{t(x)c()}

    37

  • 3.

    3.1: - .

    () p()x (n, ) Beta(r, q) Beta(r + x, q + n x)x1, . . . , xn () Beta(r, q) Beta(r + n,

    xi n)x1, . . . , xn Poisson() Gamma(r, q) Gamma(r +

    xi, q + n)x1, . . . , xn Normal(, 1), ( ) Normal(b, c1) Normal( cb+nxc+n , 1c+n )

    h, g, t, c

    L(x|)dx = g()

    h(x)exp{t(x)c()}dx = 1.

    , Poisson , Gamma, . 3.1

    . () .

    3.11

    . . = (1, 2, . . . , s)

    s -. () , L(x|)

    38

  • 3.12. MARKOV CHAIN MONTE CARLO

    Bayes

    p(|x) = L(x|)()L(x|)()d

    . . (conditional posterior distribu-

    tion) pi(i|y, i) i i

    pi(i|x, i) p(|x)

    i . - p(|x) i, .

    (marginal posterior distribution) p(i|x) - i

    p(i|x) =

    p(|x)di,

    p(|x) i.

    3.12 Markov chain Monte Carlo

    - Markov chainMonte Carlo. - . , . Markov chain Monte Carlo (MCMC) -

    , , . MCMC , Gibbs Metropolis-Hastings.

    39

  • 3.

    3.12.1 Gibbs

    Xi|, N(, 1 ) i =1, 2, . . . , n , .

    f(x|, ) =n

    i=1

    (

    2)1/2exp{

    2(xi )2} n/2exp{

    2

    n

    i=1

    (xi )2}

    ,

    N(0,1

    0) , Gamma(0, 0)

    , . - ,

    f(, |x) e2n

    i=1(xi)2

    e02(0)2

    n2+01e0

    , . - , ,

    (|, x) N(00 + n

    i=1 xi0 + n

    ,1

    0 + n),

    (|, x) Gamma(0 +n

    2, 0 +

    ni=1(xi )2

    2).

    (conditional conjuga-cy ) Gibbs . d (1, 2, . . . , d) f(1, 2, . . . , d|x). Gibbs

    I = ((0)1 , (0)2 , . . . ,

    (0)d ).

    II (1)1 f(1|x, (0)2 ,

    (0)3 , . . . ,

    (0)d ).

    III (1)2 f(2|x, (1)1 ,

    (0)3 , . . . ,

    (0)d ).

    40

  • 3.12. MARKOV CHAIN MONTE CARLO

    IV . . .

    V (1)d f(d|x, (1)1 ,

    (1)2 , . . . ,

    (1)d1).

    VI II V .

    f(1, 2, . . . , d|q) . , (burn-in period ) . ,

    .

    f(|x) = f(x|)f()f(x|)f()d

    , Gibbs , - .

    3.12.2 Metropolis-Hastings

    Gibbs MCMC -. , Gibbs ( ). . - MCMC Metropolis-Hastings. Xi|, Cauchy(, 1 ) i = 1, 2, . . . , n.

    f(x|, ) =n

    i=1

    f(xi|, ) =n

    i=1

    1/2

    1

    1 + (xi )2.

    41

  • 3.

    , , ,

    N(0,1

    0) , Gamma(0, 0)

    , . - ,

    f(, |x) {n

    i=1

    1

    1 + (xi )2}e

    02(0)2

    n2+01e0I[ > 0].

    ,

    f(|, x) {n

    i=1

    1

    1 + (xi )2}e

    02(0)2

    f(|, x) {n

    i=1

    1

    1 + (xi )2} n2 +01e0I[ > 0].

    Gibbs. Gibbs , Metropolis-Hastings .

    I d 1, . . . , d 1.

    II ((0)1 , (0)2 , . . . ,

    (0)d ).

    III (0)1 (1)1

    f(1|x, (0)2 , (0)3 , . . . ,

    (0)d ).

    IV (0)2 (1)2

    f(2|x, (1)1 , (0)3 , . . . ,

    (0)d ).

    V . . .

    VI (0)d (1)d

    f(d|x, (1)1 , (1)2 , . . . ,

    (1)d1).

    42

  • 3.12. MARKOV CHAIN MONTE CARLO

    VII III V I.

    , , -. Metropolis-Hastings i ( ). MCMC -

    j (j)1 , (j)2 , . . . ,

    (j)d

    (j+1)1 , 1. - Metropolis-Hastings .

    1. can1 -

    q(can1 |(j)1 ,

    (j)2 , . . . ,

    (j)d ).

    2. 1 (j+1)1

    (j+1)1 =

    {

    can1 p

    (j)1 1 p

    p = min{1, f(can1 |x,

    (j)2 , . . . ,

    (j)d )

    f(j1|x, (j)2 , . . . ,

    (j)d )

    q(j1|can1 , (j)2 , . . . ,

    (j)d )

    q(can1 |(j)1 ,

    (j)2 , . . . ,

    (j)d )

    }

    f(can1 |x, (j)2 , . . . ,

    (j)d ) -

    1 1 = can1

    f(j1|x, (j)2 , . . . ,

    (j)d ).

    ,

    q(can1 |(j)1 ,

    (j)2 , . . . ,

    (j)d )

    . Metropolis-Hastings - Gibbs. Gibbs Metropolis-

    Hastings q(can1 |(j)1 ,

    (j)2 , . . . ,

    (j)d ) =

    f(can1 |(j)1 ,

    (j)2 , . . . ,

    (j)d )

    (j+1)1 =

    can1

    1[;].

    43

  • 3.

    44

  • 4

    And Id join the movementIf there was oneI could believe inYeah Id break bread and wineIf there was a church I couldreceive in.

    Acrobat

    U2

    , ( ).

    45

  • 4.

    4.1

    -

    yi = 0 + 1xi + i i = 1, 2, . . . , n

    i N(0, 2).

    =[

    0, 1, 2]

    L(0, 1, 2|y) (2)n2 exp{ 1

    22

    n

    i=1

    (yi 0 1xi)2}

    l(0, 1, 2|y) = n

    2ln(2) 1

    22

    n

    i=1

    (yi 0 1xi)2.

    l0l1l2

    =

    12

    ni=1(yi 0 1xi)

    12

    ni=1 xi(yi 0 1xi)

    n22

    + 124

    ni=1(yi 0 1xi)2

    0 =

    [

    0, 1, 2]

    2 =

    ni=1(yi 0 1xi)2

    n

    0 1

    [

    nn

    i=1 xin

    i=1 xin

    i=1 x2i

    ]

    [

    0 1

    ]

    =

    [

    ni=1 yi

    ni=1 xiyi

    ]

    .

    0 = y 1x

    46

  • 4.1.

    1 =

    ni=1 xiyi 1n

    ni=1 xi

    ni=1 yi

    ni=1 x

    2i 1n(

    ni=1 xi)

    2

    ., Fisher

    I() = 2

    nn

    i=1 xi 0n

    i=1 xin

    i=1 x2i 0

    0 0 (22)1n

    yi = 0 + 1xi1 + . . .+ kxik + i, i = 1, . . . , n.

    i N(0, 2I).

    Y =

    y1y2...yn

    , X =

    1 x11 . . . x1k1 x21 . . . x2k......

    ......

    1 xn1 . . . xnk

    , =

    01...k

    , =

    12...n

    Y = X + ,

    E() = 0 V () = 2I 2 - I n n.

    =[

    , 2]

    .

    yi N(i, 2) i = xi xi =

    1xi1...xik

    i = 1, . . . , n.

    L() =( 1

    22)n/2

    exp{ 122

    n

    i=1

    (yi xi)2}

    47

  • 4.

    l(, 2|y) = n2ln(22) 1

    22

    n

    i=1

    (yi xi)2

    = n2ln(22) 1

    22[(y X)(y X)]

    = n2ln(22) 1

    22[yy 2 X y + X X]

    l(, 2|y)

    = 122

    [[yy 2 X y + X X]

    ]

    = 122

    [2X y + 2X X]

    =1

    22[X y X X].

    ,

    l(, 2|y)

    = 0

    1

    22[X y X X] = 0

    X X = X y

    = (X X)1X y.

    2

    l(, 2|y)2

    = n22

    +1

    24[y X)(y X)]

    l(, 2|y)2

    = 0

    n22

    +1

    24[y X)(y X)] = 0

    1

    24[y X)(y X)] = n

    22

    1

    2[y X)(y X)] = n.

    48

  • 4.2.

    2 =1

    n

    n

    i=1

    (y X )2.

    [;] Fisher

    = (X X)1X Y,

    2 =1

    n

    n

    i=1

    (yi xi)2

    I() = 2(X X).

    I1() = 2(X X)1.

    ... - Franklin[?]Gonzalez[?].

    4.2

    .

    yi = 0 + 1xi1 + . . .+ kxik + i, i = 1, . . . , n.

    i N(0, 2I)

    Y = X + ,

    E() = 0 V () = 2I 2 I n n. , ,

    =[

    , 2]

    49

  • 4.

    L(, 2|y) (2)n/2exp[(y X)(y X)

    22].

    (y X)(y X) = (y X X +X)(y X X +X)= [y X X( )][y X X( )]= (y X)(y X) + ( )X X( )= S + ( )X X( ).

    S = (y X)(y X)

    = (X X)1X y

    ... .

    L(, 2|y) (2)n/2exp[S + ( )X X( )

    22].

    = [, 2] - (NIG(a, d,m, V )) (Normal Inverse Gam-ma) a, d,m, V

    () =(a/2)d/2

    (2)p/2|V |1/2(d/2)(2)(d+p+2)/2exp[{(m)V 1(m)+a}/(22)],

    () (2)(d+p+2)/2exp[{( m)V 1( m) + a}/(22)]

    p(|y) ()L(|y)

    p(|y) (2)(d+n+p+2)/2exp[Q/(22)]

    Q = (y X)(y X) + ( m)V 1( m) + a= (V 1 +X X) (V 1m+X y) (mV 1 + yX) + (mV 1m+ yy + a)= ( m)(V )1( m) + a,

    50

  • 4.2.

    V = (V 1 +X X)1,

    m = (V 1 +X X)1(V 1m+X y),

    a = a+mV 1m+ yy (m)(V )1m.

    , d = d + n

    p(|y) = p(, 2|y) NIG(a, d, m, V )

    , 2 p(, 2|y) 2 .

    p(|y) =

    p(, 2|y)d2

    (2)(d+n+p+2)/2exp[Q/(22)]d2

    {1 + ( m)(aV )1( m)}(d+p)/2,

    t d m

    aV .

    2

    p(2|y) =

    p(, 2|y)d

    (2)(d+n+p+2)/2exp[Q/(22)]d

    (2)(d+2)/2exp[a/(22)],

    2 - (IG(a, d)) (Inverse Gamma) a d. -

    Sorensen,Gianola[?] OHagan[?].

    51

  • 4.

    4.3

    -

    - - . i. -

    i N(0, 2).

    Laplace (assymetric Laplace). - U Laplace

    gp(u) = p(1 p)exp{p(u)}, 0 < p < 1, u [0,)

    p(u) = puI[0,)(u) (1 p)uI(,0)(u)

    (check function). p = 1/2 gp(u) =14exp{ |u|

    2} Laplace

    . p, . 12p

    p(1p) p > 1/2,

    p < 1/2 0 p = 1/2 12p+2p2

    p2(1p)2

    p .

    yi = 0,p + 1,pxi1 + . . .+ k,pxik + i,p i = 1, . . . , n.

    Y Xi.

    Y =

    y1y2...yn

    , X =

    1 x11 . . . x1k1 x21 . . . x2k......

    ......

    1 xn1 . . . xnk

    , p =

    0(p)1(p)...

    k(p)

    , p =

    1,p2,p...

    n,p

    52

  • 4.4.

    Y = Xp + p.

    , p, p

    n

    i=1

    p(Y Xp)

    p(u) = p|u| . p

    L(yi|p, p, x1, . . . , xn) = (p(1 p)

    p)nexp{ 1

    p

    n

    i=1

    p(yi pxi)}

    0 < p < 1, p > 0.

    Y , ... . [;]

    p = argminp

    [n

    i=1

    p(yi pxi)]

    p =1

    n

    n

    i=1

    p(yi pxi).

    - Bootstrap [;]., Laplace , - tick-exponential . - Komunjer [;].

    4.4

    -

    - , MCMC

    53

  • 4.

    (Markov chain Monte Carlo) - . MCMC . , , - . y = (y1, y2, . . . , yn),

    p, p

    (p, p|y) L(y|p, p)p(p)p(p), p(p), p(p) p, p L(y|p, p)

    L(yi|p, p, x1, . . . , xn) = (p(1 p)

    p)nexp{ 1

    p

    n

    i=1

    p(yi pxi)}

    0 < p < 1, p > 0.

    p Yu Moyeed[?] (improper) p , (proper).1

    p 0 2p p ( )

    p(p) exp{2p22p

    }

    p(p) 1.

    (p, p|y) (p(1 p)

    p)nexp{ 1

    p

    n

    i=1

    p(yi pxi)}exp{2p22p

    }

    1 p()

    0 c H0.

    (x) < c H0.

    (x) = c H0 q,

    c, q

    qPr((x) = c|H0) +Pr((x) < c|H0) =

    .

    1 (x), H0. Likelihood ratio test

    61

  • 5.

    62

  • 6

    There is no such thing as animpartial jury because there areno impartial people. There arepeople that argue on the web forhours about who their favoritecharacter on Friends is.

    The Daily Show

    Jon Stewart

    (hedgefunds) . hedgefunds - . . 40% Euronext, - . - / . -

    (risk factors) . - hedge fund, - .

    63

  • 6.

    - .

    stepwise regression AIC BIC .

    , , , , . .

    - . , , -. - . . 4

    14 (risk factors) - - (0.1, 0.25, 0.5, 0.75, 0.9). AIC BIC. - - . - MATLAB .

    6.1

    4 : Convertible Arbitrage (CA), Equity Non-Hedge (ENH), Distressed Secu-

    64

  • 6.1.

    rities (DS), Merger Arbitrage (MA). CA (- , ) (short selling). - ENH (leverage). DS MA . - 1990 2005. - . 6.1

    - . 6.1 . (ENH) (CA, MA). . ENH CA 4 . , 4 - . DS, MA . - . -

    1.RUS Russell 3000 (Rus-sell 3000 equity index excess return).

    2.RUS(1) Russell 3000 (Rus-sell 3000 equity index excess return lagged once).

    3.MXUS ( ) Morgan Stanley(Morgan Stanley Capital Idternational world excluding USA index e-xcess return).

    4.MEM MorganStanley (Morgan Stanley Capital Idternational emerging markets indexexcess return).

    65

  • 6.

    6.1: -

    .

    .. . . . 25 v. 50 v. 75 v.CA 0.48 0.99 5.37 1.18 0.03 0.68 1.14ENH 1.00 4.05 3.63 0.53 1.60 1.70 3.53DS 0.84 1.75 8.50 0.68 0.05 0.81 1.72MA 0.50 1.08 13.38 2.39 0.08 0.64 1.12

    5.SMB Fama and French (Fama and Frenchs size).

    6.HML Fama and French(Fama and Frenchsbook-to-market).

    7.MOM Carhart (Carharts momentum factor).

    8.SBGC - Salomon Brothers (Salomon Brothers world government andcorporate bond index excess return).

    9.SBWG Salomon Brothers (SalomonBrothers world government bond index excess return).

    10.LHY Lehman (Lehman high yield indexexcess return).

    11.DEFSPR BA-A 10 (Difference between the yield on the BAA-rated corporate bonds and the 10-year bonds).

    12.FRBI Federal ReserveBank (Federal Reserve Bank competitiveness weighted dollar-index e-xcess return).

    13.GSCI Goldman Sachs (Goldman Sachs com-modity index excess return).

    14.VIX S&P 500 (Change in S&P500 implied volatility index).

    66

  • 6.2.

    6.2

    - 6.2. , ( 0) - (standarderrors).

    . , BIC AIC BIC .

    6.3 -

    - 6.3, 6.4, 6.5, 6.6. -, ( 0) (standard errors) Bo-otstrap. - . - . . (10 90 ) - .

    67

  • 6.

    . - MA 90 10 14 - 50 3. 7 13 10 90 , MA ( ). 9 11 CA (AIC) 11 ENH ( AIC).

    6.4

    -

    6.2 6.3, 6.4, 6.5, 6.6 , - , - DS, ENH BIC. - . hedge funds. -

    , , . - 6.3 hedge funds. - , . , , - , . , .

    68

  • 6.4.

    - , BIC. , BIC .

    69

  • 6.

    6.2: .. .

    AIC 2 4 5 8 10

    0.0042 0.0494 0.0347 0.0331 0.1370 0.0493s.e. 0.0007 0.0160 0.0106 0.0213 0.0531 0.0226

    CABIC 2 4 8 10

    0.0043 0.0539 0.0387 0.1232 0.0575s.e. 0.0007 0.0158 0.0103 0.0525 0.0220

    AIC 1 2 4 5 6 9 10 12 13 14

    0.0063 0.6920 0.0448 0.0704 0.4370 -0.1045 0.0812 0.0640 0.1613 0.0271 0.0780s.e. 0.0008 0.0332 0.0212 0.0175 0.0294 0.0234 0.0494 0.0288 0.0796 0.0142 0.0316

    ENHBIC 1 4 5 6 10 14

    0.0066 0.6969 0.0673 0.4548 -0.0950 0.0720 0.0948s.e. 0.0008 0.0335 0.0174 0.0284 0.0230 0.0289 0.0307

    AIC 2 4 5 8 10 11 12 14

    0.0074 0.0924 0.0898 0.0956 0.2301 0.0823 -2.7857 0.1513 -0.0556s.e. 0.0009 0.0229 0.0168 0.0287 0.0748 0.0306 0.8219 0.0770 0.0292

    DSBIC 2 4 5 8 10 11

    0.0073 0.0787 0.0988 0.0952 0.2161 0.0918 -3.1576s.e. 0.0009 0.0225 0.0145 0.0292 0.0759 0.0309 0.8192

    AIC 1 2 4 5 6 7 11

    0.0037 0.0996 0.0653 0.0405 0.0732 0.0516 0.0298 0.8227s.e. 0.0006 0.0221 0.0164 0.0136 0.0233 0.0221 0.0135 0.5584

    MABIC 1 2 4

    0.0043 0.0787 0.0681 0.0460s.e. 0.0006 0.0210 0.0152 0.0130

    70

  • 6.4.

    6.3: : .. . .

    0.10 AIC 2 3 4 5 6 8 9 10 11 -0.0083 0.0960 -0.0732 0.0981 -0.0703 -0.0609 0.2603 0.1015 0.0716 -2.0879s.e. 0.0018 0.0480 0.0546 0.0382 0.0727 0.0682 0.1557 0.1181 0.0542 2.0486

    0.25 1 2 3 4 8 10 11 13 14 -0.0001 0.0673 0.0759 -0.0405 0.0268 0.1199 0.0881 1.1586 0.0220 0.0315s.e. 0.0013 0.0384 0.0279 0.0406 0.0253 0.0848 0.0444 1.5808 0.0163 0.0388

    0.50 1 2 5 10 11 0.0059 0.0470 0.0439 0.0282 0.0972 2.3189s.e. 0.0006 0.0130 0.0141 0.0182 0.0364 0.6483

    0.75 2 4 5 6 7 8 11 13 0.0099 0.0297 0.0244 0.0293 -0.0325 -0.0431 0.1298 1.7262 0.0147s.e. 0.0006 0.0179 0.0100 0.0223 0.02221 0.0159 0.0399 0.5544 0.0130

    0.90 2 4 5 6 7 8 9 10 11 12 13 0.0125 0.0470 0.0231 0.0257 -0.0184 -0.0169 0.1072 -0.0507 0.0144 1.3574 -0.0619 0.0224s.e. 0.0011 0.0306 0.0202 0.0374 0.0315 0.0157 0.0777 0.0612 0.0756 0.8819 0.0888 0.0207

    CA0.10 BIC 2 3 4 8 11

    -0.0090 0.0763 -0.0515 0.1004 0.3214 -1.5298s.e. 0.0017 0.0502 0.0417 0.0272 0.1074 1.7396

    0.25 2 8 10 0.0001 0.0801 0.1398 0.1368s.e. 0.0009 0.0237 0.0516 0.0453

    0.50 1 2 5 10 11 0.0059 0.0470 0.0439 0.0282 0.0972 2.3189s.e. 0.0005 0.0119 0.0130 0.0174 0.0353 0.7283

    0.75 2 4 5 6 7 8 11 0.0095 0.0360 0.0246 0.0346 -0.0343 -0.1454 0.1354 1.7523s.e. 0.0006 0.0165 0.0112 0.0191 0.0215 0.0171 0.0372 0.5899

    0.90 2 4 5 10 11 0.0135 0.0469 0.0254 0.0434 0.0225 1.4495s.e. 0.0007 0.0281 0.0183 0.0185 0.0654 0.6323

    71

  • 6.

    6.4: : .. . .

    0.10 AIC 1 2 4 5 6 7 9 10 11 13 -0.0065 0.6239 0.0668 0.0988 0.3765 -0.1062 0.0137 0.1657 0.1366 -1.0523 0.0291s.e. 0.0014 0.0337 0.0260 0.0254 0.0357 0.0339 0.0183 0.0568 0.0544 1.1602 0.0143

    0.25 1 2 4 5 6 9 10 13 14 -0.0019 0.6191 0.0493 0.0896 0.3838 -0.0997 0.1176 0.0803 -0.2368 0.0257s.e. 0.0012 0.0546 0.0348 0.0360 0.0553 0.0394 0.0809 0.0360 0.0177 0.0503

    0.50 1 3 4 5 6 7 8 14 0.0061 0.6358 0.0405 0.0670 0.4986 -0.1042 -0.0030 0.1146 0.0855s.e. 0.0012 0.0530 0.0399 0.0272 0.0477 0.0376 0.0194 0.0982 0.0424

    0.75 1 3 4 5 6 7 11 12 14 0.0130 0.6677 0.0266 0.0841 0.4943 -0.1164 -0.0218 1.0484 0.2198 0.0768s.e. 0.0011 0.0532 0.0395 0.0314 0.0401 0.0404 0.0271 1.0466 0.0943 0.0644

    0.90 1 2 3 4 5 6 7 11 12 13 14 0.0194 0.7972 0.0404 0.0289 0.0333 0.4596 -0.0906 -0.0313 0.9426 0.2875 0.0559 0.1717s.e. 0.0019 0.1183 0.0507 0.0443 0.0358 0.0725 0.0616 0.0381 1.3739 0.1597 0.0375 0.1284

    ENH0.10 BIC 1 2 4 5 6 9 10 11 13

    -0.0066 0.6241 0.0667 0.0988 0.3670 -0.1183 0.1828 0.1097 -1.4624 0.0337s.e. 0.0014 0.0290 0.0268 0.0231 0.0350 0.0256 0.0597 0.0469 1.2791 0.0143

    0.25 1 4 5 6 9 10 14 -0.0012 0.6604 0.0849 0.4333 -0.0803 0.1154 0.0647 0.0622s.e. 0.0012 0.0475 0.0330 0.0480 0.0405 0.0579 0.0392 0.0342

    0.50 1 4 5 6 14 0.0066 0.7335 0.0653 0.4626 -0.0779 0.1339s.e. 0.0009 0.0460 0.0220 0.0497 0.0369 0.0388

    0.75 1 4 5 6 14 0.0126 0.7033 0.0744 0.5043 -0.1011 0.1060s.e. 0.0010 0.0456 0.0191 0.0426 0.0380 0.0760

    0.90 1 4 5 6 13 14 0.0191 0.8209 0.0194 0.5412 -0.0399 0.0511 0.1668s.e. 0.0014 0.0852 0.0360 0.0562 0.0626 0.0346 0.1172

    72

  • 6.4.

    6.5: : .. . .

    0.10 AIC 1 2 4 7 8 10 11 12 13 -0.0049 0.0565 0.1012 0.0865 0.0284 0.1460 0.1738 -2.4498 0.1634 0.0548s.e. 0.0019 0.0410 0.0386 0.0466 0.0331 0.1148 0.0737 1.3073 0.1219 0.0291

    0.25 1 2 4 5 7 8 10 11 12 0.0013 0.0517 0.0885 0.0422 0.0742 0.0172 0.1879 0.1361 -4.1552 0.0601s.e. 0.0011 0.0298 0.0269 0.0255 0.0331 0.0186 0.1023 0.0681 1.1223 0.0923

    0.50 2 3 4 5 8 10 11 13 0.0066 0.0671 0.0392 0.0725 0.0459 0.2820 0.0763 -4.0166 -0.0375s.e. 0.0012 0.0356 0.0332 0.0261 0.0636 0.1316 0.0770 1.3440 0.0289

    0.75 1 2 4 5 6 7 8 9 10 11 12 0.0132 0.0580 0.0663 0.0907 0.2061 0.0664 0.0494 0.1487 0.1209 0.0567 -3.0243 0.2432s.e. 0.0014 0.0372 0.0414 0.0213 0.0524 0.0512 0.0369 0.1273 0.0858 0.0508 1.4736 0.1377

    0.90 2 3 4 5 6 8 9 10 11 12 14 0.0209 0.0227 -0.0687 0.1291 0.2505 0.1051 0.2439 0.0795 0.0914 -2.0042 0.3356 -0.0300s.e. 0.0021 0.0575 0.0684 0.0374 0.0710 0.0450 0.1893 0.1125 0.0714 2.3445 0.1495 0.0563

    DS0.10 BIC 1 2 4 8 10 11 12 13

    -0.0045 0.0721 0.0912 0.0687 0.1782 0.1561 -2.5255 0.1923 0.0371s.e. 0.0018 0.0384 0.0391 0.0456 0.0902 0.0641 1.3520 0.1249 0.0261

    0.25 1 2 4 5 8 10 11 0.0014 0.0336 0.0851 0.0479 0.0687 0.2319 0.1242 -4.4157s.e. 0.0010 0.0388 0.0274 0.0222 0.0330 0.0902 0.0648 1.1975

    0.50 2 4 8 10 11 0.0059 0.0903 0.0847 0.2298 0.1082 -4.3613s.e. 0.0014 0.0298 0.0174 0.1233 0.0753 1.3483

    0.75 2 4 5 8 10 11 0.0142 0.0539 0.0861 0.1690 0.2461 0.0731 -3.0941s.e. 0.0011 0.0366 0.0156 0.0492 0.0891 0.0632 1.2087

    0.90 4 5 6 8 10 12 0.0202 0.1209 0.2548 0.1302 0.2649 0.0703 0.3399s.e. 0.0021 0.0282 0.0413 0.0419 0.1564 0.0580 0.1753

    73

  • 6.

    6.6: : .. . .

    0.10 AIC 1 2 3 4 5 6 7 11 12 13 -0.0070 0.1146 0.0915 0.0426 0.0604 0.0574 0.0378 0.0344 2.1157 0.1076 0.0369s.e. 0.0016 0.0453 0.0276 0.0501 0.0382 0.0322 0.0481 0.0245 1.3575 0.0944 0.0289

    0.25 1 2 4 5 7 8 12 14 -0.0007 0.0916 0.0453 0.0319 0.0648 0.0182 0.1471 0.1189 -0.0411s.e. 0.0009 0.0306 0.0329 0.0222 0.0319 0.0148 0.0654 0.0892 0.0417

    0.50 1 2 3 4 5 7 9 11 12 0.0051 0.0761 0.0671 -0.0379 0.0491 0.0544 0.0222 0.1074 1.3755 0.1353s.e. 0.0007 0.0320 0.0148 0.0231 0.0183 0.0206 0.0119 0.0452 1.0334 0.0539

    0.75 1 2 4 5 6 9 11 12 13 14 0.0096 0.0562 0.0435 0.0214 0.0738 0.0182 0.0689 0.8799 0.1802 -0.0225 -0.0230s.e. 0.0007 0.0235 0.0223 0.0150 0.0257 0.0256 0.0383 0.7499 0.0621 0.0138 0.0286

    0.90 1 2 5 7 8 10 11 12 13 14 0.0128 0.0449 0.0327 0.0713 -0.0303 0.1028 -0.0539 1.0319 0.1585 -0.0290 -0.0396s.e. 0.0007 0.0177 0.0234 0.0272 0.0179 0.0634 0.0351 0.6407 0.0572 0.0132 0.0288

    MA0.10 BIC 1 2 4 7 13

    -0.0059 0.1187 0.0890 0.0595 0.0275 0.0365s.e. 0.0019 0.0450 0.0369 0.0390 0.0238 0.0281

    0.25 1 2 4 -0.0004 0.0696 0.0499 0.0507s.e. 0.0008 0.0276 0.0307 0.0198

    0.50 1 2 5 0.0054 0.0837 0.0533 0.0690s.e. 0.0007 0.0246 0.0178 0.0139

    0.75 1 2 5 12 13 0.0100 0.0699 0.0254 0.0772 0.0790 -0.0231s.e. 0.0006 0.0172 0.0156 0.0259 0.0334 0.0089

    0.90 1 2 5 7 8 10 11 12 13 14 0.0128 0.0449 0.0327 0.0713 -0.0303 0.1028 -0.0539 1.0319 0.1585 -0.0290 -0.0396s.e. 0.0007 0.0199 0.0212 0.0242 0.0155 0.0549 0.0336 0.7342 0.0615 0.0145 0.0286

    74

  • Matlab

    Ignorance is bliss. Oedipusruined a great sex life by askingtoo many questions.

    The Colbert Report

    Stephen Colbert

    .1 Matlab -

    y - 6.1

    mean(y)

    std(y)

    prctile(y,[25 50 75])

    skewness(y)

    kurtosis(y)

    .2 Matlab -

    - AIC, BIC . 14

    75

  • . MATLAB

    214 = 16384. 2 , . MATLAB ( ).

    N=14;

    all_models=zeros(1,N);

    for i=1:N

    models_i=nchoosek(1:14,i);

    [a,b]=size(models_i);

    models_i=[models_i zeros(a,N-b)];

    all_models=[all_models; models_i];

    end

    save all_models all_models

    all models =

    1 0 0 0 . . . 02 0 0 0 . . . 0..................

    14 0 0 0 . . . 01 2 0 0 . . . 01 3 0 0 . . . 0..................

    13 14 0 0 . . . 0..................

    1 2 3 4 . . . 14

    16384 14 - . MATLAB AIC, BIC

    .

    function [minaic,minbic,B]=minaibi(y,X)

    load all_models

    load datafactors_hfrci.txt % Matrix that contains the risk factors

    for i=1:size(all_models14,1)

    model=all_models14(i,:);

    model(model==0)=[];

    76

  • .2. MATLAB

    X=datafactors_hfrci(:,model);

    [n,k]=size(X);

    s=regstats(y,X,linear); % Linear regression

    AIC=n*log(s.r*s.r)+2*(k+1); % Computing AIC, BIC

    BIC=n*log(s.r*s.r)+log(n)*(k+1);

    B(i,:)=[AIC BIC];

    end

    minaic=min(B(:,1)); % Computing the min AIC, BIC

    minbic=min(B(:,2));

    end

    AIC - .

    L() =( 1

    22)n/2

    exp{ 122

    n

    i=1

    (yi xi)2}

    l() = n2log(2) n

    2log(2) 1

    22

    n

    i=1

    (yi xi)2}

    = n2log(2) n

    2log(2) 1

    22n2

    = n2log(2) + c.

    ,

    AIC = n log(2) + 2k.

    BIC. - B 16384 2 AIC - BIC . . , B, ,

    [val1 ind1]=min(B(:,1)); % Value of minaic and index of that model

    [val2 ind2]=min(B(:,2)); % Value of minbic and index of that model

    allmodels(ind1,:) %Model with minimum AIC

    allmodels(ind2,:) %Model with minimum BIC

    77

  • . MATLAB

    , - , - CA AIC

    b1=[2 4 5 8 10]; %Best model factors

    X=datafactors_hfrci(:,b1);

    s1=regstats(y,X,linear);

    s1.beta %Regression coefficients

    sqrt(diag(s1.covb)) %Standard errors

    .3 Matlab

    - AIC, BIC . (check function) - .

    function sum = check(y,X,betaq,p)

    sum=0;

    qq=y-X*betaq;

    for i=1:size(qq,1)

    if (qq(i)>=0)

    sum=sum+p*qq(i);

    elseif (qq(i)

  • .3. MATLAB

    [m n] = size(X);

    u = ones(m, 1);

    a = (1 - p) .* u;

    b = -lp_fnm(X, -y, X * a, u, a);

    function y = lp_fnm(A, c, b, u, x)

    % Solve a linear program by the interior point method:

    % min(c * u), s.t. A * x = b and 0 < x < u

    % An initial feasible solution has to be provided as x

    %

    % Function lp_fnm of Daniel Morillo & Roger Koenker

    % Translated from Ox to Matlab by Paul Eilers 1999

    % Modified by Roger Koenker 2000--

    % More changes by Paul Eilers 2004

    % Set some constants

    beta = 0.9995;

    small = 1e-5;

    max_it = 50;

    [m n] = size(A);

    % Generate inital feasible point

    s = u - x;

    y = (A \ c);

    r = c - y * A;

    r = r + 0.001 * (r == 0); % PE 2004

    z = r .* (r > 0);

    w = z - r;

    gap = c * x - y * b + w * u;

    % Start iterations

    it = 0;

    while (gap) > small & it < max_it

    it = it + 1;

    % Compute affine step

    q = 1 ./ (z ./ x + w ./ s);

    r = z - w;

    Q = spdiags(sqrt(q), 0, n, n);

    AQ = A * Q; % PE 2004

    79

  • . MATLAB

    rhs = Q * r; % "

    dy = (AQ \ rhs); % "

    dx = q .* (dy * A - r);

    ds = -dx;

    dz = -z .* (1 + dx ./ x);

    dw = -w .* (1 + ds ./ s);

    % Compute maximum allowable step lengths

    fx = bound(x, dx);

    fs = bound(s, ds);

    fw = bound(w, dw);

    fz = bound(z, dz);

    fp = min(fx, fs);

    fd = min(fw, fz);

    fp = min(min(beta * fp), 1);

    fd = min(min(beta * fd), 1);

    % If full step is feasible, take it. Otherwise modify it

    if min(fp, fd) < 1

    % Update mu

    mu = z * x + w * s;

    g = (z + fd * dz) * (x + fp * dx) + (w + fd * dw) * (s + fp * ds);

    mu = mu * (g / mu) ^3 / ( 2* n);

    % Compute modified step

    dxdz = dx .* dz;

    dsdw = ds .* dw;

    xinv = 1 ./ x;

    sinv = 1 ./ s;

    xi = mu * (xinv - sinv);

    rhs = rhs + Q * (dxdz - dsdw - xi);

    dy = (AQ \ rhs);

    dx = q .* (A * dy + xi - r -dxdz + dsdw);

    ds = -dx;

    dz = mu * xinv - z - xinv .* z .* dx - dxdz;

    dw = mu * sinv - w - sinv .* w .* ds - dsdw;

    % Compute maximum allowable step lengths

    fx = bound(x, dx);

    fs = bound(s, ds);

    80

  • .3. MATLAB

    fw = bound(w, dw);

    fz = bound(z, dz);

    fp = min(fx, fs);

    fd = min(fw, fz);

    fp = min(min(beta * fp), 1);

    fd = min(min(beta * fd), 1);

    end

    % Take the step

    x = x + fp * dx;

    s = s + fp * ds;

    y = y + fd * dy;

    w = w + fd * dw;

    z = z + fd * dz;

    gap = c * x - y * b + w * u;

    %disp(gap);

    end

    function b = bound(x, dx)

    % Fill vector with allowed step lengths

    % Support function for lp_fnm

    b = 1e20 + 0 * x;

    f = find(dx < 0);

    b(f) = -x(f) ./ dx(f);

    AIC, BIC .

    function [minaicq,minbicq,Q]=minaibiq(y,X,p)

    load all_models

    load datafactors_hfrci.txt % Matrix that contains the risk factors

    for i=1:16384

    model=all_models(i,:);

    model(model==0)=[];

    X=datafactors_hfrci(:,model);

    [n,k]=size(X);

    X=[ones(n,1) X];

    betaq=rq(X, y, p); %Quantile regression function

    ch=check(y,X,betaq,p);

    AIC=2*n*log(ch)-2*n*log(p*(1-p))+2*n-2*n*log(n)+2*(k+1);

    BIC=2*n*log(ch)-2*n*log(p*(1-p))+2*n-2*n*log(n)+log(n)*(k+1);

    81

  • . MATLAB

    Q(i,:)=[AIC BIC];

    end

    minaicq=min(Q(:,1)); % Computing the min AIC, BIC

    minbicq=min(Q(:,2));

    end

    AIC

    L(yi|p, p, x1, . . . , xn) = (p(1 p)

    p)nexp{ 1

    p

    n

    i=1

    p(yi pxi)}

    l() = n log(p(1 p)) n log(p)1

    p

    n

    i=1

    p(yi pxi)

    = . . .

    = n log(p(1 p)) n log(n

    i=1

    p(yi pxi)) + n log(n) n.

    ,

    AIC = 2n log(n

    i=1

    p(yi pxi)) 2n log(p(1 p)) + 2n 2n log(n) + 2k.

    BIC. - Q 16384 2 AIC - BIC . . , Q, ,

    [val1 ind1]=min(Q(:,1)); % Value of minaic and index of that model

    [val2 ind2]=min(Q(:,2)); % Value of minbic and index of that model

    allmodels(ind1,:) %Model with minimum AIC

    allmodels(ind2,:) %Model with minimum BIC

    Bootstrap -

    82

  • .3. MATLAB

    function [bootestimates,covmat_boot]=b_bootstrap(F,data,p,b_lsq,B,m);

    T=length(data);

    bootestimates=zeros(length(b_lsq),B);

    for bb=1:B

    bootsample=unidrnd(T,1,m);

    boot_factors=F(bootsample,:);

    boot_data=data(bootsample);

    b_boot=rq(boot_factors,boot_data,p);

    bootestimates(:,bb)=[b_boot];

    end

    mles=repmat([b_lsq],[1,B]);

    covmat_boot=(m/T)*(bootestimates-mles)*(bootestimates-mles)/B;

    - , y , p, p, B m ., -

    , - CA AIC

    b1q=[2 3 4 5 6 8 9 10 11]

    X=datafactors_hfrci(:,b1q);

    [n k]=size(X);

    X=[ones(n,1) X];

    beta1q=rq(X,y,0.1);

    [bootestimates,covmat_boot]=b_bootstrap(X,y,0.1,beta1q,100,189);

    sqrt(diag(covmat_boot))

    83