We use the following packages:

knitr::opts_chunk$set(echo = FALSE, include = FALSE, message = FALSE, eval = FALSE)

The following table shows numbers of occasions when inhibition (i.e., no flow of current across a membrane) occurred within 120 s, for different concentrations of the protein peptide-C. The outcome yes implies that inhibition has occurred.

conc 0.1 0.5  1 10 20 30 50 70 80 100 150 
no     7   1 10  9  2  9 13  1  1   4   3 
yes    0   0  3  4  0  6  7  0  0   1   7

  1. Create this data in R

  1. Add three new variables (columns) to the data

  1. Inspect the expanded data. What do you see?

  1. Add a new column where the log odds are calculated as: \[\log\text{odds} = \log\left(\frac{\text{yes} + 0.5}{\text{no} + 0.5}\right)\]

  1. Fit the model with margin as the weights

  1. Look at the summary of the fitted object

  1. Inspect the plots number 1 and 5 for fit

  1. conc is somewhat skewed. Run the model again with a log-transformation for conc.

  1. Look at the summary of the fitted object again

  1. Inspects the plots number 1 and 5 of the fitted object based on log(conc).

  1. Use the brandsma data from package mice to fit a logistic regression model for sex based on lpo (Language Post Outcome).

  1. Obtain confidence intervals for the parameter estimates.

  1. Use the model parameters to predict the sex variable and compare your predictions to the observed sex.


  1. In the data set minor.head.injury (from package DAAG), obtain a logistic regression model relating clinically.important.brain.injury to all the other variables.

  1. Patients whose risk is sufficiently high will be sent for CT (computed tomography). Using a risk threshold of 0.025 (2.5%), turn the result into a decision rule for use of CT.

End of Practical