initial: Initial Parameter Generator for GLARMA from GLM

Description Usage Arguments Details Value Author(s) Examples

Description

Function used to generate initial values of parameters for the GLARMA model from glm or glm.nb.

Usage

1
initial(y, X, offset = NULL, type = "Poi", alpha = 1)

Arguments

y

Numeric vector; response variable.

X

Matrix; explanatory variables. A vector of ones should be added to the data matrix as the first column for the beta of the intercept.

offset

Either NULL or a numeric vector of length equal to the number of cases. Used to specify an a priori known component to be included in the linear predictor during fitting.

type

Character; the distribution of the counts.

alpha

Numeric; an optional initial value for the theta parameter in the negative binomial distribution; the default value is 1.

Details

Generates and returns the initial parameters for the GLARMA model under the specified distribution by fitting a generalized linear model.

Value

beta

A named numeric vector of initial coefficients.

y

If requested, the y vector used.

X

If requested, the model matrix.

alpha

The theta parameter in the negative binomial distribution returned by glm.nb. NULL if any other distribution is used.

type

The distribution of the counts in the GLARMA model.

null.deviance

Null deviance of the GLM with the same regression structure as the GLARMA model.

df.null

Null degrees of freedom of the GLM with the same regression structure as the GLARMA model.

Author(s)

"William T.M. Dunsmuir" <w.dunsmuir@unsw.edu.au>

Examples

1
2
3
4
5
6
7
8
### Using the polio data
data(Polio)
y <- Polio[, 2]
X <- as.matrix(Polio[, 3:8])

glmMod <- initial(y, X, type = "Poi", alpha=1)
str(glmMod)
head(glmMod)

Example output

List of 7
 $ beta         : Named num [1:6] 0.207 -4.799 -0.149 -0.532 0.169 ...
  ..- attr(*, "names")= chr [1:6] "XIntcpt" "XTrend" "XCosAnnual" "XSinAnnual" ...
 $ y            : int [1:168] 0 1 0 0 1 3 9 2 3 5 ...
 $ X            : num [1:168, 1:6] 1 1 1 1 1 1 1 1 1 1 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : NULL
  .. ..$ : chr [1:6] "Intcpt" "Trend" "CosAnnual" "SinAnnual" ...
 $ alpha        : NULL
 $ type         : chr "Poi"
 $ null.deviance: num 343
 $ df.null      : int 167
$beta
       XIntcpt         XTrend     XCosAnnual     XSinAnnual XCosSemiAnnual 
     0.2069383     -4.7986615     -0.1487333     -0.5318768      0.1690998 
XSinSemiAnnual 
    -0.4321435 

$y
  [1]  0  1  0  0  1  3  9  2  3  5  3  5  2  2  0  1  0  1  3  3  2  1  1  5  0
 [26]  3  1  0  1  4  0  0  1  6 14  1  1  0  0  1  1  1  1  0  1  0  1  0  1  0
 [51]  1  0  1  0  1  0  1  0  0  2  0  1  0  1  0  0  1  2  0  0  1  2  0  3  1
 [76]  1  0  2  0  4  0  2  1  1  1  1  0  1  1  0  2  1  3  1  2  4  0  0  0  1
[101]  0  1  0  2  2  4  2  3  3  0  0  2  7  8  2  4  1  1  2  4  0  1  1  1  3
[126]  0  0  0  0  1  0  1  1  0  0  0  0  0  1  2  0  2  0  0  0  1  0  1  0  1
[151]  0  2  0  0  1  2  0  1  0  0  0  1  2  1  0  1  3  6

