Skip to content

From Variables to Data

Theory

Suggested Conceptual Reading & Discussion

Application

Variable Types & Levels of Measurement

Variables can broadly be categorized as either discrete or continuous.

  • Discrete variables are those that take on a countable number of values, meaning they can only be whole numbers. An example of a discrete variable is the number of voters in an election, which might be represented as 3,450 voters.
  • Continuous variables can take on an infinite number of values within a given range, allowing for more precise measurement. For instance, the time it takes for respondents to answer a survey can be a continuous variable, such as 2.5 minutes, indicating that time can be measured in fractions and is not limited to whole numbers.
Levels Description Example
Nominal Categories without any mathematical relation. Party Identification (e.g., Democrat Republican)
Ordinal Categories with a meaningful order but unequal intervals. Level of education (e.g., high school, bachelor's, master's, phd, ...)
Interval Numeric values with meaningful intervals but no true zero. Feeling Thermometer (e.g., survey responses on a scale from 0 to 100)
Ratio Numeric values with meaningful intervals and a true zero. Age of a respondent (e.g., 25 years old)

Let's practice:

  • Political Ideology - Measured on a scale (e.g., liberal to conservative)
  • Voter Turnout - Percentage of eligible voters who vote
  • Campaign Expenditure - Total amount of money spent on a campaign
  • Attitudes towards a government spending - Measured on a scale likert scale ranging from 1 to 7
  • Age of Respondents - Measured in categories (e.g. 18-25, 26-45, 46-65, 66+)
  • Gender - Categorical variable (e.g., male, female, non-binary, other)
  • Political Participation - Scale measuring levels of engagement (e.g., none, some, active)

With regards to your project idea

  • Identify the key concepts with regards to your project idea.
  • How are these concepts interrelated?
  • Translate them into variables (DV, IV, CV)

Code: Live Demo & Hands-on Lab

Student Group Live Demo (Group 2)

Hands-on Practice

  • Follow 📘 Running Python Scripts in VS Code to open and run interactive Python scripts.
  • Step 1: Head to the Course Materials and download the appropriate script(s) into your local data-analysis course folder.
  • Step 2: Open VS Code and practice working with core data structures (lists, dictionaries, pandas Series and DataFrames), calling functions, and inspecting basic survey variables using Smart Send (Shift+Enter).

Get Ready for Next Session: Think. Explore. Practice.

Think

Explore

  • Live Demo (Group 3): Data Acquisition & Column Inspection (reading ANES data, .shape, .info(), .describe(), column subsetting). Group 3 prepares a 10–15 min demonstration and shares the handout on WhatsApp before class (groups can book a meeting with the instructor to get direction).
  • The class should review the Course Materials and the Pandas Indexing and Subsetting Guide to follow along and lead the peer discussion.

Practice

  • Download the scripts from the Course Materials into your data-analysis folder to practice loading and exploring survey datasets.
  • Complete Milestone 2 - Proposal (Due Friday, Oct 23 at 08:00 before class via email).