0% found this document useful (0 votes)
3 views30 pages

Chapter 2. Descriptive Statistics

Chapter 2 discusses descriptive statistics, focusing on summarizing qualitative and quantitative data through frequency distributions, bar charts, pie charts, and histograms. It explains the importance of visualizing data to gain insights and detect patterns, as well as methods for creating various graphical representations. Additionally, it covers crosstabulations for analyzing the relationship between two variables.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views30 pages

Chapter 2. Descriptive Statistics

Chapter 2 discusses descriptive statistics, focusing on summarizing qualitative and quantitative data through frequency distributions, bar charts, pie charts, and histograms. It explains the importance of visualizing data to gain insights and detect patterns, as well as methods for creating various graphical representations. Additionally, it covers crosstabulations for analyzing the relationship between two variables.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CHAPTER 2

DESCRIPTIVE STATISTICS:
Tabular and Graphical Presentations

Nguyen Thi Ngoc Mien CHAPTER 2 1 / 30


Summarizing qualitative data
Frequency distribution

• A frequency distribution is a tabular summary of data showing the


frequency (or number) of items in each of several non-overlapping
classes.
• The objective is to provide insights about the data that cannot be
quickly obtained by looking only at the original data.
• The category with the highest frequency is the mode
• The frequency divided by the total number of observations is the
proportion.
• The proportion multiplied by 100 is the percentage.
Both proportions and percentages can be called relative frequencies.

Nguyen Thi Ngoc Mien CHAPTER 2 2 / 30


Summarizing qualitative data
Frequency distribution

Example: Guests staying at Pullman were asked to rate the quality


of their accommodations as being excellent, above average, average,
below average, or poor. The ratings provided by a sample of 20
guests are:

Nguyen Thi Ngoc Mien CHAPTER 2 3 / 30


Summarizing qualitative data
Frequency distribution

Frequency table for the rating scale

rate <- c("below average","above average",


"above average","average","above average",
"average","above average","average",
"below average","poor","excellent",
"above average","average","above average",
"above average","below average","poor")
df1 <- table(rate)
df2 <- proportions(table(rate))

Nguyen Thi Ngoc Mien CHAPTER 2 4 / 30


Summarizing qualitative data
Bar chart

• A bar chart is a graphical device for depicting qualitative data.


• On one axis (usually the horizontal axis), we specify the labels that
are used for each of the classes.
• A frequency, proportion, or percentage can be used for the other
axis (usually the vertical axis).
• Using a bar of fixed width drawn above each class label, we extend
the height appropriately.
• The bars are separated to emphasize the fact that each class is a
separate category.

Nguyen Thi Ngoc Mien CHAPTER 2 5 / 30


Summarizing qualitative data
Bar chart

data1 <- [Link](rate)


ggplot(rate,aes(rate)) +
geom_bar(width=0.3,fill="blue") + theme_bw() + theme(text=element_text(size=4)) +
xlab("Rating")

Using the file [Link].


# Bar-chart (Base R)
df1 <- table(data1$Occupation)
barplot(df1)

# Bar-chart (ggplot2)
library(ggplot2)
p <- ggplot(data1,aes(Occupation)) + geom_bar(fill="light blue")
aa <- p + theme([Link].x=element_text(angle=90,hjust=1,vjust=0.5))+
theme([Link] = element_blank(),
[Link] = element_blank())

# Save plot
ggsave("[Link]", aa, width = 5, height = 5)

# Proportion chart
p <- ggplot(data1,aes(x=Occupation,y=..count../sum(..count..))) + geom_bar()

Nguyen Thi Ngoc Mien CHAPTER 2 6 / 30


Summarizing qualitative data
Bar chart

When the bars are arranged in descending order of height from left to
right (with the most frequently occurring cause appearing first), the bar
chart is called a Pareto diagram.
library(forcats)
p <- ggplot(data1,aes(x=fct_infreq(Occupation),
y=after_stat(count)/sum(after_stat(count))))+
geom_bar(fill="light blue")+ylab("Proportion")+
theme([Link].x=element_text(angle=90))

Nguyen Thi Ngoc Mien CHAPTER 2 7 / 30


Summarizing qualitative data
Pie chart

