## An example for logistic regression,
## using the "South African heart disease" dataset from
## Hastie, Tibshirani and Friedman,
## The Elements of Statistical Learning, Springer 2009.
## 
## See https://hastie.su.domains/ElemStatLearn/data.html
## from the description there:
## A retrospective sample of males in a heart-disease high-risk region
## of the Western Cape, South Africa. There are roughly two controls per
## case of CHD. Many of the CHD positive men have undergone blood
## pressure reduction treatment and other programs to reduce their risk
## factors after their CHD event. In some cases the measurements were
## made after these treatments. These data are taken from a larger
## dataset, described in  Rousseauw et al, 1983, South African Medical
## Journal. 
##
## sbp		systolic blood pressure
## tobacco		cumulative tobacco (kg)
## ldl		low density lipoprotein cholesterol
## adiposity
## famhist		family history of heart disease (Present, Absent)
## typea		type-A behavior
## obesity
## alcohol		current alcohol consumption
## age		age at onset
## chd		response, coronary heart disease

dat <- read.table("SAheart.data", header=TRUE,sep=",", row.names=1)
dat
dim(dat) # n=462 observations, 10 rows

dat$famhist <- as.factor(dat$famhist) # convert string to factor
pairs(dat)

m <- glm(chd ~ sbp + tobacco + ldl + adiposity + famhist + typea +
             obesity + alcohol + age, family=binomial, data=dat)
m
summary(m)
