confintvglm: Confidence Intervals for Parameters of VGLMs

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/confint.vlm.R

Description

Computes confidence intervals (CIs) for one or more parameters in a fitted model. Currently the object must be a "vglm" object.

Usage

1
2
confintvglm(object, parm, level = 0.95, method = c("wald", "profile"),
            trace = NULL, ...)

Arguments

object

A fitted model object.

parm, level, ...

Same as confint.

method

Character. The default is the first method. Abbreviations are allowed. Currently "profile" is basically working; and it is likely to be more accurate especially for small samples, as it is based on a profile log likelihood, however it is computationally intensive.

trace

Logical. If TRUE then one can monitor the computation as it progresses (because it is expensive). The default is the orginal model's trace value (see vglm.control). Setting FALSE suppresses all intermediate output.

Details

The default for this methods function is based on confint.default and assumes asymptotic normality. In particular, the coef and vcov methods functions are used for vglm-class objects.

When method = "profile" the function profilevglm is called to do the profiling. The code is very heavily based on profile.glm which was originally written by D. M. Bates and W. N. Venables (For S in 1996) and subsequently corrected by B. D. Ripley. Sometimes the profiling method can give problems, for example, cumulative requires the M linear predictors not to intersect in the data cloud. Such numerical problems are less common when method = "wald", however, it is well-known that inference based on profile likelihoods is generally more accurate than Wald, especially when the sample size is small. The deviance (deviance(object)) is used if possible, else the difference 2 * (logLik(object) - ell) is computed, where ell are the values of the loglikelihood on a grid.

For Wald CIs and rrvglm-class objects, currently an error message is produced because I haven't gotten around to write the methods function; it's not too hard, but am too busy! An interim measure is to coerce the object into a "vglm" object, but then the confidence intervals will tend to be too narrow because the estimated constraint matrices are treated as known.

For Wald CIs and vgam-class objects, currently an error message is produced because the theory is undeveloped.

Value

Same as confint.

Note

The order of the values of argument method may change in the future without notice. The functions plot.profile.glm and pairs.profile.glm from MASS appear to work with output from this function.

Author(s)

Thomas Yee adapted confint.lm to handle "vglm" objects, for Wald-type confidence intervals. Also, profile.glm was originally written by D. M. Bates and W. N. Venables (For S in 1996) and subsequently corrected by B. D. Ripley. This function effectively calls confint.profile.glm() in MASS.

See Also

vcovvlm, summaryvglm, confint, profile.glm, lrt.stat.vlm, wald.stat, plot.profile.glm, pairs.profile.glm.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Example 1: this is based on a glm example
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3, 1, 9); treatment <- gl(3, 3)
 glm.D93 <-  glm(counts ~ outcome + treatment, family = poisson())
vglm.D93 <- vglm(counts ~ outcome + treatment, family = poissonff)
confint(glm.D93) # needs MASS to be present on the system
confint.default(glm.D93)  # based on asymptotic normality
confint(vglm.D93)
confint(vglm.D93) - confint(glm.D93)    # Should be all 0s
confint(vglm.D93) - confint.default(glm.D93)  # based on asympt. normality

# Example 2: simulated negative binomial data with multiple responses
ndata <- data.frame(x2 = runif(nn <- 100))
ndata <- transform(ndata, y1 = rnbinom(nn, mu = exp(3+x2), size = exp(1)),
                          y2 = rnbinom(nn, mu = exp(2-x2), size = exp(0)))
fit1 <- vglm(cbind(y1, y2) ~ x2, negbinomial, data = ndata, trace = TRUE)
coef(fit1)
coef(fit1, matrix = TRUE)
confint(fit1)
confint(fit1, "x2:1")  #  This might be improved to "x2" some day...
## Not run: 
confint(fit1, method = "profile")  # Computationally expensive
confint(fit1, "x2:1", method = "profile", trace = FALSE)

## End(Not run)

fit2 <- rrvglm(y1 ~ x2, negbinomial(zero = NULL), data = ndata)
confint(as(fit2, "vglm"))  # Too narrow (SEs are biased downwards)

Example output