• The pie chart is a commonly used graphical device for presenting


relative frequency for categorical data.
• First draw a circle; then use the relative frequencies to subdivide the
circle into sectors that correspond to the relative frequency for each
class.
• Since there are 360 degrees in a circle, a class with a relative
frequency of .25 would consume .25(360) = 90 degrees of the circle.

pie <- ggplot(data1,aes(x=factor(1),fill = BMI_Category)) +


geom_bar(stat="count") + coord_polar(theta='y') +
theme([Link].x = element_blank(),
[Link].y = element_blank(),
[Link] = element_blank(),
[Link]=element_blank(),
[Link] = element_blank(),
[Link].x=element_blank())

Nguyen Thi Ngoc Mien CHAPTER 2 8 / 30


Summarizing qualitative data

Example: A partial relative frequency distribution is given


Class Relative frequency
A 0.17
B 0.25
C 0.31
D

a. What is the relative frequency of class D?


b. The total sample size is 150. What is the frequency of class A?
c. Construct a bar chart, pie chart.

Nguyen Thi Ngoc Mien CHAPTER 2 9 / 30


Summarizing quantitative data
Frequency distribution

The three steps necessary to define the classes for a frequency


distribution with quantitative data are:
Determine the number of Determine the class limits
non-overlapping classes - Class limits must be chosen so that each
- Use between 5 and 20 classes
- The goal is to use enough classes data item belongs to one and only one class.
to show the variation in the data, but - Two types of class intervals:
not so many classes that some
(i) Exclusive class intervals: the frequencies
contain only a few data items.
corresponding to the specific class interval
do not include the value of its upper limit.
(i) Inclusive class intervals: values equal to
the lower and upper limits of a class are
Determine the width of each class
- Use classes of equal width included in the frequency of the same
- Approximate class width = class.
Largest data value − Smallest data value
Number of classes

Nguyen Thi Ngoc Mien CHAPTER 2 10 / 30


Summarizing quantitative data
Frequency distribution

Example: Blockbuster is one of the largest video rental and sales


companies in the US. Its stores rent and sell DVD products. Re-
cently, a district manager for Blockbuster in Arkansas conducted a
survey of customers in her district. Among the questions asked on
the written survey was “How many DVD movies do you own?” A
total of 100 people completed the survey. These data are discrete,
quantitative data. The values range from 0 to 19. The data col-
lected are as follows

Nguyen Thi Ngoc Mien CHAPTER 2 11 / 30


Summarizing quantitative data
Frequency distribution

Example: Can create frequency table based solely on values themselves


because data is discrete.

Nguyen Thi Ngoc Mien CHAPTER 2 12 / 30


Summarizing quantitative data
Frequency distribution

Example: Or can group data into classes of equal width:


- Pick the number of classes: n = 5
19 − 0
- Find the class width: = = 3.8 ≈ 4
5
- Find the class limits: 0 + 4 = 4, 4 + 4 = 8, 8 + 4 = 12, 12 + 4 = 16,
16 + 4 = 20.

Inclusive intervals Exclusive intervals

Note: For continuous variables, exclusive class intervals should be used.


Code in R:
library(DescTools)
Freq(data1$Sleep_Duration,breaks=9,right=F)

Nguyen Thi Ngoc Mien CHAPTER 2 13 / 30


Summarizing quantitative data
Graphical Presentations

Why visualize data?


Data visualization means drawing graphic displays to show data.
Data visualization is a key component in any quantitative research:
• Lets users absorb information quickly, get better insights and figure
out the next steps faster.
• Understand what is happening in the data: data structure, detecting
outliers and unusual group.
• Allow users to easily compare different categories, groups, or periods.

Nguyen Thi Ngoc Mien CHAPTER 2 14 / 30


Summarizing quantitative data
Histogram

Histogram uses bars to portray the frequencies or the relative frequencies


of the possible outcomes of a quantitative variable.
• The variable of interest is placed on the horizontal axis.
• A rectangle is drawn above each class interval with its height
corresponding to the interval’s frequency, relative frequency, or
percent frequency.
• Unlike a bar graph, a histogram has no natural separation between
rectangles of adjacent classes.

hist <- ggplot(data1, aes(Sleep_Duration))+