$X
       Intcpt  Trend     CosAnnual     SinAnnual CosSemiAnnual SinSemiAnnual
  [1,]      1 -0.072  1.000000e+00  1.469528e-15           1.0  2.939055e-15
  [2,]      1 -0.071  8.660254e-01  5.000000e-01           0.5  8.660254e-01
  [3,]      1 -0.070  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
  [4,]      1 -0.069 -3.184654e-15  1.000000e+00          -1.0 -6.369308e-15
  [5,]      1 -0.068 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
  [6,]      1 -0.067 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
  [7,]      1 -0.066 -1.000000e+00  2.205647e-15           1.0 -4.411293e-15
  [8,]      1 -0.065 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
  [9,]      1 -0.064 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
 [10,]      1 -0.063 -4.905202e-16 -1.000000e+00          -1.0  9.810403e-16
 [11,]      1 -0.062  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
 [12,]      1 -0.061  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
 [13,]      1 -0.060  1.000000e+00  4.777320e-15           1.0  9.554640e-15
 [14,]      1 -0.059  8.660254e-01  5.000000e-01           0.5  8.660254e-01
 [15,]      1 -0.058  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
 [16,]      1 -0.057 -2.939733e-15  1.000000e+00          -1.0 -5.879466e-15
 [17,]      1 -0.056 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
 [18,]      1 -0.055 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
 [19,]      1 -0.054 -1.000000e+00 -1.102146e-15           1.0  2.204291e-15
 [20,]      1 -0.053 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
 [21,]      1 -0.052 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
 [22,]      1 -0.051  2.817272e-15 -1.000000e+00          -1.0 -5.634544e-15
 [23,]      1 -0.050  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
 [24,]      1 -0.049  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
 [25,]      1 -0.048  1.000000e+00  9.796851e-16           1.0  1.959370e-15
 [26,]      1 -0.047  8.660254e-01  5.000000e-01           0.5  8.660254e-01
 [27,]      1 -0.046  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
 [28,]      1 -0.045  8.579021e-16  1.000000e+00          -1.0  1.715804e-15
 [29,]      1 -0.044 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
 [30,]      1 -0.043 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
 [31,]      1 -0.042 -1.000000e+00 -8.572244e-16           1.0  1.714449e-15
 [32,]      1 -0.041 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
 [33,]      1 -0.040 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
 [34,]      1 -0.039  2.572351e-15 -1.000000e+00          -1.0 -5.144702e-15
 [35,]      1 -0.038  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
 [36,]      1 -0.037  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
 [37,]      1 -0.036  1.000000e+00  7.347638e-16           1.0  1.469528e-15
 [38,]      1 -0.035  8.660254e-01  5.000000e-01           0.5  8.660254e-01
 [39,]      1 -0.034  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
 [40,]      1 -0.033  1.102823e-15  1.000000e+00          -1.0  2.205647e-15
 [41,]      1 -0.032 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
 [42,]      1 -0.031 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
 [43,]      1 -0.030 -1.000000e+00 -2.388660e-15           1.0  4.777320e-15
 [44,]      1 -0.029 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
 [45,]      1 -0.028 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
 [46,]      1 -0.027  5.510729e-16 -1.000000e+00          -1.0 -1.102146e-15
 [47,]      1 -0.026  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
 [48,]      1 -0.025  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
 [49,]      1 -0.024  1.000000e+00  4.898425e-16           1.0  9.796851e-16
 [50,]      1 -0.023  8.660254e-01  5.000000e-01           0.5  8.660254e-01
 [51,]      1 -0.022  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
 [52,]      1 -0.021 -4.286122e-16  1.000000e+00          -1.0 -8.572244e-16
 [53,]      1 -0.020 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
 [54,]      1 -0.019 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
 [55,]      1 -0.018 -1.000000e+00 -3.673819e-16           1.0  7.347638e-16
 [56,]      1 -0.017 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
 [57,]      1 -0.016 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
 [58,]      1 -0.015  1.194330e-15 -1.000000e+00          -1.0 -2.388660e-15
 [59,]      1 -0.014  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
 [60,]      1 -0.013  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
 [61,]      1 -0.012  1.000000e+00  2.449213e-16           1.0  4.898425e-16
 [62,]      1 -0.011  8.660254e-01  5.000000e-01           0.5  8.660254e-01
 [63,]      1 -0.010  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
 [64,]      1 -0.009 -1.836910e-16  1.000000e+00          -1.0 -3.673819e-16
 [65,]      1 -0.008 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
 [66,]      1 -0.007 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
 [67,]      1 -0.006 -1.000000e+00 -1.224606e-16           1.0  2.449213e-16
 [68,]      1 -0.005 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
 [69,]      1 -0.004 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
 [70,]      1 -0.003  6.123032e-17 -1.000000e+00          -1.0 -1.224606e-16
 [71,]      1 -0.002  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
 [72,]      1 -0.001  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
 [73,]      1  0.000  1.000000e+00  0.000000e+00           1.0  0.000000e+00
 [74,]      1  0.001  8.660254e-01  5.000000e-01           0.5  8.660254e-01
 [75,]      1  0.002  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
 [76,]      1  0.003  6.123032e-17  1.000000e+00          -1.0  1.224606e-16
 [77,]      1  0.004 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
 [78,]      1  0.005 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
 [79,]      1  0.006 -1.000000e+00  1.224606e-16           1.0 -2.449213e-16
 [80,]      1  0.007 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
 [81,]      1  0.008 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
 [82,]      1  0.009 -1.836910e-16 -1.000000e+00          -1.0  3.673819e-16
 [83,]      1  0.010  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
 [84,]      1  0.011  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
 [85,]      1  0.012  1.000000e+00 -2.449213e-16           1.0 -4.898425e-16
 [86,]      1  0.013  8.660254e-01  5.000000e-01           0.5  8.660254e-01
 [87,]      1  0.014  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
 [88,]      1  0.015  1.194330e-15  1.000000e+00          -1.0  2.388660e-15
 [89,]      1  0.016 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
 [90,]      1  0.017 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
 [91,]      1  0.018 -1.000000e+00  3.673819e-16           1.0 -7.347638e-16
 [92,]      1  0.019 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
 [93,]      1  0.020 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
 [94,]      1  0.021 -4.286122e-16 -1.000000e+00          -1.0  8.572244e-16
 [95,]      1  0.022  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
 [96,]      1  0.023  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
 [97,]      1  0.024  1.000000e+00 -4.898425e-16           1.0 -9.796851e-16
 [98,]      1  0.025  8.660254e-01  5.000000e-01           0.5  8.660254e-01
 [99,]      1  0.026  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
