Design Matrix

Discussion in 'Careers' started by entact, Nov 18, 2014.

  1. entact

    entact Member

    For the following dataset:

    Design Matrix

    Exp Clms Size Type
    500 42 small 1
    1200 37 medium 1
    100 1 large 1
    400 101 small 2
    500 73 medium 2
    300 14 large 2

    Is the correct design matrix, X:

    1 1 0 0
    1 0 1 0
    1 0 0 0
    1 1 0 1
    1 0 1 1
    1 0 0 1

    So the base will size(large) and type(1).

    I've imported this data in Emblem modelling software and fit the first iteration only. The attachment 'Betas.jpg' is the results I am getting for the betas. The 'mean' as described in the attachment is size(large) and type(1).

    I have also attached the results of the 1st Iteration showing the fitted values. I am trying to replicate these values!

    So my design matrix, X, is above. Next is the W matric. I have attached the formula which Emblem give for a Poisson with log link (attachment: 'formulae.jpg'). I assume the wi in the formula is the Exp (exposure years) column in the data above? I know mu in the formula is a function of inital estimate of betas. I have attached the note in the Emblem guide where they discuss the initial fit and a brief discussion of intial mu (attachment: 'Initial Fit Instructions.jpg'). It gives 2 options for inital mu. The first, average y, I assume is the (sum of Clms)/(sum of Exp) so a so the vector initial mui is:

    .08933
    .08933
    .08933
    .08933
    .08933
    .08933

    Is this correct. If so the diag(wi.mui) would be:

    500*.08933 0 0 0 0 0 0

    0 1200*.08933 0 0 0 0

    0 0 100*.08933 0 0 0

    ...

    ...

    ...

    Finally, the linear predictor at the end of the formula

    Β(1st iteration)=(X_T.W.X)^(-1).X_T.W.η

    is log(mui(initial))

    so...

    η vector is:

    log(.08933)
    log(.08933)
    log(.08933)
    log(.08933)
    log(.08933)
    log(.08933)


    When I put all of this together I get the following values for my betas from iteration 1 I get

    -2.415
    0
    0
    0

    Which is clearly wrong and doesn't match the betas from the attached.

    The fitted values I get are a vector of all same values:

    .08933
    .08933
    .08933
    .08933
    .08933
    .08933

    Whereas the values in the attachment (Fitted Values...) are

    .104833
    .045030
    ...
    ...
    ...
    ...

    If anyone can help solve this and shed some light for me it would be brilliant. I'm only interested in the 1st iteration so if you knew it would take 2 minutes in excel to do the matrix multiplication and put me out of my misery.

    Many thanks in advance
     

    Attached Files:

Share This Page