Loading required package: stats4
Loading required package: splines
Waiting for profiling to be done...
                 2.5 %      97.5 %
(Intercept)  2.6958215  3.36655581
outcome2    -0.8577018 -0.06255840
outcome3    -0.6753696  0.08244089
treatment2  -0.3932548  0.39325483
treatment3  -0.3932548  0.39325483
                 2.5 %      97.5 %
(Intercept)  2.7095672  3.37947764
outcome2    -0.8505027 -0.05800787
outcome3    -0.6707552  0.08478093
treatment2  -0.3919928  0.39199279
treatment3  -0.3919928  0.39199279
                 2.5 %      97.5 %
(Intercept)  2.7095672  3.37947764
outcome2    -0.8505027 -0.05800787
outcome3    -0.6707552  0.08478093
treatment2  -0.3919928  0.39199279
treatment3  -0.3919928  0.39199279
Waiting for profiling to be done...
                  2.5 %       97.5 %
(Intercept) 0.013745734  0.012921826
outcome2    0.007199164  0.004550529
outcome3    0.004614421  0.002340033
treatment2  0.001262037 -0.001262037
treatment3  0.001262036 -0.001262036
                   2.5 %        97.5 %
(Intercept) 9.864554e-12 -9.863665e-12
outcome2    3.233234e-10 -3.233244e-10
outcome3    1.765685e-10 -1.765695e-10
treatment2  2.162410e-10 -2.162420e-10
treatment3  1.785770e-10 -1.785785e-10
VGLM    linear loop  1 :  loglikelihood = -684.91405
VGLM    linear loop  2 :  loglikelihood = -683.68621
VGLM    linear loop  3 :  loglikelihood = -683.67436
VGLM    linear loop  4 :  loglikelihood = -683.67435
VGLM    linear loop  5 :  loglikelihood = -683.67435
(Intercept):1 (Intercept):2 (Intercept):3 (Intercept):4          x2:1 
   3.10985777    1.22080362    2.02740368    0.02959234    0.71247900 
         x2:2 
  -1.03074641 
            loge(mu1) loge(size1) loge(mu2) loge(size2)
(Intercept)  3.109858    1.220804  2.027404  0.02959234
x2           0.712479    0.000000 -1.030746  0.00000000
                   2.5 %     97.5 %
(Intercept):1  2.8768436  3.3428720
(Intercept):2  0.9204419  1.5211653
(Intercept):3  1.5937575  2.4610498
(Intercept):4 -0.3344606  0.3936453
x2:1           0.3186671  1.1062909
x2:2          -1.7878397 -0.2736532
         2.5 %   97.5 %
