Highlights
Part one: Data management and missing data
Let’s start by loading the patient data and storing it in an R object called patient.data, and removing patients who did not have COVID 19. Don't forget to set your working directory.
patient.data<-read.csv("Synthea_patient_covid.csv", na.strings = "") patient.data<-patient.data[which(patient.data$covid_status==1),]
Question 1
The first thing you want to know is how many patients died? Use the table() function to find and report this number.
Question 2
Next you want to know how many missing values each variable has. Use the appropriate code from week 3 to obtain these results (note the code is complex but all you need to do is change the name of the data object). For each variable with missing data, report the proportion of values which are missing (you can calculate the proportion by hand - no fancy R code required):
Question 3
One of the variables which had missing data was DEATHDATE. However, this is expected because only patients who died will have a value on this variable. But there could still be genuine missing values on this variable if any patients who died don't have a value for DEATHDATE. Make a table showing death status by missingness on DEATHDATE and report how many (if any) patients who died were missing a DEATHDATE.
Question 4
Our data does not include a variable for age, but we can make one using the following code. Run the code below which makes the age variable. In your answer, explain what each of the three lines of code does, and use the summary() function to find the mean and median age in the sample, to check that the age variable includes only plausible values of age - comment on what you find. For example, if we had negative ages, or ages above 150, we would question whether we had made a mistake or not when making the age variable.
Question 5
As the pandemic has progressed it has become clear that males are at increased risk of death compared with females. But before investigating if that is true in our data, we firstly need to see if age is distributed differently by gender (i.e., is one group older than the other?). To answer this question, make a box plot of age by gender and interpret the plot with regards to the distribution of age by gender (you may need to research how to interpret box plots with a Google search).
Question 6
Your manager also wants to know the death rate (proportion of patients who died) in your sample. This is the result of a simple division in which the numerator is the number of dead (which you obtained in question 1), and the denominator is the number of patients in the data. For example, if we had 50 patients and 4 died, the death rate would simply be 4/50 = 0.08.
Without thinking, s/he uses the number of rows in your dataset as the denominator and obtains a death rate of 0.023 (or 2.3%). You need to explain why what s/he did was wrong and find the true death rate. The functions you will need to achieve this are the length() and unique() functions. Below is a brief explanation of how each function works, what you need to do is figure out how to apply them to solve this problem:
The unique() function will look through a vector of numbers or characters and return only the unique elements. For example, if you have a vector of eight values c(1,0,5,12,4,5,1,1) in which the value 1 is repeated three times and the value 5 is repeated twice, you can use the unique() function to remove duplicate values (run the code below to confirm):
unique(c(1,0,5,12,4,5,1,1))
## [1] 1 0 5 12 4
The length() function is very simple, it simply counts the number of elements in a vector, for example:
length(c(1,0,5,12,4,5,1,1))
## [1] 8
Use this information to solve this problem. If you can, estimate the death rate in a single line of code.
Question 7
Explain what each line of code in the above is doing and why we took these steps to produce our pred.data object. Explain it line-byline (e.g., Line 1 does A, B and C. Line 2 does X, Y and Z, and so on...).
This data is very similar to the data we prepared in our week 4 exercises, with a few important differences. In week 4 we predicted COVID+ status among the full sample. Here we are predicting death among the COVID+ sample. We have also removed the RACE variable to save time (i.e., we don't have to dummy code). Before we can run our model, we have one last step, we must separate our data into a training and testing set (run the following code).
This PUBH2005 - Data Analytics Assignment has been solved by our Data Analytics experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.