# icdglm.fit: EM by the Method of Weights for Incomplete Data in GLMs... In icdGLM: EM by the Method of Weights for Incomplete Categorical Data in Generlized Linear Models

## Description

This function applies the EM algorithm by the method of weights to incomplete data in a general linearized model.

## Usage

 ```1 2``` ```icdglm.fit(x, y, weights = rep.int(1, NROW(x)), indicator = rep.int(0, NROW(x)), family = binomial(link = "logit"), control=list()) ```

## Arguments

 `x` a vector, matrix, list or data frame containing the independent variables `y` a vector of integers or numerics. This is the dependent variable. `weights` a vector which attaches a weight to each observation. For incomplete data, this is obtained from `expand_data`. `indicator` a vector that indicates which observations belong to each other. This is obtained from `expand_data`. `family` family for glm.fit. See `glm` or `family` for more details. Default is `binomial(link = "logit")`. `control` a list of control characteristics. See `glm.control` for further information. Default settings are: `epsilon = 1e-10, maxit = 100, trace = FALSE`.

## Value

`icdglm.fit` returns a list with the following elements:

• xa matrix of numerics containing all independent variables

• ya vector of numerics containing the dependent variable

• new.weightsthe new weights obtained in the final iteration of icdglm.fit

• indicatora vector of integers indicating which observations belong to each other

• glm.fit.datatypical `glm.fit` output for the last iteration. See `glm.fit` for further information.

• coefficientsa named vector of coefficients

• qrQR Decomposition of the information matrix

• residualsthe residuals of the final iteration

• fitted.valuesthe fitted mean values, obtained by transforming the linear predictors by the inverse of the link function.

• rankthe numeric rank of the fitted linear model

• familythe family object used.

• linear.predictorsthe linear fit on link scale

• devianceup to a constant, minus twice the maximized log-likelihood. Where sensible, the constant is chosen so that a saturated model has deviance zero.

• aicsee glm

• null.devianceThe deviance for the null model, comparable with deviance. The null model will include the offset, and an intercept if there is one in the model. Note that this will be incorrect if the link function depends on the data other than through the fitted mean: specify a zero offset to force a correct calculation.

• iteran integer containing the number of iterations in icdglm.fit before convergence

• weightsthe working weights, that is the weights in the final iteration of the IWLS fit.

• prior.weightsthe weights initially supplied, a vector of 1s if none were.

• df.residualthe residual degrees of freedom from the initial data set

• df.nullthe residual degrees of freedom from initial data set for the null model

• modelmodel frame

• convergedTRUE if icdglm converged.

• callthe match call

• formulathe formula supplied

• termsthe terms object used

• datathe data argument

• controlthe value of the control argument used

## References

Ibrahim, Joseph G. (1990). Incomplete Data in Generalized Linear Models. Journal of the American Statistical Association, Vol.85, No. 411, pp. 765 - 769.

## See Also