[100,]      1  0.027  5.510729e-16  1.000000e+00          -1.0  1.102146e-15
[101,]      1  0.028 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
[102,]      1  0.029 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
[103,]      1  0.030 -1.000000e+00  2.388660e-15           1.0 -4.777320e-15
[104,]      1  0.031 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
[105,]      1  0.032 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
[106,]      1  0.033  1.102823e-15 -1.000000e+00          -1.0 -2.205647e-15
[107,]      1  0.034  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
[108,]      1  0.035  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
[109,]      1  0.036  1.000000e+00 -7.347638e-16           1.0 -1.469528e-15
[110,]      1  0.037  8.660254e-01  5.000000e-01           0.5  8.660254e-01
[111,]      1  0.038  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
[112,]      1  0.039  2.572351e-15  1.000000e+00          -1.0  5.144702e-15
[113,]      1  0.040 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
[114,]      1  0.041 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
[115,]      1  0.042 -1.000000e+00  8.572244e-16           1.0 -1.714449e-15
[116,]      1  0.043 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
[117,]      1  0.044 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
[118,]      1  0.045  8.579021e-16 -1.000000e+00          -1.0 -1.715804e-15
[119,]      1  0.046  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
[120,]      1  0.047  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
[121,]      1  0.048  1.000000e+00 -9.796851e-16           1.0 -1.959370e-15
[122,]      1  0.049  8.660254e-01  5.000000e-01           0.5  8.660254e-01
[123,]      1  0.050  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
[124,]      1  0.051  2.817272e-15  1.000000e+00          -1.0  5.634544e-15
[125,]      1  0.052 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
[126,]      1  0.053 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
[127,]      1  0.054 -1.000000e+00  1.102146e-15           1.0 -2.204291e-15
[128,]      1  0.055 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
[129,]      1  0.056 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
[130,]      1  0.057 -2.939733e-15 -1.000000e+00          -1.0  5.879466e-15
[131,]      1  0.058  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
[132,]      1  0.059  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
[133,]      1  0.060  1.000000e+00 -4.777320e-15           1.0 -9.554640e-15
[134,]      1  0.061  8.660254e-01  5.000000e-01           0.5  8.660254e-01
[135,]      1  0.062  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
[136,]      1  0.063 -4.905202e-16  1.000000e+00          -1.0 -9.810403e-16
[137,]      1  0.064 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
[138,]      1  0.065 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
[139,]      1  0.066 -1.000000e+00 -2.205647e-15           1.0  4.411293e-15
[140,]      1  0.067 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
[141,]      1  0.068 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
[142,]      1  0.069 -3.184654e-15 -1.000000e+00          -1.0  6.369308e-15
[143,]      1  0.070  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
[144,]      1  0.071  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
[145,]      1  0.072  1.000000e+00 -1.469528e-15           1.0 -2.939055e-15
[146,]      1  0.073  8.660254e-01  5.000000e-01           0.5  8.660254e-01
[147,]      1  0.074  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
[148,]      1  0.075 -2.455989e-16  1.000000e+00          -1.0 -4.911978e-16
[149,]      1  0.076 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
[150,]      1  0.077 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
[151,]      1  0.078 -1.000000e+00  5.144702e-15           1.0 -1.028940e-14
[152,]      1  0.079 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
[153,]      1  0.080 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
[154,]      1  0.081 -3.429575e-15 -1.000000e+00          -1.0  6.859151e-15
[155,]      1  0.082  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
[156,]      1  0.083  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01
[157,]      1  0.084  1.000000e+00 -1.714449e-15           1.0 -3.428898e-15
[158,]      1  0.085  8.660254e-01  5.000000e-01           0.5  8.660254e-01
[159,]      1  0.086  5.000000e-01  8.660254e-01          -0.5  8.660254e-01
[160,]      1  0.087  7.104750e-15  1.000000e+00          -1.0  1.420950e-14
[161,]      1  0.088 -5.000000e-01  8.660254e-01          -0.5 -8.660254e-01
[162,]      1  0.089 -8.660254e-01  5.000000e-01           0.5 -8.660254e-01
[163,]      1  0.090 -1.000000e+00 -1.715804e-15           1.0  3.431608e-15
[164,]      1  0.091 -8.660254e-01 -5.000000e-01           0.5  8.660254e-01
[165,]      1  0.092 -5.000000e-01 -8.660254e-01          -0.5  8.660254e-01
[166,]      1  0.093 -3.674497e-15 -1.000000e+00          -1.0  7.348993e-15
[167,]      1  0.094  5.000000e-01 -8.660254e-01          -0.5 -8.660254e-01
[168,]      1  0.095  8.660254e-01 -5.000000e-01           0.5 -8.660254e-01

$alpha
NULL

$type
[1] "Poi"

$null.deviance
[1] 343.0004

glarma documentation built on May 2, 2019, 6:33 a.m.