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.
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
Import the data
poison <- read_csv("https://raw.githubusercontent.com/statOmics/PSLS21/data/poison.csv")
Data tidying
We can see a couple of things in the data that can be improved upon:
Capitalise the fist column name
Set the Species column as a factor
Change the species factor levels from 0, 1 and 2 to Dojofish, Goldfish and Zebrafish. Hint: use the fct_recode
function.
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.
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.
Linear regression
In order to get familiar with simple linear regression
Check the assumptions
Interpret the model parameters of the linear model
Interpret the results, both for the intercept as well as for the slope
Write a conclusion that answers the research hypothesis.
LS0tCnRpdGxlOiAiRXhlcmNpc2UgNi4xOiBMaW5lYXIgcmVncmVzc2lvbiBvbiB0aGUgZmlzaCB0YW5rIGRhdGFzZXQiICAgCmF1dGhvcjogIkxpZXZlbiBDbGVtZW50IGFuZCBKZXJvZW4gR2lsaXMiCmRhdGU6ICJzdGF0T21pY3MsIEdoZW50IFVuaXZlcnNpdHkgKGh0dHBzOi8vc3RhdG9taWNzLmdpdGh1Yi5pbykiICAKb3V0cH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