`expand_data`, `icdglm` `glm.fit`, `glm.control`, `summary.glm`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12``` ```data(TLI.data) complete.data <- expand_data(data = TLI.data[, 1:3], y = TLI.data[, 4], missing.x = 1:3, value.set = 0:1) example1 <- icdglm.fit(x = complete.data\$data[, 1:3], y = complete.data\$data[, 4], weights = complete.data\$weights, indicator = complete.data\$indicator, family = binomial(link = "logit"), control = list(epsilon = 1e-10, maxit = 100, trace = TRUE)) ```

### Example output

```Deviance deviation = 0.9991132 Iterations = 1
Deviance deviation = 0.001017535 Iterations = 2
Deviance deviation = 6.3549e-05 Iterations = 3
Deviance deviation = 1.173515e-06 Iterations = 4
Deviance deviation = 1.195021e-05 Iterations = 5
Deviance deviation = 1.530168e-05 Iterations = 6
Deviance deviation = 1.617554e-05 Iterations = 7
Deviance deviation = 1.578342e-05 Iterations = 8
Deviance deviation = 1.471047e-05 Iterations = 9
Deviance deviation = 1.330836e-05 Iterations = 10
Deviance deviation = 1.179385e-05 Iterations = 11
Deviance deviation = 1.029671e-05 Iterations = 12
Deviance deviation = 8.890071e-06 Iterations = 13
Deviance deviation = 7.610768e-06 Iterations = 14
Deviance deviation = 6.472902e-06 Iterations = 15
Deviance deviation = 5.476863e-06 Iterations = 16
Deviance deviation = 4.615211e-06 Iterations = 17
Deviance deviation = 3.876454e-06 Iterations = 18
Deviance deviation = 3.247422e-06 Iterations = 19
Deviance deviation = 2.714703e-06 Iterations = 20
Deviance deviation = 2.265471e-06 Iterations = 21
Deviance deviation = 1.88793e-06 Iterations = 22
Deviance deviation = 1.571506e-06 Iterations = 23
Deviance deviation = 1.30689e-06 Iterations = 24
Deviance deviation = 1.085995e-06 Iterations = 25
Deviance deviation = 9.018657e-07 Iterations = 26
Deviance deviation = 7.485662e-07 Iterations = 27
Deviance deviation = 6.210584e-07 Iterations = 28
Deviance deviation = 5.150877e-07 Iterations = 29
Deviance deviation = 4.270743e-07 Iterations = 30
Deviance deviation = 3.540146e-07 Iterations = 31
Deviance deviation = 2.933949e-07 Iterations = 32
Deviance deviation = 2.431155e-07 Iterations = 33
Deviance deviation = 2.014252e-07 Iterations = 34
Deviance deviation = 1.668653e-07 Iterations = 35
Deviance deviation = 1.382223e-07 Iterations = 36
Deviance deviation = 1.144872e-07 Iterations = 37
Deviance deviation = 9.482177e-08 Iterations = 38
Deviance deviation = 7.853013e-08 Iterations = 39
Deviance deviation = 6.503479e-08 Iterations = 40
Deviance deviation = 5.385667e-08 Iterations = 41
Deviance deviation = 4.459851e-08 Iterations = 42
Deviance deviation = 3.693095e-08 Iterations = 43
Deviance deviation = 3.0581e-08 Iterations = 44
Deviance deviation = 2.532244e-08 Iterations = 45
Deviance deviation = 2.096783e-08 Iterations = 46
Deviance deviation = 1.736186e-08 Iterations = 47
Deviance deviation = 1.437589e-08 Iterations = 48
Deviance deviation = 1.190337e-08 Iterations = 49
Deviance deviation = 9.856037e-09 Iterations = 50
Deviance deviation = 8.160791e-09 Iterations = 51
Deviance deviation = 6.757099e-09 Iterations = 52
Deviance deviation = 5.594827e-09 Iterations = 53
Deviance deviation = 4.63246e-09 Iterations = 54
Deviance deviation = 3.835621e-09 Iterations = 55
Deviance deviation = 3.17584e-09 Iterations = 56
Deviance deviation = 2.629547e-09 Iterations = 57
Deviance deviation = 2.177221e-09 Iterations = 58
Deviance deviation = 1.802701e-09 Iterations = 59
Deviance deviation = 1.492603e-09 Iterations = 60
Deviance deviation = 1.235847e-09 Iterations = 61
Deviance deviation = 1.023257e-09 Iterations = 62
Deviance deviation = 8.47236e-10 Iterations = 63
Deviance deviation = 7.014939e-10 Iterations = 64
Deviance deviation = 5.808224e-10 Iterations = 65
Deviance deviation = 4.809087e-10 Iterations = 66
Deviance deviation = 3.981822e-10 Iterations = 67
Deviance deviation = 3.296862e-10 Iterations = 68
Deviance deviation = 2.729731e-10 Iterations = 69
Deviance deviation = 2.260158e-10 Iterations = 70
Deviance deviation = 1.87136e-10 Iterations = 71
Deviance deviation = 1.549446e-10 Iterations = 72
Deviance deviation = 1.282906e-10 Iterations = 73
Deviance deviation = 1.062218e-10 Iterations = 74
Deviance deviation = 8.794948e-11 Iterations = 75
 75

