Excel 2: Descriptive Statistics for Qualitative Variables Notes on Qualitative Variables
Distribution of Outcomes: Frequency Table
The initial step in studying the distribution of a qualitative variable, such as T-shirt sizes in the dataset
<Size T-shirts.xlsx>, is creating a frequency table to provide a numerical representation.To establish the format for a frequency table, a header row should be created. The possible outcomes for the qualitative variable are listed in the first column.
In the practice dataset, the text labels "size", "a.f." (absolute frequency), and "r.f." (relative frequency) are placed in cells , , and respectively.
The specific outcomes for T-shirt sizes are represented numerically. Values and are entered in cells and . Using the fill handle from selection , the sequence is completed up to cell (representing sizes through ).
Cell is designated for the label "n", representing the total sample size.
Determining Absolute Frequency (a.f.)
The absolute frequency of outcomes can be calculated using the
COUNTIFfunction.In cell , the formula is:
The range contains the raw data.
The criteria refers to the specific outcome (e.g., size ).
To avoid repetitive manual entry for all sizes ( through ), absolute cell references must be used for the data range to allow for copying the formula.
The updated formula in cell should be:
When this formula is copy-pasted to the range , the data range remains fixed (absolute reference) while the outcome criterion () changes relatively to match the row (relative reference).
Determining Relative Frequency (r.f.)
Relative frequency is determined by dividing the absolute frequency of an outcome by the total number of observations ().
The total number of data points () can be calculated in two ways:
By summing the absolute frequencies in cell :
By counting the number of observations in the raw data range in cell :
Note: The
COUNTfunction can also be used if the observations are numbers, as they are in this variable.
To calculate the relative frequency in cell , the formula used is:
A dollar sign is utilized before the row reference () because the divisor (total sample size in ) must remain fixed when the formula is copied down through cells .
Summing the relative frequency column should result in a value of , which serves as a verification check.
Determining Cumulative Relative Frequency (c.r.f.)
Because the data is ordinal (sizes have a natural ranking), cumulative frequencies are informative measures.
Method 1: Manual Addition
For the smallest outcome in cell , the cumulative relative frequency is simply equal to the relative frequency:
For the subsequent outcome in cell , the formula adds the previous cumulative total to the current relative frequency:
This formula is then copied to the range .
Method 2: Expanding SUM Range
In cell , the
SUMfunction is used with an absolute start point and a relative end point:When copied to the range , the range expands (e.g., in it becomes
SUM($E$9:E10)).
The final value for the cumulative relative frequency must always equal .
Graphical Representations of Distributions
Graphical displays are found under the "Insert" tab in the "Charts" group.
A frequency table must be set up as a preliminary step before creating most charts.
Pie Charts
To create a pie chart for the variable size, select the outcomes and absolute frequencies (cells ) and select the Pie option.
Potential Error: Excel may occasionally misinterpret numerical labels (like for sizes) as a separate data series. In this case, Excel might treat the "size" column as values and sum them (), resulting in a wrong graph.
Corrective Action: If the graph is incorrect, select only the absolute frequencies (). Then, use the "Select Data" command under the "Chart Design" tab to manually assign cells to the "Horizontal (Category) Axis Labels".
Labeling: Charts should always include a legend, title, axis titles, and data labels. In the "More Data Label Options", one can choose to display "Value" (absolute frequency) or "Percentage".
Needle Graphs (Column Charts)
A needle graph is represented as a basic column chart using relative frequencies on the y-axis.
Selection Technique: To select non-adjacent columns (e.g., letter codes in and relative frequencies in ), hold the "Command" (or Ctrl) button while selecting the ranges.
Identification: If numerical headings are used instead of text letter codes, Excel may misplot the data. Similar to the pie chart, identifying the data series explicitly through "Select Data" fixes this.
100% Stacked Column Charts
This chart type is particularly useful for ordinal data to show the composition of the whole.
Process 1: Manual Setup
Select only the relative frequencies ().
Insert a standard Column Chart, then use "Change Chart Type" to select the "100% Stacked Column" subtype.
Click "Switch Row/Column" in the Chart Design tab.
Legend and series names must be added manually by clicking "Select Data", choosing "Series1", and linking it to the descriptive name cell (e.g., which might contain "1=S"). Repeat for all 5 series.
Process 2: Text-Based Automation
Select both the text outcomes () and relative frequencies ().
Insert a column chart, change to the "100% Stacked Column" subtype, and click "Switch Row/Column".
Because the outcomes are text (S, M, L, etc.) rather than numbers (), Excel automatically assigns the legend correctly.
Summary Measure: Mode
The mode is the outcome with the highest absolute frequency (a.f.) or highest relative frequency (r.f.).
It can be identified by inspecting the frequency table.
The Excel function for mode is:
Caveat: If a dataset is multimodal (has more than one mode), the standard
=MODEfunction in Excel will only return one of those modes.
Utilization of PivotTables
PivotTables allow for the creation of frequency tables without manual framework setup.
To create a PivotTable, select the variable outcomes including the header (cells ), go to "Insert", and select "PivotTable".
In the PivotTable fields:
Drag the "size" variable to the Rows area.
Drag the "size" variable to the Values area.
By default, Excel may apply a "Sum" to numerical data. This must be changed to "Count" by clicking the info icon/drop-down arrow and selecting "Value Field Settings" > "Summarize value field by: Count".
Advanced PivotTable Calculations
To add relative frequency (r.f.) and cumulative relative frequency (c.r.f.) to a PivotTable, drag the "size" variable into the Values area multiple times.
For Relative Frequency: Under Value Field Settings, go to the "Show Data As" tab and select "% of Grand Total".
For Cumulative Relative Frequency: Under Value Field Settings, go to the "Show Data As" tab and select "% running Total in".
PivotTable Maintenance
PivotTables do not refresh automatically when raw data is changed.
If a value in the data range (e.g., cell ) is modified, the user must click on the PivotTable and select the "Refresh" command under the "PivotTable Analyze" tab.
Ordinal Sorting: If outcomes are letters (S, M, L, XL, XXL), Excel will sort them alphabetically by default. To correct this for cumulative frequency relevance, right-click an outcome and select "Move" to order them logically (e.g., Move S to beginning, Move M up).
Summary of Competencies
Construct frequency tables using
=COUNTIFand=SUMwhile applying effective cell referencing ($$ and relative).Determine c.r.f. via multiple methods (addition vs. range sum).
Calculate r.f., a.f., and c.r.f. efficiently using PivotTables and the "Show Data As" settings.
Identify and interpret the mode of a qualitative variable.
Generate and format Pie, Column (needle), and 100% Stacked Column charts ensuring correct legend and axis labeling.