This analysis examines the resting heart rates of 65 randomly sampled males and 65 randomly sampled females. Descriptive statistics and graphical methods are used to examine each group and compare their distributions.
dat <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
male <- dat[dat$Sex == 1, ]
female <- dat[dat$Sex == 2, ]
The data were separated by sex, where males are coded as 1 and
females are coded as 2. The variable Beats represents
resting heart rate.
min(male$Beats)
## [1] 58
max(male$Beats)
## [1] 86
mean(male$Beats)
## [1] 73.36923
sd(male$Beats)
## [1] 5.875184
median(male$Beats)
## [1] 73
quantile(male$Beats)
## 0% 25% 50% 75% 100%
## 58 70 73 78 86
The descriptive statistics summarize the center and variability of resting heart rate for the male sample. The mean and median provide measures of the center, while the standard deviation and quartiles describe the amount of variation among the observations.
hist(male$Beats,
main = "Male Resting Heart Rate",
xlab = "Heart Rate (beats per minute)",
col = "blue")
The histogram shows how the male resting heart rates are distributed. Most observations are concentrated around the middle of the distribution, while fewer observations occur toward the lower and upper ends.
qqnorm(male$Beats,
main = "Normal Probability Plot - Male Resting Heart Rate")
qqline(male$Beats)
The normal probability plot can be used to assess whether the male heart-rate observations are reasonably consistent with a normal distribution. The observations generally follow the reference line, although some deviation may occur toward the ends of the distribution.
min(female$Beats)
## [1] 57
max(female$Beats)
## [1] 89
mean(female$Beats)
## [1] 74.15385
sd(female$Beats)
## [1] 8.105227
median(female$Beats)
## [1] 76
quantile(female$Beats)
## 0% 25% 50% 75% 100%
## 57 68 76 80 89
These descriptive statistics summarize the center and spread of the female resting heart-rate observations. Comparing the mean and median helps describe the center of the distribution, while the standard deviation, range, and quartiles describe its variability.
hist(female$Beats,
main = "Female Resting Heart Rate",
xlab = "Heart Rate (beats per minute)",
col = "pink")
The histogram displays the distribution of resting heart rates among females. Most observations are concentrated near the center of the distribution, with fewer observations appearing at the lower and upper ends.
qqnorm(female$Beats,
main = "Normal Probability Plot - Female Resting Heart Rate")
qqline(female$Beats)
The female normal probability plot shows the relationship between the observed heart rates and values expected under a normal distribution. The points generally follow the reference line, suggesting that a normal model is reasonably appropriate, although some departures may appear in the tails.
boxplot(male$Beats, female$Beats,
names = c("Male", "Female"),
main = "Resting Heart Rate: Male vs Female",
ylab = "Heart Rate (beats per minute)")
The side-by-side box plots show substantial overlap between male and female resting heart rates. The female group appears to have a somewhat higher center than the male group. At the same time, both groups show considerable variability and overlap, so resting heart rates are not completely separated by sex. The box plots also allow the spreads, medians, ranges, and any possible unusual observations in the two groups to be compared directly.
dat <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
male <- dat[dat$Sex == 1, ]
female <- dat[dat$Sex == 2, ]
# Male descriptive statistics
min(male$Beats)
max(male$Beats)
mean(male$Beats)
sd(male$Beats)
median(male$Beats)
quantile(male$Beats)
# Male histogram
hist(male$Beats,
main = "Male Resting Heart Rate",
xlab = "Heart Rate (beats per minute)",
col = "blue")
# Male normal probability plot
qqnorm(male$Beats,
main = "Normal Probability Plot - Male Resting Heart Rate")
qqline(male$Beats)
# Female descriptive statistics
min(female$Beats)
max(female$Beats)
mean(female$Beats)
sd(female$Beats)
median(female$Beats)
quantile(female$Beats)
# Female histogram
hist(female$Beats,
main = "Female Resting Heart Rate",
xlab = "Heart Rate (beats per minute)",
col = "pink")
# Female normal probability plot
qqnorm(female$Beats,
main = "Normal Probability Plot - Female Resting Heart Rate")
qqline(female$Beats)
# Male and female side-by-side box plots
boxplot(male$Beats, female$Beats,
names = c("Male", "Female"),
main = "Resting Heart Rate: Male vs Female",
ylab = "Heart Rate (beats per minute)")