geom_histogram(boundary=min(data1$Sleep_Duration),
binwidth=0.3)
hist
layer_data(hist)

Nguyen Thi Ngoc Mien CHAPTER 2 15 / 30


Summarizing quantitative data
Histogram

Histograms show skewness


• Symmetric: The histogram has one peak in the middle. Data points
have an equal chance of being on either side of the average.
• Right-skewed histogram: the tail on the right side is longer than
usual, and the highest point (peak) of the graph is towards the left.
• Left-skewed histogram: the tail on the left side is longer than usual,
and the highest point (peak) of the graph is towards the right.

Histograms showing the central tendency

Nguyen Thi Ngoc Mien CHAPTER 2 16 / 30


Summarizing quantitative data
Histogram

Histograms detecting irregularities/outliers

Histograms showing unimodal/bimodal/multimodal distribution


A unimodal distribution only has one peak in the distribution, a bimodal
distribution has two peaks, and a multimodal distribution has three or
more peaks.

Nguyen Thi Ngoc Mien CHAPTER 2 17 / 30


Summarizing quantitative data
Cumulative Distributions

Cumulative frequency (relative frequency, percent frequency) distribution


shows the number (proportion, percentage) of items with values less than
or equal to the upper limit of each class.

An ogive is a graph of a cumulative distribution.


• The data values are shown on the horizontal axis.
• Shown on the vertical axis are the: cumulative frequencies, or
cumulative relative frequencies, or cumulative percent frequencies.
• Plot cumulative frequency against the upper class boundary of each
class and connect the points.

Nguyen Thi Ngoc Mien CHAPTER 2 18 / 30


Summarizing quantitative data
Cumulative Distributions

h <- hist(sl$Sleep_Duration,plot=FALSE)
cf <- c(0, cumsum(h$counts/sum(h$counts)))
plot(h$breaks, cf, type = "b", col = "blue", pch = 20,
xlab = "Sleep", ylab = "Frequency")

Nguyen Thi Ngoc Mien CHAPTER 2 19 / 30


Summarizing quantitative data
Dot plot

- A horizontal axis shows the range of data values.


- Then each data value is represented by a dot placed above the axis.

Example: A doctor’s office staff studied the waiting times for pa-
tients who arrive at the office with a request for emergency ser-
[Link] following data with waiting times in minutes were collected
over a one-month period.

14 10 12 4 4 5 17 11 8 9 8 12 6 8 7

Draw a dot plot of the data.

Nguyen Thi Ngoc Mien CHAPTER 2 20 / 30


Summarizing quantitative data
Dot plot

ggplot(data1, aes(x=Sleep_Duration)) +
geom_dotplot(dotsize = 0.3) +
theme([Link].y = element_blank(),[Link].y = element_blank(),
[Link].y = element_blank(),[Link]=element_blank(),
[Link] = element_blank(),[Link] = element_blank(),
[Link].x = element_line(colour = "black"))

Nguyen Thi Ngoc Mien CHAPTER 2 21 / 30


Summarizing quantitative data
Stem and leaf

A stem-and-leaf display shows both the rank order and shape of the
distribution of the data.

• Sort the data in order from smallest to largest


• The first digits of each data item are arranged to the left of a
vertical line.
• To the right of the vertical line, we record the last digit for each
item in rank order.

Example: Britney is a swimmer training for a competition. The number of


50-metre laps she swam each day for 30 days are as follows:
22, 21, 24, 19, 27, 28, 24, 25, 29, 28, 26, 31, 28, 27, 22, 39, 20, 10, 26, 24,
27, 28, 26, 28, 18, 32, 29, 25, 31, 27.

Nguyen Thi Ngoc Mien CHAPTER 2 22 / 30


Summarizing quantitative data
Stem and leaf

• A single digit is used to define each leaf.


• Leaf units may be 100, 10, 1, 0.1, and so on.
• Where the leaf unit is not shown, it is assumed to equal 1.
If we have data with values such as:
If we have data with values such as:
8.6 11.7 9.4 9.1 10.2 11.0 8.8
1806 1717 1974 1791 1682 1910 1838
a stem-and-leaf display of these data
a stem-and-leaf display of these data will be
will be

