Description Usage Format Details Source References Examples
German health registry for the year 1984.
1 |
A data frame with 3,874 observations on the following 17 variables.
docvis
number of visits to doctor during year (0-121)
hospvis
number of days in hospital during year (0-51)
edlevel
educational level (categorical: 1-4)
age
age: 25-64
outwork
out of work=1; 0=working
female
female=1; 0=male
married
married=1; 0=not married
kids
have children=1; no children=0
hhninc
household yearly income in marks (in Marks)
educ
years of formal education (7-18)
self
self-employed=1; not self employed=0
edlevel1
(1/0) not high school graduate
edlevel2
(1/0) high school graduate
edlevel3
(1/0) university/college
edlevel4
(1/0) graduate school
rwm1984 is saved as a data frame. Count models typically use docvis as response variable. 0 counts are included
German Health Reform Registry, year=1984, in Hilbe and Greene (2007)
Hilbe, Joseph, M (2014), Modeling Count Data, Cambridge University Press Hilbe, Joseph M (2011), Negative Binomial Regression, Cambridge University Press Hilbe, J. and W. Greene (2008). Count Response Regression Models, in ed. C.R. Rao, J.P Miller, and D.C. Rao, Epidemiology and Medical Statistics, Elsevier Handbook of Statistics Series. London, UK: Elsevier.
1 2 3 4 5 6 7 8 9 10 11 12 13 | library(MASS)
library(msme)
data(rwm1984)
glmrp <- glm(docvis ~ outwork + female + age + factor(edlevel), family=poisson, data=rwm1984)
summary(glmrp)
exp(coef(glmrp))
summary(nb2 <- nbinomial(docvis ~ outwork + female + age + factor(edlevel), data=rwm1984))
exp(coef(nb2))
summary(glmrnb <- glm.nb(docvis ~ outwork + female + age + factor(edlevel), data=rwm1984))
exp(coef(glmrnb))
|
Loading required package: msme
Loading required package: MASS
Loading required package: lattice
Loading required package: sandwich
Call:
glm(formula = docvis ~ outwork + female + age + factor(edlevel),
family = poisson, data = rwm1984)
Deviance Residuals:
Min 1Q Median 3Q Max
-3.5746 -2.1973 -1.2704 0.3265 26.0734
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.085762 0.041688 -2.057 0.0397 *
outwork 0.258678 0.021532 12.013 < 2e-16 ***
female 0.273051 0.021185 12.889 < 2e-16 ***
age 0.022010 0.000851 25.863 < 2e-16 ***
factor(edlevel)2 -0.068450 0.042271 -1.619 0.1054
factor(edlevel)3 -0.172508 0.039740 -4.341 1.42e-05 ***
factor(edlevel)4 -0.251967 0.048019 -5.247 1.54e-07 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 25791 on 3873 degrees of freedom
Residual deviance: 23957 on 3867 degrees of freedom
AIC: 31053
Number of Fisher Scoring iterations: 6
(Intercept) outwork female age
0.9178130 1.2952162 1.3139678 1.0222535
factor(edlevel)2 factor(edlevel)3 factor(edlevel)4
0.9338402 0.8415515 0.7772701
Call:
nbinomial(formula1 = docvis ~ outwork + female + age + factor(edlevel),
data = rwm1984)
Deviance Residuals:
Min. 1st Qu. Median Mean 3rd Qu. Max.
-1.5676 -1.2638 -0.4750 -0.4535 0.1200 5.7030
Pearson Residuals:
Min. 1st Qu. Median Mean 3rd Qu. Max.
-0.6444 -0.6082 -0.3688 -0.0002 0.1273 26.9409
Coefficients (all in linear predictor):
Estimate SE Z p LCL UCL
(Intercept) -0.1184 0.11089 -1.067 0.286 -0.3357 0.0990
outwork 0.2759 0.05949 4.639 3.51e-06 0.1593 0.3925
female 0.3252 0.05631 5.775 7.7e-09 0.2148 0.4356
age 0.0221 0.00237 9.322 1.14e-20 0.0174 0.0267
factor(edlevel)2 -0.1136 0.11822 -0.961 0.337 -0.3453 0.1181
factor(edlevel)3 -0.1758 0.10204 -1.723 0.085 -0.3758 0.0242
factor(edlevel)4 -0.3253 0.11491 -2.831 0.00465 -0.5505 -0.1000
(Intercept)_s 2.2582 0.07007 32.228 7.06e-228 2.1208 2.3955
Null deviance: 4148.15 on 3872 d.f.
Residual deviance: 3909.534 on 3866 d.f.
Null Pearson: 5923.495 on 3872 d.f.
Residual Pearson: 5703.044 on 3866 d.f.
Dispersion: 1.475179
AIC: 16637.37
Number of optimizer iterations: 84
Warning messages:
1: In dnbinom(y, size = scale, mu = y.hat, log = TRUE) : NaNs produced
2: In dnbinom(y, size = scale, mu = y.hat, log = TRUE) : NaNs produced
3: In dnbinom(y, size = scale, mu = y.hat, log = TRUE) : NaNs produced
4: In dnbinom(y, size = scale, mu = y.hat, log = TRUE) : NaNs produced
5: In dnbinom(y, size = scale, mu = y.hat, log = TRUE) : NaNs produced
6: In dnbinom(y, size = scale, mu = y.hat, log = TRUE) : NaNs produced
7: In dnbinom(y, size = scale, mu = y.hat, log = TRUE) : NaNs produced
(Intercept) outwork female age
0.8883717 1.3177478 1.3843133 1.0223234
factor(edlevel)2 factor(edlevel)3 factor(edlevel)4 (Intercept)_s
0.8926237 0.8388077 0.7223425 9.5654586
Call:
glm.nb(formula = docvis ~ outwork + female + age + factor(edlevel),
data = rwm1984, init.theta = 0.442880598, link = log)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.5672 -1.2639 -0.4748 0.1198 5.6998
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.113599 0.111888 -1.015 0.30997
outwork 0.276468 0.062895 4.396 1.10e-05 ***
female 0.325059 0.059812 5.435 5.49e-08 ***
age 0.021969 0.002404 9.138 < 2e-16 ***
factor(edlevel)2 -0.114024 0.118122 -0.965 0.33439
factor(edlevel)3 -0.176290 0.102102 -1.727 0.08424 .
factor(edlevel)4 -0.325601 0.115847 -2.811 0.00494 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for Negative Binomial(0.4429) family taken to be 1)
Null deviance: 4148.4 on 3873 degrees of freedom
Residual deviance: 3909.8 on 3867 degrees of freedom
AIC: 16637
Number of Fisher Scoring iterations: 1
Theta: 0.4429
Std. Err.: 0.0137
2 x log-likelihood: -16621.3670
(Intercept) outwork female age
0.8926162 1.3184649 1.3841121 1.0222123
factor(edlevel)2 factor(edlevel)3 factor(edlevel)4
0.8922363 0.8383752 0.7220934
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.