chdage: CHDAGE data

Description Usage Format Source Examples

Description

chdage dataset.

Usage

1

Format

A data.frame with 100 rows and 4 variables:

id

Identification code (1 - 100)

age

Age (Years)

agegrp

Age group (1: 20-39, 2: 30-34, 3: 35-39, 4: 40-44, 5: 45-49, 6: 50-54, 7: 55-59, 8: 60-69)

chd

Presence of CHD (1: No, 2: Yes)

Source

Hosmer, D.W., Lemeshow, S. and Sturdivant, R.X. (2013) Applied Logistic Regression, 3rd ed., New York: Wiley

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
29
30
31
32
33
head(chdage,  n = 10)
summary(chdage)

## Figure 1.1 p. 5
plot(as.integer(chd)-1 ~ age,
     pch = 20,
     main = "Figure 1.1 p. 5",
     ylab = "Coronary heart disease",
     xlab = "Age (years)",
     data = chdage)

## Table 1.2
with(chdage, addmargins(table(agegrp)))
with(chdage, addmargins(table(agegrp, chd)))
(Means <- with(chdage, tapply(as.integer(chd)-1, list(agegrp), mean)))

## Figure 1.2 p. 6
midPoints <- c(24.5, seq(32, 57, 5), 64.5)
plot(midPoints, Means, pch = 20,
     ylab = "Coronary heart disease (mean)",
     xlab = "Age (years)", ylim = 0:1,
     main = "Figure 1.2 p. 6")
lines(midPoints, Means)

## Table 1.3
summary( mod1.3 <- glm( chd ~ age, family = binomial, data = chdage ))

## Table 1.4
vcov(mod1.3)

## Computing OddsRatio and confidence intervals for age ...
exp(coef(mod1.3))[-1]
exp(confint(mod1.3))[-1, ]

Example output

   id age agegrp chd
1   1  20  20-39  No
2   2  23  20-39  No
3   3  24  20-39  No
4   4  25  20-39  No
5   5  25  20-39 Yes
6   6  26  20-39  No
7   7  26  20-39  No
8   8  28  20-39  No
9   9  28  20-39  No
10 10  29  20-39  No
       id              age            agegrp    chd    
 Min.   :  1.00   Min.   :20.00   55-59  :17   No :57  
 1st Qu.: 25.75   1st Qu.:34.75   30-34  :15   Yes:43  
 Median : 50.50   Median :44.00   40-44  :15           
 Mean   : 50.50   Mean   :44.38   45-49  :13           
 3rd Qu.: 75.25   3rd Qu.:55.00   35-39  :12           
 Max.   :100.00   Max.   :69.00   20-39  :10           
                                  (Other):18           
agegrp
20-39 30-34 35-39 40-44 45-49 50-54 55-59 60-69   Sum 
   10    15    12    15    13     8    17    10   100 
       chd
agegrp   No Yes Sum
  20-39   9   1  10
  30-34  13   2  15
  35-39   9   3  12
  40-44  10   5  15
  45-49   7   6  13
  50-54   3   5   8
  55-59   4  13  17
  60-69   2   8  10
  Sum    57  43 100
    20-39     30-34     35-39     40-44     45-49     50-54     55-59     60-69 
0.1000000 0.1333333 0.2500000 0.3333333 0.4615385 0.6250000 0.7647059 0.8000000 

Call:
glm(formula = chd ~ age, family = binomial, data = chdage)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.9718  -0.8456  -0.4576   0.8253   2.2859  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept) -5.30945    1.13365  -4.683 2.82e-06 ***
age          0.11092    0.02406   4.610 4.02e-06 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 136.66  on 99  degrees of freedom
Residual deviance: 107.35  on 98  degrees of freedom
AIC: 111.35

Number of Fisher Scoring iterations: 4

            (Intercept)           age
(Intercept)  1.28517059 -0.0266769747
age         -0.02667697  0.0005788748
     age 
1.117307 
Waiting for profiling to be done...
   2.5 %   97.5 % 
1.069222 1.175868 

aplore3 documentation built on May 2, 2019, 8:24 a.m.