## 9. Final exercise

**Here** you will find a dataset in .csv format containing the results of a study performed to investigate the impact of three anorexia treatments (the source of these data can be found **here**, p. 9). The weights of (in total) 72 anorexia patients were measured before and after receiving one of the three treatments.

The data contain three variables:

**treat**: The treatment indicator (0 = control, i.e. no treatment, 1 = cognitive behavioural treatment, 2 = family treatment).
**w_pre**: The weight (in lbs) before receiving the treatment.
**w_post**: The weight (in lbs) after receiving the treatment.

Please perform the steps below to analyze these data. Don’t forget to annotate your script. Again, feel free to use any on-line information you can find.

Import the data into R, and store it as an object.

Check the first three rows of the data to see if step 1 was performed correctly.

Create two new variables representing the weight in kilograms (instead of lbs). Note: 1 kg = 2.205 lbs.

Calculate weight change, i.e. the weight after receiving the treatment minus the change before receiving the treatment, and add this information to the dataset.

Make three **box plots** of the change scores, one for each treatment.

Calculate the average weight change for each of the treatments.

Add a new variable to the dataset indicating whether the weight was decreased, increased or remained approximately the same. Let the variable take on the character value ‘Decrease’ (if weight was decreased by at least 1 kg), ‘No change’ (if the change in weight was at most 1 kg in either direction), or ‘Increase’ (if the increase in weight was at least 1 kg).

For each treatment, create a frequency table for the variable included in step 7.

Note that the total number of patients assigned to each treatment differs. Hence, it is more informative to compare proportions instead of absolute numbers. Calculate, again per treatment, the proportion of patients in each category of the variable created in step 7.

Write a short conclusion regarding the effectiveness of the three treatments.

The solution to this exercise can be found **here**.