1 Fish tank dataset

In this experiment, 96 fish (dojofish, goldfish and zebrafish) were placed separately in a tank with two litres of water and a certain dose (in mg) of a certain poison EI-43,064. The resistance of the fish a against the poison was measured as the amount of minutes the fish survived upon adding the poison (Surv_time, in minutes). Additionally, the weight of each fish was measured.

2 Goal

The research goal is to study the association between the dose of the poison that was administered to the fish and their survival time by using a linear regression model.

Read the required libraries

library(tidyverse)

3 Import the data

poison <- read_csv("https://raw.githubusercontent.com/statOmics/PSLSData/main/poison.csv")

4 Data tidying

We can see a couple of things in the data that can be improved:

  1. Capitalise the fist column name

  2. Set the Species column as a factor

  3. Change the species factor levels from 0, 1 and 2 to Dojofish, Goldfish and Zebrafish. Hint: use the fct_recode function.

5 Data Exploration and Descriptive Statistics

How many fish do we have per species?

Which variables might influence survival? Make a suitable visualisation of the association between the dose and the survival time.

6 Important note on the dataset

In this dataset, there are multiple variables can have an effect on the survival time of the fish. The most obvious one is the dose of poison that was administered (as displayed above). However, we could also imagine that heavier fish are less prone to the poison than light fish. Additionally, one fish species may be more resistant to the poison.

To correctly analyse this data, all these factors should be taken into account. However, modeling the response based on multiple predictors will only be discussed later in this course. For now, we will simply ignore the potential effect of weigth and species on the survival time of the fish. Hence, we only consider the effect of the poison dosage. This allows us to analyze the data using simple linear regression, but please bear in mind that not taking into account thesee other factors will invalidate our analysis. Later in the course, we will come back to this dataset and perform a correct analysis that takes into acount all relevant predictors.

7 Linear regression

In order to get familiar with simple linear regression

  1. Check the assumptions

  2. Interpret the model parameters of the linear model

  3. Interpret the results, both for the intercept as well as for the slope

  4. Write a conclusion that answers the research hypothesis.

LS0tCnRpdGxlOiAiRXhlcmNpc2UgNi4xOiBMaW5lYXIgcmVncmVzc2lvbiBvbiB0aGUgZmlzaCB0YW5rIGRhdGFzZXQiCmF1dGhvcjogIkxpZXZlbiBDbGVtZW50LCBKZXJvZW4gR2lsaXMgYW5kIE1pbGFuIE1hbGZhaXQiCmRhdGU6ICJzdGF0T21pY3MsIEdoZW50IFVuaXZ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