LAB 1 1-11-22
1. Used my own computer.
2. Set my directory.
setwd(“C:/Users/manol/Desktop/Binder Lab/Statistics 110/Week 1 Files”)
3a. Loaded data into R
hospital <- read.table("HOSPITALL.txt", header=TRUE)
The variable name for Age in R data “hospital” is AGE and is in the 3RD column. The variable name for Received antibiotic 1=yes/2=no in R data “hospital” is ANTIBIO and is in the 7TH column.
3b. Compute the mean
The mean for the ages of the 25 patient is 41.24
mean(hospital$Age)
## [1] 41.24
3c. Compute the median
The median for the ages of the 25 patients is 41
median(hospital$Age)
## [1] 41
3d. Compute the standard deviation
The standard deviation (SD) for the ages of the 25 patients is 20.1024
sd(hospital$Age)
## [1] 20.1024
3e. Construct histogram
Your histogram for the ages of all 25 patients is:
hist(hospital$Age)
3f. Construct boxplot
The boxplot for the age of the 25 patients is:
boxplot(hospital$Age)
3g. Comment on the symmetry of the distribution of hospitalization based on histogram and boxplot you obtained in (e) and (f).
Based on both the histogram and boxplot, our data appears to have a normal distribution. I make this claim based the fact that (1) the bellcurve of the histogram shows relative symmetry (one might argue there is a SLIGHT right skew) and (2) the boxplot exhibits a median that is centered between the first and third quartiles with whiskers of equal length on either side.
3h. Descriptive data analysis using either numeric or graphic methods. Describe your findings (using both numeric and graphic method) on if the duration of hospitalization is affected by whether a patient has received antibiotics.
Numeric method:
mean(hospital$Dur_stay[hospital$Antibio==1])
## [1] 11.57143
mean(hospital$Dur_stay[hospital$Antibio==2])
## [1] 7.444444
Graphical method:
boxplot(hospital$Dur_stay~hospital$Antibio)
Based on the numeric method, I determined that the duration of hospitalization is higher (mean = 11.56) in patients that recieved antibiotics compared to those who didn’t (mean = 7.44). I confirmed these findings with the graphical method which enabled me to visualize that the median of those who received antibiotics is higher than the median of those who did not.
It is of clinical interest to know if younger patients are more likely to receive antibiotics than older patients. . Answer this question descriptively using either numeric or graphic methods.Comment descriptively (using both numeric and graphic method) on if younger patients are more likely to receive antibiotics than older patients.
Numeric method:
mean(hospital$Age[hospital$Antibio==1])
## [1] 42.71429
Graphical method:
boxplot(hospital$Age~hospital$Antibio)
I would consider a pediatric patient (0-18 years) to be young, a patient between 19-64 years of age to be middle aged, and 65+ years of age to be old (geriatric). The numeric method tells us that the mean age of those who use antibiotics is 42.71 years. This suggests that on average, middle aged patients are the most likely to be using antibiotics. The boxplot helps us to visualize that the mean is indeed ~42 years of age.