Data management and programming for epidemiology - write


Introduction

This is a short analysis assignment to be undertaken individually.

This assignment involves three tasks, involving a file of simple patient data (the data are fictional and do not refer to real people).

The first task is to check the integrity of a data file (check for the presence of data errors and problems) by writing simple R code. The file contains a number of errors and potential problems. Some of the errors are obvious if you inspect the data by eye. However, marks will not be awarded for simply stating what the errors or problems are. Marks will be awarded for R code that demonstrates the presence (or absence) of errors and problems in the given data. The R code that you will submit does not need to be the most elegant or ‘clever' code possible: we are seeking a demonstration of basic R usage in this assignment. It should still be clear, concise, commented and correct.

The second task involves writing R code to perform some descriptive analysis of the data.

The third task requires you to write an R function to calculate a derived value: Body Mass Index (BMI). You will then use that function to add a column for BMI to the data. You will then need to use R to draw a histogram of the distribution of BMI.

Marking

There are 3 tasks. Task 1 is worth 30 marks. Task 2 is worth 20 marks. Task 3 is worth 10 marks. This assignment is out of 60 and contributes 30% of your final assessment mark.

Recommendations

You should prepare all your work using RStudio. Create a project called ‘assignment-2' and a script file within that project called ‘solution.R'. Put all your code in ‘solution.R' and we will run this file (and only this file) when marking your assignment.

This assignment is not difficult but will take time to complete so don't leave it until the last minute. The time available to you before this is due is more than adequate to complete the assignment.

A description of the data file ‘diabetes1.csv'

A study is underway to determine how many people presenting to an Emergency Department (ED) in a hospital with ear infections have diagnosed diabetes. The file diabetes1.csv is provided to you supposedly with the following specifications.

The file ‘diabetes1.csv' contains data on 1000 patients presenting to the ED with otitis externa (outer ear infection) in CSV format.1

Table T1 describes the data in the file column by column. Each row of the file contains one record with the column in the order as given on the first header line.2 In the table:

- A column marked as mandatory means the data in that column are required in all records

- A column marked as optional means that the data in that column may be missing for some records

Table T1:

 

Column name

 

Required?

 

Type

 

Comments

 

ID

 

mandatory

 

integer

 

unique for each patient

 

surname

 

mandatory

 

character string

 

patient's surname in upper case

 

middle.name

 

optional

 

character string

 

patient's middle name (if they have one) in mixed case

 

first.name

 

mandatory

 

character string

 

patient's first or given name in mixed case

 

gender

 

mandatory

 

character string

 

"Female" or "Male" only

 

systolic_bp

 

mandatory

 

integer

 

pressure reading in mmHg in the range 60- 220 mmHg

 

diastolic_bp

 

mandatory

 

integer

 

pressure reading in mmHg in the range 50- 150 mmHg

 

Age

 

mandatory

 

integer

 

age in whole years, only patients 18 years and older have been enrolled in the study

 

Height(cm)

 

mandatory

 

decimal number

 

measured height of the patient in cm

 

Column name

 

Required?

 

Type

 

Comments

 

weight

 

mandatory

 

integer

 

measured weight of the patient, fully clothed and with shoes on, in kg

 

RandomBSL

 

optional

 

decimal

 

blood sugar level (BSL), measured in millimole per litre (mmol/L), ≥ 2.2 mmol/L

 

HbA1c

 

optional

 

decimal

 

haemoglobin A1c measurement, as a percentage

 

DiabetesDiagnosis

 

optional

 

logical

(TRUE or FALSE)

 

whether the patient had been previously diagnosed as suffering from diabetes

Task 1

Remember: you will be submitting R code that calculates/demonstrates answers to the following questions not just a printed output. We will not be marking the printed output of your programme. We need to be able to run your programme to mark it.

Read the file ‘diabetes1.csv' into an R data frame.

You will want to use StringsAsFactors=FALSE as an optional argument to the read.csv() function to prevent character variables being automatically converted to factors.

Check that the data file conforms to the specifications for it:

- Does it have the correct number of rows?

- Does it contain all the columns it is supposed to contain

- Does it contain no additional columns?

- For each column, calculate the number and proportion (percentage) of records for which the data are missing.

- For each column, calculate the number and proportion (percentage) of records for which the data are valid (exists and is a legal value).

- Calculate the number and proportion (percentage) of records overall that contain no invalid values in any column. A missing optional value is not invalid.

Task 2

You may need to correct some problems with the data as provided in order to calculate these quantities.

All changes to the data must be made using R code, so that the changes are repeatable. Do not edit

‘diabetes1.csv (or a copy of it) by hand. You will lose marks for editing the input data to correct problems.

If you need to correct or modify the data we suggest you load the ‘raw' data into a dataframe and write a function to correct the dataframe then analyse the corrected data.

Calculate the following descriptive statistics.

- Number of patients in each of the following age brackets:

o 0-17,18-24, 25-44, 45-64, 65-84, 85+

- Number and percentage of patients:

o previously diagnosed with diabetes

o not previously diagnosed with diabetes

- Number of patients in each age group previously diagnosed with diabetes, and not previously diagnosed with diabetes (note: this is 12 values).

- The ID numbers of all patients aged over 64 years who have not previously been diagnosed with diabetes.

- Draw a histogram of RandomBSL. Some proportion of the marks will be given for proper labelling of the histogram and its axes.

Task 3

Write an R function to calculate Body Mass Index (BMI).

BMI is calculated using the following formula:

BMI = weight in kg/(height in m)2

Use your BMI function to add a column containing the calculated BMI for each patient to the data frame containing the patient data.

Draw a histogram of BMI. Some proportion of the marks will be given for proper labelling of the histogram and its axes.

Attachment:- diabetes.rar

Request for Solution File

Ask an Expert for Answer!!
Other Engineering: Data management and programming for epidemiology - write
Reference No:- TGS02265736

Expected delivery within 24 Hours