SDA - TABLE OF CONTENT
LESSON 1-2 - 19-20/5...............................................................................................3
COST OF GOODS........................................................................................................................3
Smothering methods - line methods/ timeplot.........................................................................3
LESSON 3 - 21/5........................................................................................................ 5
Cost of goods................................................................................................................................ 5
CENTER TENDENCY AND DISPERSION.................................................................... 6
MATHS AND READING SCORES......................................................................................8
LESSON 4 - 22/5..................................................................................................... 10
SIMPLE LINEAR REGRESSION/ Model (=behaviour)....................................... 10
LESSON 5 - 23/5......................................................................................................14
SIMPLE LINEAR REGRESSION (cont).........................................................................14
Multiple R: correlation of Yi and Xi - Covariance....................................................................... 16
R square...................................................................................................................................18
Standard Error..................................................................................................................................................18
LESSON 6 - 26/5..................................................................................................... 19
MULTIPLE LINEAR REGRESSION..................................................................................19
Conditional Expectation............................................................................................... 19
MLR - Multiple Linear Regression.........................................................................20
Linear Assumption........................................................................................................... 21
LESSON............................................................................................................................................. 22
LESSON 9 - 2/6................................................................................................................................ 22
MLR - Transformation........................................................................................................................................ 22
1. Plotting.............................................................................................................................................................22
2. Transformation Y^i=Bo+B1Xi.............................................................................................................22
(1) Double log: LnY^i=B0+B1lnXi.................................................................................................. 22
(2) Semi-log: lin-log/log-lin: LnY^i=B0+B1Xi or Y^i=B0+B1lnXi.......................... 23
(3) Reciprocal: Y^i=B0+B1 * 1/Xi or 1/Y^i=B0+B1Xi......................................................... 23
(4) Standardized: StdY^i= B0+B1StdXi or we can have Std on 1 of the side...
23
(5) Under root model: Y^i=B0+B1 * sqrtXi..............................................................................24
(6) Polinomial model.......................................................................................................................... 24
(7) Logistic regression: Yi = Category....................................................................................... 24
Logistic regression...............................................................................................................................................24
Distribution...............................................................................................................................................................24
LESSON 10 - 3/6.........................................................................................................................24
Distribution.............................................................................................................................24
1
Bayesian................................................................................................................................ 25
Logistic...................................................................................................................................25
INTERPRET A REGRESSION SUMMARY TABLE.........................................................25
Regression Statistics....................................................................................................... 25
ANOVA Table................................................................................................................... 25
Coefficients Table.............................................................................................................26
Quick Rules of Thumb..................................................................................................... 26
Example Interpretation.....................................................................................................27
INTERPRET DUMMY VALUES....................................................................................... 27
1. Dummy Variables (Categorical Variables in Regression)............................................ 27
Key Points for Interpretation:..................................................................................... 27
How Dummy Variables Are Introduced in Regression & Key Commentary Points..........28
2. Key Points to Comment On............................................................................................... 29
A. Number of Dummies vs. Categories............................................................................29
B. Reference (Baseline) Category................................................................................... 30
C. Interpretation of Coefficients....................................................................................... 30
D. Interaction Terms (If Present)...................................................................................... 30
E. Potential Problems to Check....................................................................................... 30
3. Example Commentary....................................................................................................... 31
Summary Table: What to Check...................................................................................... 32
Ultimate Cheat Sheet: Interpreting Regression Coefficients (All Model Types)...............32
Summary Table................................................................................................................ 35
INTERPRET THE RESULTS........................................................................................... 36
2
LESSON 1-2 - 19-20/5
COST OF GOODS
Graph builder: banana + time
The train (avg) has gone up
Smooth train plot
Smothering methods - line methods/ timeplot
Spline: similar to linear smoothening, taking bunches of data instead of
1 data at once
Local Kernel: take smaller bunches of data compared to spline, more
variety than spline
3
Underfitting vs Overfitting
2 features
- Duration: long
- Volatility: low
=> linear
-Short duration - high: spline
Moving avg is used when data has seasonality in it. - exponential
Những phần xanh là range of value, chấm nằm ngoài là outlier value
Box plot
Compare the avg
Help you know the volatility (fluctuation)
4
Bananas: whiskey short, không cách nhau nhiều => giá của chuối
không disperse (không trải rộng mà ổn định)
Beef: whisker long => larger volatility (large spread of value)
Orange: có disperse nhưng không chaotic
Tomato: there was 2 months where price was highly inflated at that
point
Bread: many outliers => disturbing data. High volatility in the upper and
lower range
If the box is in the center (oranges - almost normally skewed) =>
skewness of the data
Positively skewed: milk, eggs, beef.
LESSON 3 - 21/5
Cost of goods
Graphical - ratio
1. Line plot (time)
2. Box-plot
5
- Dispersion
- Volatility
3. Histogram/ Distribution plot
- Avg value
- SD
- Skewness
- Kurtosis
CENTER TENDENCY AND DISPERSION
Estimate the approximate/expected value
1. Mean - best measure of central tendency / avg
- Some of all observation
- (-): when there are outlier, mean tends to shift
2. Median if and only if there are many outlier
- Location: 50th percentile
3. Mode
- Highest repetition
4. 25th percentile
5. 75th percentile
Trimming
- Use when there are many outlier
- Trimming at 5%: remove the lowest 5% and highest 5% values
- Trimming at 10%: remove the lowest 10% and highest 10% values
- Trim mean should be as close as the median
SD = Xi - Xbar
6
Method of moments
How disperse values from the mean
2nd moment around the mean is the variance => take the under root
and get Sd
Kurtosis
- How volatile the data is - how fluctuate the data is
7
Kb < Ka
- How disperse - how big the range of data
MATHS AND READING SCORES
- Shorter boxes - higher whisker => high volatility
- Box placing higher over time => better, higher scores
Columbia: worst
performing, high
disparity => huge
inequality
Massachusetts, New
Hampshire: best
performing, most of
the data is on the
upper percentile, not
highly dispersed =>
best example for other
states to look up to.
Michigan: least disperse
8
Nhìn theo cột dọc, so
sánh vạch ngang trong
khoảng 220-250 => biết
được điểm của bang
đó tăng hay giảm
9
LESSON 4 - 22/5
SIMPLE LINEAR REGRESSION/ Model (=behaviour)
(1)Relationship
f= Yi = dependent - ratio scale
Px = Xi = independent - ratio/categorical scale
Qdx= f(Price)
f - linear or nonlinear => check for the best fit
=> How does the line fit?
=> Best fit?
=> Tools to basically best fit?
Actual: Yi= f(Xi)
Yi - actual value
f - a line
Xi - actual of independent
10
^
Expected: 𝑌 𝑖 = β0 + β1𝑥𝑖
Y^i - expected value
Bo - intercept
B1 - slope
Yi (actual) - Y^i (expected) = ε𝑖 (error)
=> how to make a line such that error is minimized => best fitting
line.
Sum of the errors
𝑛 𝑛
^
∑ ε𝑖 = ∑ (𝑌𝑖 − 𝑌 𝑖) = 0
𝑖=1 𝑖=1
Sum of square error
2 ^ 2
𝑚𝑖𝑛∑ ε𝑖 = ∑ (𝑌𝑖 − 𝑌 𝑖)
Determine B0 and B1
2 2
∑ ε𝑖 = ∑ (𝑌𝑖 − β0 − β1𝑥𝑖)
2
δΣε𝑖
⇒ δβ0
= 0
2
δΣε𝑖
δβ1
= 0
11
RMSE as close to 0 as possible => assume good model
Example: slide 195
Expected value of B0i = B0
Zero null hypothesis
=> test whether or not Bo and B1 exist in the population (significant).
Test for the sample to know if that sample is representing the
population or not. If Ha is true, then it does represent.
H0: B0=0
12
Ha: B0#0
If H0: B0=0 => intercept insignificant value =0
If Ha: B0#0 => intercept significant, exist, value #0 (in short, we want Ha
to be true, H0 to be rejected)
In excel, compare p-value of the intercept to alpha=5%/2=0.025 (chia đôi
vì là 2 tailed testing)
Significant Bo B1 Diagrams
x x
13
LESSON 5 - 23/5
SIMPLE LINEAR REGRESSION (cont)
How much of the Yi is the regression (Yi=B0+B1Xi) able to capture?
Yi - Y^i: dot to the regression line
Total: Yi - Ybar: dot to the mean
line
Explained: Yi-Y^i
Unexplained: Y^i-Ybar
14
TSS = ESS + RSS
(ESS + RSS)/TSS = 1
TSS, ESS, RSS comes from the
anova table
15
whether the linear model was a good fitting model for the data or not?
=> Should I stick with linear or switch to non linear?
Multiple R: correlation of Yi and Xi - Covariance
(1)Covariance: joint variance between Xi and Yi (VarXi and VarYi)
Avg joint variance
If COV is
(+) : JD is positive
=0 : no joint dispersion
(-) : JD is negative
Joint dispersion
(2)Correlation
16
Correlation: Unitless, [-1;1]
~-1 => high negative relation of X and Y
(-0.9 => -0.7)
~1 => high positive relation of X and Y
(0.7 => 0.9)
~0 => no linear relation (0.0xxx)
17
R square
To see if the line model is a good fitting model or not?
Can be computed with regression only
Always positive [0;1]
~0: the line model is bad fitting
~1: the line model is good fitting
Tùy trường hợp
Mkt >0.4
Medical >0.85
Interpretation:
R^2=0.92175
92.175% of the determination of Yi from Ybar is explained by the
regression. => #~1 => high explained => line good!
Standard Error
Approximate Error
#6 Linear Regression:
- SLR
#7 Linear Regression
- MLR
- Transformation and model accuracy
- non linear model: logistic + others
#8,9 RV
#10,11 Bayian
18
LESSON 6 - 26/5
MULTIPLE LINEAR REGRESSION
Với 1 giá trị X thì có thể nhận được nhiều giá trị Y, cái này gọi là error
Y^i= b0 + b1Xi
Conditional Expectation
E(Yi)= sum Yi*pi
Contingency table/ Joint distribution table
y= 50 y= 60 y= 80 Marginal prob of X
f(x)
P(x= 100) 0.2 0.3 0.1 0.5
P(x= 200) 0.2 0.1 0.1 0.4
P(x=300) 0.05 0.025 0.005 0.1
Marginal prob of Y 0.45 0.325 0.225 1
f(y)
19
MLR - Multiple Linear Regression
Why add Xis? - More accurate, more considerate of more factors.
Y^i= Bo + B1Xi
Yi= Y^i + error
- Measurement error: Yi - Y^i
- Variable did not take the unobservable factors
How to add E(Yi/Xis)=?
SLR:
- Assumptions that we make in the background “good/best fitting”
must satisfy BLUE
BLUE - best linear unbiased estimation
(1)Unbiased:
Expected value of the estimator = population
(2)Linear
Y^i= Bo^1+B1^1*Xi
B must be to the power of 1. Y and X không bắt buộc phải là bậc 1
(3)Efficient
Variance of the estimator should be minimum
(4)Consistent
Expected value of the estimator
(5)Sufficient
(6)Asymptotic Normality
Least sq - Compute method to get the best intercept slope
intercept = Bo
20
Slope =b1
Linear Assumption
1. E(ei)=0 => show that the regression is unbiased
Overall, the error=0
2. E(ei/Xi)=0 => show that the regression is unbiased
There is no relationship between the error and the Xi
3. Linear
Parameter (Bo) must be linear.
4. Homoscedasticity
The variance of the error is constant V(ei)=constant
5. No multicollinearity
Making sure that BLUE is maintained
6. No autocorrelation
Autocorrelation: (ei, ej)=0
Errors tại các điểm giá trị X không bị phụ thuộc vào nhau.
7. No model simplification error
The fitting of the model - there should not be any fitting problem (no
over/under fitting)
8. Normality
21
2
Error (ei) is ND (0, σ )
4+ 8: At each point of X, the error is normally distributed
LESSON
LESSON 9 - 2/6
MLR - Transformation
Y^i=b0 +b1X1i + b2x2i + b3Di
Relationship: x and y
Model: when put a line to the graph
1. Plotting
2. Transformation Y^i=Bo+B1Xi
(1)Double log: LnY^i=B0+B1lnXi
Differentiate: 1/y change in y/change in x = b1* 1/x
change rate: b1= (change y/y)/(change x/x)
22
=> growth rate (%change y/%change x) = b1
Slope : b1 = change y/change x
(gdp output)
(2)Semi-log: lin-log/log-lin: LnY^i=B0+B1Xi or Y^i=B0+B1lnXi
(eg2 jmp)
(3)Reciprocal: Y^i=B0+B1 * 1/Xi or 1/Y^i=B0+B1Xi
Y^i=B0+B1 * 1/Xi Y^i=b0+b1xi
B1 >0 => relation will be inverse
Slope: differentiate
Change Y/Change X= - b1 *1/X^2 => vẫn còn X nên slope will be
dependent on which point the slope is at. Change is not constant
(4)Standardized: StdY^i= B0+B1StdXi or we can have Std on 1 of
the side
Stdx: (xi-xbar)/SDx
Stdy: (yi-ybar)/SDy
23
Std Y^i=b0+b1* stdX1 + b2*stdX2 +...
Trong các giá trị b, ví dụ b1 lớn nhất trong b1,b2,b3 thì stdX1 is the most
important variable of Y.
(5)Under root model: Y^i=B0+B1 * sqrtXi
Positive relationship => line đi lên
When X goes up, Y goes up slowly. Càng lên cao càng lên chậm. Nó
cũng đi lên và đi thẳng như Y^i bình thường nhưng sẽ hơi cong một tí.
Close to line vì move slowly
Vì có sqrt nên weaker linear regression.
Slope: diff
B1= 1/2sqrtXi
(6)Polinomial model
Not close to the line, vì move intensely,faster.
Y^i^b=B0+BiXi^a
Slope: B1= aXi^a-1
(7)Logistic regression: Yi = Category
Logistic regression
Distribution
LESSON 10 - 3/6
Distribution
Binom
Negative binomial (geometric)
Hyper geometric
24
Bayesian
Logistic
INTERPRET A REGRESSION SUMMARY TABLE
Regression Statistics
Metric What It Tells You Good Range Warning Signs
Multiple R Correlation between actual 0 to ±1 (closer to Near 0 = weak
and predicted values ±1 = stronger) relationship.
(strength/direction of linear
relationship).
R-Square % of variation in Y explained 0.7-1 (strong), <0.3 = poor fit
(R²) by X variables. 0.3-0.7 (but context
(moderate) matters!).
Adjusted R² adjusted for # of Same as R² but Much lower
R² predictors (penalizes more reliable than R² =
useless variables). with multiple X. overfitting.
Std. Error Avg. distance of data points Smaller = better High value =
from regression line (no strict ran large prediction
(precision of predictions). errors.
ANOVA Table
Metric What It Tells You Good/Bad
F-statistic Tests if the model is Good: F > critical value (check
statistically significant (at F-distribution table) or
least one X matters). p-value < 0.05.
25
Significance F Probability that the model is Good: p < 0.05 (reject null).
(p-value) useless (all β = 0). p<0.05 is significant
Coefficients Table
Metric What It Tells You Good/Bad
Intercept Predicted Y when all X = 0. Context-dependent (may or
may not be meaningful).
X Coefficients Change in Y per 1-unit Good: Significant (p-value <
change in X (holding other X 0.05) and intuitive sign.
constant).
p-value Probability that the Good: p < 0.05 ("statistically
coefficient is 0 (no effect). significant").
t-stat Coefficient / Std. Error t>~2=significant
(measures signal-to-noise). (≈ p < 0.05).
Lower/Upper Confidence interval for the Good: Interval excludes 0
95% coefficient. (significant).
Quick Rules of Thumb
✅ Strong Model:
● R² > 0.7 (or Adjusted R² close to R²).
● F p-value < 0.05.
● Most X variables have p-values < 0.05.
⚠️ Weak Model:
26
● R² < 0.3.
● F p-value > 0.05 (model is useless).
● Many X variables with p-values > 0.05.
🔍 Check for Problems:
● Multicollinearity: If coefficients flip signs or SEs are huge (check
correlations between X variables).
● Autocorrelation: If Durbin-Watson (not in Excel by default) is far from 2
(1.5-2.5 is okay).
Example Interpretation
Suppose you get:
● Multiple R = 0.85 → Strong linear relationship.
● R² = 0.72 → 72% of Y’s variation explained.
● Adjusted R² = 0.70 → No overfitting.
● F p-value = 0.001 → Model is significant.
● Coefficient for X1: 3.5 (p = 0.02) → X1 has a significant positive effect on Y.
Conclusion: The model is strong and X1 matters!
INTERPRET DUMMY VALUES
1. Dummy Variables (Categorical Variables in Regression)
Dummy variables are binary (0/1) variables used to represent categorical data
in regression models.
Key Points for Interpretation:
● Purpose:
○ They allow the inclusion of qualitative (non-numeric) variables
(e.g., gender, region, treatment groups) in regression models.
● Reference Category (Baseline Group):
27
○ If a categorical variable has *k* categories, you need *k-1* dummy
variables (to avoid the dummy variable trap).
○ The omitted category serves as the reference group.
○ Example:
■ If "Gender" has Male (0) and Female (1), the coefficient on
Female measures the difference relative to Male.
● Interpretation of Coefficients:
○ The coefficient on a dummy variable represents the average
difference in the dependent variable between the dummy
category (1) and the reference category (0), holding other
variables constant.
○ Example:
■ If the coefficient for Female is +2.5, it means females have,
on average, a 2.5-unit higher outcome than males (if the
dependent variable is in levels).
● Interaction Terms with Dummies:
○ If you interact a dummy with a continuous variable (e.g., Female ×
Education), the effect of the continuous variable differs by group.
○ Example:
■ If the interaction term is significant, it means the slope of
Education differs between males and females.
● Avoiding Multicollinearity:
○ Do not include all *k* dummies for *k* categories (leads to perfect
collinearity).
○ Use one as the baseline.
How Dummy Variables Are Introduced in Regression & Key
Commentary Points
When a question asks you to "Comment on the way the dummies have been
introduced in the model," you should analyze:
1. How many dummies were created (based on the number of
categories).
2. Which category was omitted (reference group).
3. Interpretation of coefficients (comparison to the baseline).
28
4. Potential issues (collinearity, omitted variable bias).
There are three main methods to include dummy variables in regression:
Method Description Example (Gender:
Male, Female,
Non-Binary)
1. Dropping One - Create (k-1) dummies Female (0/1), NonBinary
Category (Baseline for k categories. (0/1)
Approach)
- One category is left (Reference: Male)
out (reference).
2. Including All - Creates perfect Male (0/1), Female (0/1),
Categories (Dummy multicollinearity NonBinary (0/1) → BAD
Trap)❌ (regression fails).
- Never do this!
3. Effect Coding - One category is coded Female (1), NonBinary (0),
(Alternative to Dummy as -1 instead of 0. Male (-1)
Coding)
- Coefficients show
deviations from grand
mean.
2. Key Points to Comment On
When asked to analyze how dummies were introduced, check:
A. Number of Dummies vs. Categories
● If a variable has k categories, there should be k-1 dummies.
29
○ Example:
■ Education (High School, Bachelor, Master, PhD) → 3
dummies (one omitted).
■ If you see 4 dummies, there’s a dummy trap (problem!).
B. Reference (Baseline) Category
● Identify which group was left out (e.g., "Male" if Female=1 is included).
● Interpretation:
○ "The coefficient on Female measures the difference relative to
Males."
C. Interpretation of Coefficients
● Positive coefficient → Higher outcome than the baseline.
● Negative coefficient → Lower outcome than the baseline.
● Example:
○ If Female = 2.3 (p < 0.05), females earn $2.3K more than males (if Y is
salary).
D. Interaction Terms (If Present)
● If dummies interact with other variables (e.g., Female × Experience), the
effect differs by group.
● Example:
○ Female × Experience = -0.5 → Women get less salary growth per year
of experience than men.
E. Potential Problems to Check
30
1. Dummy Variable Trap → Too many dummies (k instead of k-1).
2. Omitted Variable Bias → Wrong reference group distorts results.
3. Multicollinearity → If dummies are highly correlated (check VIF).
3. Example Commentary
Question: "Comment on how the dummy variables were introduced in this
wage regression."
Model:
● Wage = β₀ + β₁(Female) + β₂(Master’s Degree) + β₃(PhD) + ...
Response:
1. Correct Specification:
○ Gender: Only Female is included (reference = Male).
○ Education: Master’s and PhD included (reference = Bachelor’s).
2. Interpretation:
○ Female = -1.2 → Women earn $1.2K less than men, ceteris paribus.
○ PhD = 5.0 → PhD holders earn $5K more than Bachelor’s.
3. No Dummy Trap:
○ No redundant dummies (e.g., no "Male" or "Bachelor’s" dummy).
4. Possible Improvement:
○ Could test interactions (e.g., Female × PhD) to check for gender pay
gaps at higher education levels.
31
Summary Table: What to Check
Aspect What to Look For Good Practice Red Flags
# of k-1 dummies for k ✅ 3 categories ❌ 3 categories → 3
Dummies categories. → 2 dummies. dummies (trap!).
Reference Clearly defined ✅ "Male" ❌ No clear
Group baseline (omitted omitted if baseline.
category). Female=1.
Coefficient Logical direction (e.g., ✅ PhD > ❌ PhD has
Signs higher education → Bachelor’s. negative
higher pay). coefficient.
Interaction Check if effects vary ✅ Female × ❌ No interactions
Terms across groups. Experience. if needed.
Ultimate Cheat Sheet: Interpreting Regression Coefficients (All Model
Types)
This guide covers linear, log-linear, linear-log, log-log, and dummy variables in
regression.
32
33
34
Summary Table
Aspect What to Check Good Practice Red Flag
Number of k-1 dummies for k 3 categories → 2 3 categories → 3
Dummies categories. dummies. dummies.
Reference Clearly defined (e.g., *"Female=1 implies No omitted
Group "Male" omitted). Male=0."* category.
Coding 0/1 for 1=Urban, 0=Rural. 1=Urban, 2=Rural.
Scheme absence/presence.
Interpretation Coefficients = difference *"Female=0.5 → +0.5 No comparison to
from baseline. vs. Male."* baseline.
35
INTERPRET THE RESULTS
36
37
38
39
Key Tips
1. Log Models: Use %Δ for intuition, exact for precision.
2. Dummies: Always identify the reference group.
3. Interactions: Test if effects differ across groups.
4. Quadratic Terms: Check for turning points.
40
41
42
43
44