Nguyen Thi Ngoc Mien CHAPTER 2 23 / 30


Summarizing quantitative data
Stem and leaf

library(aplpack)
swim <- c(22, 21, 24, 19, 27, 28, 24, 25, 29,
28, 26, 31, 28, 27, 22, 39, 20, 10,
26, 24, 27, 28, 26, 28, 18, 32, 29,
25, 31, 27)
[Link](swim,style="bare",m=1,unit=1)
[Link](swim,style="bare",m=2,unit=1)

swim <- c(2.2, 2.1, 2.4, 1.9, 2.7, 2.8, 2.4,


2.5, 2.9, 2.8, 2.6, 3.1, 2.8, 2.7,
2.2, 3.9, 2, 1, 2.6, 2.4, 2.7, 2.8,
2.6, 2.8, 1.8, 3.2, 2.9, 2.5, 3.1, 2.7)
[Link](swim,style="bare",m=2,unit=0.1)

Nguyen Thi Ngoc Mien CHAPTER 2 24 / 30


Summarizing the data for two variables
Crosstabulations

A crosstabulation is a tabular summary of data for two variables.


Crosstabulation can be used when:
• one variable is qualitative and the other is quantitative,
• both variables are qualitative, or
• both variables are quantitative.
The left and top margin labels define the classes for the two variables.
Example: The number of Finger Lakes homes sold for each style and price for the past
two years is shown below.

Nguyen Thi Ngoc Mien CHAPTER 2 25 / 30


Summarizing the data for two variables
Crosstabulations

> table(data1$Gender,data1$BMI_Category)

Normal Obese Overweight Underweight


Female 64 1 106 14
Male 131 9 42 7

> proportions(table(data1$Gender,data1$BMI_Category),margin=1)
Normal Obese Overweight Underweight
Female 0.345945946 0.005405405 0.572972973 0.075675676
Male 0.693121693 0.047619048 0.222222222 0.037037037

ggplot(data1, aes(x = BMI_Category, fill = Gender)) +


geom_bar(position = "dodge")
ggplot(data1, aes(x = BMI_Category, fill = Gender)) +
geom_bar(position = "stack")
ggplot(data1, aes(x = BMI_Category, fill = Gender)) +
geom_bar(position = "fill")

Nguyen Thi Ngoc Mien CHAPTER 2 26 / 30


Summarizing the data for two variables
Scatter plot

A scatter diagram is a graphical presentation of the relationship between


two quantitative variables.
One variable is shown on the horizontal axis and the other variable is
shown on the vertical axis.
The general pattern of the plotted points suggests the overall relationship
between the variables.
ggplot(data1, aes(x = Age, y = Sleep_Duration)) + geom_point()

Nguyen Thi Ngoc Mien CHAPTER 2 27 / 30


Exercises

Exercise 1: A psychologist developed a new test of adult intelligence.


The test was administered to 20 individuals, and the following data were
obtained.
114 99 131 124 117 102 106 127 119 115
98 104 144 151 132 106 125 122 118 118
Construct a stem-and-leaf display for the data.

Nguyen Thi Ngoc Mien CHAPTER 2 28 / 30


Exercises

Exercise 2 The histogram shows the winning speeds at the Daytona 500.

(a) Discuss the skewness in the distribution.


(b) Which interval contains the most data values?
(c) How many of the winning speeds are at least 160 miles per hour?

Nguyen Thi Ngoc Mien CHAPTER 2 29 / 30


Exercises

Exercise 3 Recently, management at Oak Tree Golf Course received a few complaints
about the condition of the greens. Several players complained that the greens are too
fast. Rather than react to the comments of just a few, the Golf Association conducted
a survey of 100 male and 100 female golfers. The survey results are summarized here.

a. Combine these two crosstabulations into one with Male and Female as the row
labels and Too Fast and Fine as the column labels. Which group shows the highest
percentage saying that the greens are too fast?
b. Refer to the initial crosstabulations. For those players with higher handicaps, which
group (male or female) shows the highest percentage saying the greens are too fast?
c. What conclusions can you draw about the preferences of men and women
concerning the speed of the greens?

Nguyen Thi Ngoc Mien CHAPTER 2 30 / 30

You might also like