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 C8C8, D8D8, and E8E8 respectively.

  • The specific outcomes for T-shirt sizes are represented numerically. Values 11 and 22 are entered in cells C9C9 and C10C10. Using the fill handle from selection C9:C10C9:C10, the sequence is completed up to cell C13C13 (representing sizes 11 through 55).

  • Cell C14C14 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 COUNTIF function.

  • In cell D9D9, the formula is:   =COUNTIF(A2:A51;C9)\text{=COUNTIF}(A2:A51; C9)

    • The range A2:A51A2:A51 contains the raw data.

    • The criteria C9C9 refers to the specific outcome (e.g., size 11).

  • To avoid repetitive manual entry for all sizes (22 through 55), absolute cell references must be used for the data range to allow for copying the formula.

  • The updated formula in cell D9D9 should be:   =COUNTIF($A$2:$A$51,C9)\text{=COUNTIF}(\$A\$2:\$A\$51, C9)

  • When this formula is copy-pasted to the range D10:D13D10:D13, the data range remains fixed (absolute reference) while the outcome criterion (C9C9) 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 (nn).

  • The total number of data points (nn) can be calculated in two ways:

    • By summing the absolute frequencies in cell D14D14:     =SUM(D9:D13)\text{=SUM}(D9:D13)

    • By counting the number of observations in the raw data range in cell D15D15:     =COUNTA($A$2:$A$51)\text{=COUNTA}(\$A\$2:\$A\$51)

    • Note: The COUNT function can also be used if the observations are numbers, as they are in this variable.

  • To calculate the relative frequency in cell E9E9, the formula used is:   =D9/D$14\text{=D9/D\$14}

    • A dollar sign is utilized before the row reference (1414) because the divisor (total sample size in D14D14) must remain fixed when the formula is copied down through cells E10:E13E10:E13.

  • Summing the relative frequency column should result in a value of 11, 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 F9F9, the cumulative relative frequency is simply equal to the relative frequency:     =E9\text{=E9}

    • For the subsequent outcome in cell F10F10, the formula adds the previous cumulative total to the current relative frequency:     =F9+E10\text{=F9+E10}

    • This formula is then copied to the range F11:F13F11:F13.

  • Method 2: Expanding SUM Range

    • In cell G9G9, the SUM function is used with an absolute start point and a relative end point:     =SUM($E$9:E9)\text{=SUM}(\$E\$9:E9)

    • When copied to the range G10:G13G10:G13, the range expands (e.g., in G10G10 it becomes SUM($E$9:E10)).

  • The final value for the cumulative relative frequency must always equal 11.

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 C8:D13C8:D13) and select the Pie option.

  • Potential Error: Excel may occasionally misinterpret numerical labels (like 1,2,3,4,51, 2, 3, 4, 5 for sizes) as a separate data series. In this case, Excel might treat the "size" column as values and sum them (1+2+3+4+5=151+2+3+4+5=15), resulting in a wrong graph.

  • Corrective Action: If the graph is incorrect, select only the absolute frequencies (D8:D13D8:D13). Then, use the "Select Data" command under the "Chart Design" tab to manually assign cells C9:C13C9:C13 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 B8:B13B8:B13 and relative frequencies in E8:E13E8:E13), 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 (E8:E13E8:E13).

    • 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., B2B2 which might contain "1=S"). Repeat for all 5 series.

  • Process 2: Text-Based Automation

    • Select both the text outcomes (B8:B13B8:B13) and relative frequencies (E8:E13E8:E13).

    • 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 (1,2,3...1, 2, 3...), 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:   =MODE(range)\text{=MODE}(range)

  • Caveat: If a dataset is multimodal (has more than one mode), the standard =MODE function 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 A1:A51A1:A51), 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 A2A2) 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 =COUNTIF and =SUM while 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.