x2:1 0.3186671 1.106291
VGLM    linear loop  1 :  loglikelihood = -683.79937
VGLM    linear loop  2 :  loglikelihood = -683.7992
VGLM    linear loop  3 :  loglikelihood = -683.7992
VGLM    linear loop  1 :  loglikelihood = -684.17777
VGLM    linear loop  2 :  loglikelihood = -684.17638
VGLM    linear loop  3 :  loglikelihood = -684.17638
VGLM    linear loop  1 :  loglikelihood = -684.811
VGLM    linear loop  2 :  loglikelihood = -684.80716
VGLM    linear loop  3 :  loglikelihood = -684.80716
VGLM    linear loop  1 :  loglikelihood = -685.69684
VGLM    linear loop  2 :  loglikelihood = -685.68943
VGLM    linear loop  3 :  loglikelihood = -685.68943
VGLM    linear loop  1 :  loglikelihood = -686.82983
VGLM    linear loop  2 :  loglikelihood = -686.81785
VGLM    linear loop  3 :  loglikelihood = -686.81785
VGLM    linear loop  1 :  loglikelihood = -683.79717
VGLM    linear loop  2 :  loglikelihood = -683.79704
VGLM    linear loop  3 :  loglikelihood = -683.79704
VGLM    linear loop  1 :  loglikelihood = -684.16037
VGLM    linear loop  2 :  loglikelihood = -684.15911
VGLM    linear loop  3 :  loglikelihood = -684.15911
VGLM    linear loop  1 :  loglikelihood = -684.75277
VGLM    linear loop  2 :  loglikelihood = -684.74935
VGLM    linear loop  3 :  loglikelihood = -684.74935
VGLM    linear loop  1 :  loglikelihood = -685.56033
VGLM    linear loop  2 :  loglikelihood = -685.55391
VGLM    linear loop  3 :  loglikelihood = -685.55391
VGLM    linear loop  1 :  loglikelihood = -686.56693
VGLM    linear loop  2 :  loglikelihood = -686.55688
VGLM    linear loop  3 :  loglikelihood = -686.55688
VGLM    linear loop  1 :  loglikelihood = -687.75497
VGLM    linear loop  2 :  loglikelihood = -687.74088
VGLM    linear loop  3 :  loglikelihood = -687.74088
VGLM    linear loop  1 :  loglikelihood = -683.79576
VGLM    linear loop  2 :  loglikelihood = -683.79576
VGLM    linear loop  1 :  loglikelihood = -684.15475
VGLM    linear loop  2 :  loglikelihood = -684.15475
VGLM    linear loop  1 :  loglikelihood = -684.74339
VGLM    linear loop  2 :  loglikelihood = -684.74339
VGLM    linear loop  1 :  loglikelihood = -685.55379
VGLM    linear loop  2 :  loglikelihood = -685.55379
VGLM    linear loop  1 :  loglikelihood = -686.57808
VGLM    linear loop  2 :  loglikelihood = -686.57808
VGLM    linear loop  1 :  loglikelihood = -687.80855
VGLM    linear loop  2 :  loglikelihood = -687.80855
VGLM    linear loop  1 :  loglikelihood = -683.79835
VGLM    linear loop  2 :  loglikelihood = -683.79835
VGLM    linear loop  1 :  loglikelihood = -684.17542
VGLM    linear loop  2 :  loglikelihood = -684.17542
VGLM    linear loop  1 :  loglikelihood = -684.81296
VGLM    linear loop  2 :  loglikelihood = -684.81296
VGLM    linear loop  1 :  loglikelihood = -685.71805
VGLM    linear loop  2 :  loglikelihood = -685.71805
VGLM    linear loop  1 :  loglikelihood = -686.89726
VGLM    linear loop  2 :  loglikelihood = -686.89726
VGLM    linear loop  1 :  loglikelihood = -683.81181
VGLM    linear loop  2 :  loglikelihood = -683.81136
VGLM    linear loop  3 :  loglikelihood = -683.81136
VGLM    linear loop  1 :  loglikelihood = -684.23142
VGLM    linear loop  2 :  loglikelihood = -684.22918
VGLM    linear loop  3 :  loglikelihood = -684.22917
VGLM    linear loop  4 :  loglikelihood = -684.22917
VGLM    linear loop  1 :  loglikelihood = -684.94001
VGLM    linear loop  2 :  loglikelihood = -684.93415
VGLM    linear loop  3 :  loglikelihood = -684.93409
VGLM    linear loop  4 :  loglikelihood = -684.93409
VGLM    linear loop  1 :  loglikelihood = -685.93875
VGLM    linear loop  2 :  loglikelihood = -685.92766
VGLM    linear loop  3 :  loglikelihood = -685.92748
VGLM    linear loop  4 :  loglikelihood = -685.92748
VGLM    linear loop  1 :  loglikelihood = -687.22418
VGLM    linear loop  2 :  loglikelihood = -687.2066
VGLM    linear loop  3 :  loglikelihood = -687.20615
VGLM    linear loop  4 :  loglikelihood = -687.20614
VGLM    linear loop  5 :  loglikelihood = -687.20614
VGLM    linear loop  1 :  loglikelihood = -683.80721
VGLM    linear loop  2 :  loglikelihood = -683.80677
VGLM    linear loop  3 :  loglikelihood = -683.80677
VGLM    linear loop  1 :  loglikelihood = -684.19475
VGLM    linear loop  2 :  loglikelihood = -684.19256
VGLM    linear loop  3 :  loglikelihood = -684.19256
VGLM    linear loop  1 :  loglikelihood = -684.81705
VGLM    linear loop  2 :  loglikelihood = -684.81172
VGLM    linear loop  3 :  loglikelihood = -684.81172
VGLM    linear loop  1 :  loglikelihood = -685.65085
VGLM    linear loop  2 :  loglikelihood = -685.64136
VGLM    linear loop  3 :  loglikelihood = -685.64136
VGLM    linear loop  1 :  loglikelihood = -686.67116
VGLM    linear loop  2 :  loglikelihood = -686.65697
VGLM    linear loop  3 :  loglikelihood = -686.65697
VGLM    linear loop  1 :  loglikelihood = -687.85261
VGLM    linear loop  2 :  loglikelihood = -687.83357
VGLM    linear loop  3 :  loglikelihood = -687.83357
VGLM    linear loop  1 :  loglikelihood = -683.80309
VGLM    linear loop  2 :  loglikelihood = -683.80308
VGLM    linear loop  3 :  loglikelihood = -683.80308
VGLM    linear loop  1 :  loglikelihood = -684.18973
VGLM    linear loop  2 :  loglikelihood = -684.18972
VGLM    linear loop  3 :  loglikelihood = -684.18972
VGLM    linear loop  1 :  loglikelihood = -684.83433
VGLM    linear loop  2 :  loglikelihood = -684.83433
VGLM    linear loop  1 :  loglikelihood = -685.73613
VGLM    linear loop  2 :  loglikelihood = -685.73613
VGLM    linear loop  1 :  loglikelihood = -686.89363
VGLM    linear loop  2 :  loglikelihood = -686.89362
VGLM    linear loop  1 :  loglikelihood = -683.80264
VGLM    linear loop  2 :  loglikelihood = -683.80262
VGLM    linear loop  3 :  loglikelihood = -683.80262
VGLM    linear loop  1 :  loglikelihood = -684.18607
VGLM    linear loop  2 :  loglikelihood = -684.18605
VGLM    linear loop  3 :  loglikelihood = -684.18605
VGLM    linear loop  1 :  loglikelihood = -684.82182
VGLM    linear loop  2 :  loglikelihood = -684.8218
VGLM    linear loop  3 :  loglikelihood = -684.8218
VGLM    linear loop  1 :  loglikelihood = -685.70601
VGLM    linear loop  2 :  loglikelihood = -685.70599
VGLM    linear loop  3 :  loglikelihood = -685.70599
VGLM    linear loop  1 :  loglikelihood = -686.83366
VGLM    linear loop  2 :  loglikelihood = -686.83364
VGLM    linear loop  3 :  loglikelihood = -686.83364
VGLM    linear loop  1 :  loglikelihood = -683.79804
VGLM    linear loop  2 :  loglikelihood = -683.79788
VGLM    linear loop  3 :  loglikelihood = -683.79788
VGLM    linear loop  1 :  loglikelihood = -684.16829
VGLM    linear loop  2 :  loglikelihood = -684.16681
VGLM    linear loop  3 :  loglikelihood = -684.16681
VGLM    linear loop  1 :  loglikelihood = -684.78001
VGLM    linear loop  2 :  loglikelihood = -684.77591
VGLM    linear loop  3 :  loglikelihood = -684.77591
VGLM    linear loop  1 :  loglikelihood = -685.62439
VGLM    linear loop  2 :  loglikelihood = -685.61655
VGLM    linear loop  3 :  loglikelihood = -685.61655
VGLM    linear loop  1 :  loglikelihood = -686.68961
VGLM    linear loop  2 :  loglikelihood = -686.67708
VGLM    linear loop  3 :  loglikelihood = -686.67708
VGLM    linear loop  1 :  loglikelihood = -687.96133
VGLM    linear loop  2 :  loglikelihood = -687.94342
VGLM    linear loop  3 :  loglikelihood = -687.94342
VGLM    linear loop  1 :  loglikelihood = -683.79793
VGLM    linear loop  2 :  loglikelihood = -683.79777
VGLM    linear loop  3 :  loglikelihood = -683.79777
VGLM    linear loop  1 :  loglikelihood = -684.16741
VGLM    linear loop  2 :  loglikelihood = -684.16591
VGLM    linear loop  3 :  loglikelihood = -684.16591
VGLM    linear loop  1 :  loglikelihood = -684.77705
VGLM    linear loop  2 :  loglikelihood = -684.77297
VGLM    linear loop  3 :  loglikelihood = -684.77297
VGLM    linear loop  1 :  loglikelihood = -685.61756
VGLM    linear loop  2 :  loglikelihood = -685.60981
VGLM    linear loop  3 :  loglikelihood = -685.6098
VGLM    linear loop  1 :  loglikelihood = -686.67678
VGLM    linear loop  2 :  loglikelihood = -686.66447
VGLM    linear loop  3 :  loglikelihood = -686.66447
VGLM    linear loop  1 :  loglikelihood = -687.94025
VGLM    linear loop  2 :  loglikelihood = -687.92274
VGLM    linear loop  3 :  loglikelihood = -687.92274
VGLM    linear loop  1 :  loglikelihood = -683.81171
VGLM    linear loop  2 :  loglikelihood = -683.81157
VGLM    linear loop  3 :  loglikelihood = -683.81157
VGLM    linear loop  1 :  loglikelihood = -684.22125
VGLM    linear loop  2 :  loglikelihood = -684.21935
VGLM    linear loop  3 :  loglikelihood = -684.21934
VGLM    linear loop  1 :  loglikelihood = -684.89363
VGLM    linear loop  2 :  loglikelihood = -684.88804
VGLM    linear loop  3 :  loglikelihood = -684.88803
VGLM    linear loop  4 :  loglikelihood = -684.88803
VGLM    linear loop  1 :  loglikelihood = -685.81433
VGLM    linear loop  2 :  loglikelihood = -685.80347
VGLM    linear loop  3 :  loglikelihood = -685.80345
VGLM    linear loop  4 :  loglikelihood = -685.80345
VGLM    linear loop  1 :  loglikelihood = -686.96513
VGLM    linear loop  2 :  loglikelihood = -686.94779
VGLM    linear loop  3 :  loglikelihood = -686.94773
VGLM    linear loop  4 :  loglikelihood = -686.94773
VGLM    linear loop  1 :  loglikelihood = -683.81248
VGLM    linear loop  2 :  loglikelihood = -683.81211
VGLM    linear loop  3 :  loglikelihood = -683.81211
VGLM    linear loop  1 :  loglikelihood = -684.22639
VGLM    linear loop  2 :  loglikelihood = -684.22368
VGLM    linear loop  3 :  loglikelihood = -684.22367
VGLM    linear loop  1 :  loglikelihood = -684.90946
VGLM    linear loop  2 :  loglikelihood = -684.90235
VGLM    linear loop  3 :  loglikelihood = -684.90234
VGLM    linear loop  4 :  loglikelihood = -684.90234
VGLM    linear loop  1 :  loglikelihood = -685.84957
VGLM    linear loop  2 :  loglikelihood = -685.83624
VGLM    linear loop  3 :  loglikelihood = -685.83621
VGLM    linear loop  4 :  loglikelihood = -685.83621
VGLM    linear loop  1 :  loglikelihood = -687.02999
VGLM    linear loop  2 :  loglikelihood = -687.009
VGLM    linear loop  3 :  loglikelihood = -687.00893
VGLM    linear loop  4 :  loglikelihood = -687.00893
                   2.5 %     97.5 %
(Intercept):1  2.8779314  3.3501085
(Intercept):2  0.9111571  1.5178243
(Intercept):3  1.6189045  2.4640019
(Intercept):4 -0.3286271  0.3903861
x2:1           0.3132423  1.1124221
x2:2          -1.7627830 -0.3041432
    2.5 %    97.5 % 
0.3132423 1.1124221 
                  2.5 %   97.5 %
(Intercept):1 2.8731757 3.349774
(Intercept):2 0.7339106 1.363785
x2            0.3218983 1.096921

VGAM documentation built on Jan. 16, 2021, 5:21 p.m.