Family: binomial
Link function: logit

 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 8.289316e-01 1.710684e-01 6.755730e-01 3.244270e-01 4.733534e-01
 9.999996e-01 5.125468e-01 5.125468e-01 3.485040e-01 9.999996e-01
 9.999996e-01 9.999996e-01 9.999996e-01 3.899821e-01 8.333737e-02
 2.572849e-01 5.498059e-02 1.235546e-01 8.546019e-02 5.266466e-01
 4.010612e-07 4.874532e-01 4.874532e-01 6.514960e-01 3.829282e-07
 3.829282e-07 3.829282e-07 3.829282e-07 3.708890e-01 1.557915e-01
 2.446885e-01 1.027812e-01 1.312500e-01 3.272513e-08 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
 1.000000e+00 1.000000e+00 1.000000e+00
 2.072329e-01 4.275410e-02 1.688933e-01 7.806193e-02 1.138958e-01
 2.389248e-01 1.281367e-01 1.281367e-01 8.709951e-02 2.389248e-01
 2.389248e-01 2.389248e-01 2.389248e-01 9.749552e-02 2.082801e-02
 6.432122e-02 1.374097e-02 2.972907e-02 2.041856e-02 1.277940e-01
 1.168046e-07 1.217981e-01 1.217981e-01 1.628687e-01 1.115235e-07
 1.115235e-07 1.115235e-07 1.115235e-07 9.267265e-02 3.894662e-02
 6.113941e-02 2.569446e-02 3.184862e-02 9.530824e-09 2.500000e-01
 2.500000e-01 2.500000e-01 2.500000e-01 2.500000e-01 2.500000e-01
 2.500000e-01 2.500000e-01 2.500000e-01 2.500000e-01 2.498663e-01
 2.498663e-01 2.498663e-01 2.498663e-01 2.498663e-01 2.498663e-01
 2.498663e-01 2.498663e-01 2.498663e-01 2.498663e-01 2.406148e-01
 2.406148e-01 2.406148e-01 2.406148e-01 2.406148e-01 2.406148e-01
 2.426561e-01 2.426561e-01 2.499919e-01 2.499919e-01 2.499919e-01
 2.499919e-01 2.499919e-01 2.499919e-01 2.499919e-01 2.499240e-01
 2.500000e-01 2.500000e-01 2.500000e-01 2.500000e-01 2.500000e-01
 2.500000e-01 2.500000e-01 2.500000e-01 2.500000e-01 2.498663e-01
 2.498663e-01 2.498663e-01 2.498663e-01 2.498663e-01 2.498663e-01
 2.498663e-01 2.498663e-01 2.498663e-01 2.498663e-01 2.406148e-01
 2.406148e-01 2.426561e-01 2.426561e-01 2.426561e-01 2.426561e-01
 2.426561e-01 2.426561e-01 2.426561e-01 2.499240e-01 2.499240e-01
 2.499240e-01 2.499919e-01 2.389249e-01
 0.5000000 0.5087168 0.5000000 0.5968771 0.5968771 0.6052384 0.5000000
 0.5000000 0.5087168 0.6052384 0.6052384 0.6052384 0.6052384 0.5000000
 0.5087168 0.5000000 0.5087168 0.5968771 0.6052384 0.5856966 0.5941321
 0.4884354 0.4884354 0.4971510 0.5941321 0.5941321 0.5941321 0.5941321
 0.4884354 0.4971510 0.4884354 0.4971510 0.5856966 0.5941321 0.5000000
 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000
 0.5000000 0.5000000 0.4884354 0.4884354 0.4884354 0.4884354 0.4884354
 0.4884354 0.4884354 0.4884354 0.4884354 0.4884354 0.5968771 0.5968771
 0.5968771 0.5968771 0.5968771 0.5968771 0.5856966 0.5856966 0.4971510
 0.4971510 0.4971510 0.4971510 0.4971510 0.4971510 0.4971510 0.5087168
 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000
 0.5000000 0.5000000 0.4884354 0.4884354 0.4884354 0.4884354 0.4884354
 0.4884354 0.4884354 0.4884354 0.4884354 0.4884354 0.5968771 0.5968771
 0.5856966 0.5856966 0.5856966 0.5856966 0.5856966 0.5856966 0.5856966
 0.5087168 0.5087168 0.5087168 0.4971510 0.6052384
x1       x2       x3
x1 4.596889 1.441787 2.113460
x2 1.441787 5.684824 2.238459
x3 2.113460 2.238459 9.506458
```

icdGLM documentation built on May 2, 2019, 9:16 a.m.