1/103
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
X
the information you use to make a prediciton
Y
the outcome of what you want to predict
fitted line
summarizes the relationship between X and Y
Prediciton
the estimated value of Y for a particular X
Linear regression equation
Ŷ = α̂ + β̂XŶpredicted outcome is the value of Y the model predicts
α̂ (alpha hat)intercept, the predicted Y when X=0
β̂ (beta hat)the predicted change in Y when X increases by one unit
least squares
The model chooses the line that minimizes the sum of squared prediction errors by finding the line of best fit.
prediction error
vertical distance between an actual data point and the fitted line.
purpose of squaring errors
prevents positive and negative errors from canceling and penalizes larger errors more heavily.
lm()
fits a linear regression model
abline ()
adds the fitted line to a scatterplot
Y ~ X
predict Y using X
correlation
tells us the direction and strength of a linear relationship
positive correlation
as X increases, Y tends to increase
Negative correlation
as X increases, Y tends to decrease
Correlation near zero
little linear association, although a curved relationship may still exist
Correlation of +1 or −1
a perfectly linear relationship
linear probability model
A linear regression with a binary outcome
logistic regression
designed for binary outcomes
R²
coefficient of determination, measures the proportion of variation in Y explained by the model
coefficient of determination (R²)
R² = cor(X,Y)²
Higher R²
the model explains more of the variation in Y
R² = 1
the model explains 100% of the variation
R² = 0
the model explains none of the variation through a linear relationship
Straight line
learns two coefficients and captures the overall trend
Connect-the-dots
joins neighboring training observations, following individual data points much more closely
overfitting
when a model fits the peculiarities of a sample rather than the true underlying pattern, causing poor performance on new data
k-fold cross-validation:
cut the data into 𝑘 groups; each takes a turn as the test set; average the 𝑘 test errors, the lowest cross-validated error wins
neural network
many bent lines, glued together and stacked in layers
LASSO and ridge regression
many X’s, plus a penalty that shrinks the ̂𝛽s toward 0 to prevent overfitting
Decision trees and random forests
split the data into groups (e.g., under/over 30) and predict each group’s mean; a forest averages hundreds of trees
Large language models (ChatGPT, Claude)
neural networks with billions of ̂𝛽s, trained to predict the next word
features
predictors (𝑋)
target, label
outcome (𝑌)
weights and bias
slope(s) ̂𝛽 and intercept ̂𝛼
training a model
fitting it, e.g., with lm()
loss function
what we minimize: the sum of squared prediction errors
regression vs. classification
predicting a number vs. predicting a category
supervised vs. unsupervised learning
we observe 𝑌 vs. we only observe 𝑋 (e.g., finding groups of similar voters)
MEASURE:
To infer population characteristics via survey research (ex. what proportion of constituents support a particular policy)
PREDICT:
to make predictions (ex. who is the most likely candidate to win an upcoming election?)
EXPLAIN:
To estimate the causal effect of a treatment on an outcome (ex. what is the effect of small classrooms on student performance?)
Dataset
A collection of observations and variables
Observation
The unit or case represented by a row
Variable
A characteristic measured in the data
Unit of observation
The entity each observation represents
Unit of measurement
The scale or units in which a variable is measured
Binary variable
A variable with two possible values, often 0 and 1
Categorical variable
Places observations into categories
Quantitative variable
Measures a numerical quantity
The distribution of a variable
Which values occur
How often they occur
The distribution of a variable: center
Measured with:
Mean
Median
The distribution of a variable: spread
Variability in the data.
Measured with:
Range
Variance
Standard deviation
The distribution of a variable: skew
Direction of a long tail.
Right-skewed - tail right
Left-skewed - tail left
The distribution of a variable: peaks
Unimodal = one peak
Bimodal = two peaks
Mean
Mean = (Sum of all values) / (Number of values)
Mean of a Binary Variable
For a binary variable coded 1 and 0
Median
Middle observation after sorting
Mode
Most common value
Use the median when:
Data are skewed
There are outliers
Treatment Variable
The intervention or condition.
Examples:
Receiving campaign mail
Taking a drug
Outcome Variable
What is measured afterward.
Examples:
Voting
Recovery
Individual Causal Effect
Y(1)−Y(0)
the difference between a person's outcome with treatment, Y(1), and without treatment, Y(0)
Average Causal Effect (ACE)
Average of individual causal effects across all units.
E[Y(1)−Y(0)]
Fundamental Problem of Causal Inference
For any person we can observe:
Treatment outcome OR
Control outcome
But never both simultaneously.
Therefore: We never directly observe individual causal effects.
Selection Effects
People who choose treatment often differ from those who do not.
Example: People who exercise may already be healthier.
The difference you're seeing might be due to who chose the treatment, not the treatment itself.
Randomized Experiment
Researchers assign treatment randomly.
Advantages:
Eliminates selection effects
Strong causal evidence
Observational Study
Researcher only observes existing choices.
Disadvantages:
Confounding
Selection bias
Difference-in-Means Estimator
overline(Y)T−overline(Y)C
Treatment-group average minus control-group average.
Measures estimated treatment effect.
When is Difference-in-Means Valid?
when:
E[Y(0)|T=1]=E[Y(0)∣T=0]
Meaning groups are comparable before treatment.
Best way to guarantee this:
Random assignment
Checking Comparability
Compare pre-treatment characteristics:
Age
Income
Education
Gender
Prior behavior
Groups should look similar before treatment.
Percentage Points vs Percent
Example:
Treatment group voting: 45%
Control group voting: 40%
Difference:
45%−40%=5
Pros of Randomized Controlled Experiments
Strong causal evidence
Minimizes selection bias
Easy interpretation
Cons of Randomized Controlled Experiments
Expensive
Ethical concerns
Sometimes impractical
Limited external validity
Random Assignment
Creates comparable treatment/control groups.
Helps causal inference.
Random Sampling
Creates representative samples.
Helps population inference.
These are different concepts.
Valid Population Inferences need:
Representative sample
Probability sampling
Low nonresponse
Without representativeness, results may not generalize.
Nonresponse Bias
People who respond differ from those who don't.
Social Desirability Bias
People give socially acceptable answers rather than truthful answers.
Selection Bias
Sample differs systematically from population.
List Experiments Purpose:
Reduce social desirability bias when asking sensitive questions.
Respondents reveal only how many statements are true, not which ones.
Tables
Counts or percentages
Histogram
Shows distribution using bins
Density Plot
Smoothed histogram
Box Plot
Displays:
Median
Quartiles
Outliers
Variance
Average squared distance from the mean.
s²
Standard Deviation
Square root of variance.
s
Interpretation: Typical distance from the mean.
Scatter Plot
Plots:
X variable on horizontal axis
Y variable on vertical axis
Used to visualize relationships.
Curved Relationships
Strong nonlinear relationships can have correlation near 0.
Outliers
One outlier can dramatically change correlation.
Always plot your data.
Ecological Fallacy
Occurs when conclusions about individuals are drawn from aggregate data.
Example: State-level patterns may not apply to individuals.
The unit of observation matters.
Correlation Is Not Causation
Correlation alone does not establish causality because:
Reverse causation possible
Confounding variables possible
Least Squares Method
∑(Yi−Y^i)²
β̂ (Slope)
Expected change in Y from a one-unit increase in X.
Units:
(Units of Y)/(Units of X)
Binary Outcome Variables
Predictions are probabilities
Coefficients often interpreted in percentage points
Example:
β^=.03
A one-unit increase in X increases probability by 3 percentage points.
Extrapolation
Predicting beyond observed data.
Dangerous because the relationship may not continue.
Example: Estimating income for age 150.
R² (Coefficient of Determination)
Measures proportion of variation in Y explained by X.
Range:
0≤R²≤1
Interpreting R² = 0.4
Means:
40% of the variation in Y is explained by the model.
The remaining 60% is unexplained.