---
title: "Oct27-2"
author: "Nancy"
date: "26/10/2021"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(SMPracticals)
library(faraway)
```

## Binary data

```{r data}
data(wcgs, package = "faraway")
head(wcgs) #not run: str(wcgs); plot(wcgs); help(wcgs)
sum(is.na(wcgs)) # there are a few missing values; much further sleuthing finds arcus and chol have some missing values
```
Fitting a binary model:
```{r modelling}
glm(chd ~ ., family = binomial, data = wcgs)
## let's check personality type, along with a few other variables
heartmod <- glm(chd ~ age + weight + sdp + dbp + behave + cigs, family = binomial, data = wcgs)
summary(heartmod)
heartmod2 <- update(heartmod, . ~ . - behave)
summary(heartmod2)
anova(heartmod, heartmod2)
```
