1. Hello Data

a. Data and Variables

Yurk

What is Data?

Data are systematic observations or measurements collected to understand the world around us.

Why study data?

  • Make informed decisions based on evidence
  • Understand patterns and relationships
  • Draw conclusions beyond what we directly observe

Our First Dataset: loan50

Context:

  • Source: Lending Club (major peer-to-peer lending platform)
  • Data: A sample of 50 loans from the platform

We’ll use loan50 to ground the concepts introduced today.

Data Frames

Statistical data is organized in data frames — rectangular tables with rows and columns.

The loan50 dataset (first 6 loans)
loan_amount interest_rate term grade state total_income homeownership
22000 10.90 60 B NJ 59000 rent
6000 9.92 36 B CA 60000 rent
25000 26.30 36 E SC 75000 mortgage
6000 9.92 36 B CA 75000 rent
25000 9.43 60 B OH 254000 mortgage
6400 9.92 36 B IN 67000 mortgage

This rectangular structure is universal across statistical software and analysis.

Cases and Variables

loan_amount interest_rate term grade state total_income homeownership
22000 10.90 60 B NJ 59000 rent
25000 26.30 36 E SC 75000 mortgage
25000 9.43 60 B OH 254000 mortgage
3000 17.09 36 D NY 28800 rent
  • Each row is one case — the highlighted row is one loan. 50 cases total.
  • Each column is one variable — the highlighted column is loan grade. (loan50 has 18 variables; 7 shown here.)

Variable Types: Two Main Categories

Numerical variables — values are numbers where arithmetic operations make sense

  • Examples from loan50: loan_amount, interest_rate, term

Categorical variables — values indicate different levels or categories

  • Examples from loan50: grade, state, homeownership

Types and Subtypes

Each variable type splits into two subtypes:

Variable Subdivisions: Numerical

Numerical variables:

  • Discrete: countable values with gaps between them
    • Example: term (months — always a multiple of 12; loan50 has 36 and 60)
  • Continuous: any value in a range
    • Example: interest_rate (could be 7.20%, 7.21%, 7.215%, …)

Variable Subdivisions: Categorical

Categorical variables:

  • Ordinal: levels have natural ordering
    • Example: grade (A is better than B, B better than C, etc.)
  • Nominal: no natural ordering
    • Example: state (Michigan vs Ohio vs Texas)

Classifying loan50 Variables

Classify each variable (numerical vs. categorical, then the subtype):

Variable Type
loan_amount numerical, continuous
interest_rate numerical, continuous
term numerical, discrete
grade categorical, ordinal
state categorical, nominal
total_income numerical, continuous
homeownership categorical, nominal

References