BA midterm 2
chp 10: summary measures
central location
arithmetic mean
mode
median
other location
percentile
weighted mean = (w1x1 + w2x2 + β¦ + wnxn) / (w1+ .. + wn)
geometric mean = (x1 * x2 * x3 β¦. * xn)1/n
5 NUMBER SUMMARY: min, q1, q2, q2, max β think BOXPLOT
dispersion
range = max - min
IQR = Q3 - Q1
mean absolute deviation = β |π₯πβmean| / π
variance
sample = β (π₯πβmean)2 / πβ1
population = β (π₯πβmean)2 / N
standard deviation
sample = (β (π₯πβmean)2 / πβ1)1/2
population = (β (π₯πβmean)2 / N)1/2
coefficient of variance = std dev * 100 /mean
sharpe ratio = (mean - Rf) / std dev
shape
kurtosis
leptokurtic - slender, longer tails (return distribution)
mesokurtic - mid
platykurtic - broad, shorter tails
kurtosis coefficient
normal distribution: 3 (0 for excess)
more extreme tails: more than 3 (>0 for excess) leptokurtic, more extreme tails than normal
less extreme tails: less than 3 (<0 for excess) platykurtic, less extreme tails than normal
skewness
left/negative - left tail is longer < 0
right/positive - right tail is longer > 0
symmetric - equal = 0
association (strength, direction of relationship)
covariance
sample covariance = (β (π₯πβmean)(yi-mean) / πβ1)
population covariance = (β (π₯πβmean)(yi-mean) / N)
positive: + linear relationship
negative: - linear relationship
zero: NO linear relationship
correlation (removes ambiguity of units)
sample correlation = sxy / sxsy
population correlation = Sxy / SxSy
1 = all points lie exactly on the same line with + slope
1 = all points lie exactly on the same line with - slope
0 = no strong linear relationship
outliers
boxplots (not bell shaped)

empirical rule (bell shaped)
68% = mean +- s
95% = mean +- 2s
100% = mean +-3s
standardization (bell shaped, symmetric)
z score = (xi - mean ) / s
unitless
bring all variables to same scale
z > 3 or < -3 β outlier
IQR
if value exists beyond 1.5 x IQR + Q3 and 1.5 x IQR - Q1 β outlier
chp 11: python 10
chp 12: data viz
single categorical variable
frequency distribution table
bar chart/column chart
single numerical table
frequency distribution table
intervals β mutually exclusive, exhaustive, easy to recognize and interpret, number of intervals = [5,20]
histogram
no gaps
symmetric, skewed (left/negative, right/positive)
two categorical variables
contingency table
stacked bar chart/column char t - composition within each category
two numerical variables
scatter plot
linear relationship
non linear relationship
no relationship
with 1 categorical variable = colour of bubble
three numerical variables
bubble plot
third variable = size of bubble
other representations
line chart (changes/ trends over time)
heat map
important notes:
use simplest graph
axes should be clearly marked
same width for each bar
vertical axes upper limit shouldnβt be too high or stretched so data appears more pronounced
chp 13: python 12
chp 14: time series forecasting
time series data
data recorded over time
observed data point (O) = systematic component (S) + random component (R)
level: current, de-seasonalized demand
trend: long term rate of growth
seasonality: predictable swings repeated over a relatively short period of time, such as within a year
cyclic: wavelike fluctuations lasting for long periods of time
noise: random variation that cant be explained
forecasting
objective
filter out noise to estimate systematic comp
laws
the forecast is always wrong - forecast should include a point prediction and measure of accuracy
short term forecast is more accurate than long term - easy to predict things earlier in time
fan chart
historical + forecast values
dark blue = 50%
medium blue = 75%
light blue = 95%
aggregate forecasts more accurate than disaggregate forecasts
types
qualitative - forecasting models based on subjective human judgement
jury of expert opinions - group experts decide the estimate (easy, fast BUT expensive, who to choose?)
delphi method - experts complete questionnaires anonymously, summarized by moderator who can revise (cheaper BUT iterative so takes time)
customer surveys - ask customers (accurate if honest BUT expensive, fake)
time series forecast - historical demand to predict future demands
casual models - use regression to predict future based on function of external factors
measures of forecast error
MSE = β (ππ‘)2 / n
MAD = β |ππ‘| / n
MAPE = (1 / π) * β |ππ‘| β 100 / π·π‘
moving average
no seasonal factor and trend
5 period mav β y5 = (y1+y2+y3+y4) / 4
larger m β smoother forecast but slow to react to changes
exponential smoothing
no seasonal factor and trend
gives weight to observations that decreases as obs get older
yπ‘+1 = πΌπ¦π‘ + πΌ(1βπΌ)π¦π‘β1 + πΌ(1βπΌ)2π¦π‘β2 + πΌ(1βπΌ)3π¦π‘β3 +β― β theory formula
yπ‘+1 = πΌπ¦π‘ +(1 βπΌ)π¦Μπ‘ β USE IN EXAM!!
forecast for t + 1 = a (observed t) + (1-a) (forecast t)
πΌ = 0, we ignore new data, forecast is constant; = 1 ignore all past forecast and only use most recent forecast/obs
larger a β less smooth forecast trend, more sensitive to recent changes
most common (0.01, 0.5)
linear trend model
no seasonality
yt = b0 + b1t + et β line of best fit (regression)
with seasonality
βsβ different seasons = quarters, weeks, days, etc
create a time index t
create s-1 dummy variables (3 vars for 4 quarters in a yr)
yt = b0 + b1d1 + b2d2 + b3d3 + b4t
casual models + time series regression
exploits relationships between variables, and not just the time period t
yt = b0 + b1d1 + b2d2 + b3d3 + b4t + b5x
x = casual variable (maybe budget?)
exponential trend models
multiplicative growth over time
no seasonality
ln(yt) = b0 + b1t
create natural log of y and run regression on that
yt = e (b0 + b1t + et)
e = std.error2/ 2
with seasonality
yt = e (b0 + b1d1 + b2d2 + b3d3 + b4t + et)
polynomial trend models
no seasonality
yt = b0 + b1t + b2t2 + et
create t, t2
use adjusted r2 values for error
with seasonality
yt = b0 + b1d1 + b2d2 + b3d3 + b4t + b5t2 + et
data partitioning and model selection
80 train 20 test
train on early, test on new
after model is selected, use ALL data to make future predictions
holt - double exp smooth/holt exp smooth
creates a prediction based on exponential smoothing for unadjusted forecast
uses βbβ for the trend of the data β slope estimation (upward/downward trend)
ππ‘+1 = π½(π¦Μπ‘+1 β π¦Μπ‘) + (1 β π½)ππ‘
trend adjusted forecast π§π‘+1 = π¦Μπ‘+1 + ππ‘+1
a = 0.2, b = 0.15 generally
holt-winters
uses βyβ for seasonality of the data
chp 15: python 14
chp 16: intro to ML
ML - learn from data, local patterns in an iterative manner
stats - focus on average
ML - focus on individual
types of ML
supervised - input and output data
classification - NN, logistic regression, random forest, naive bayes, SVM
regression - SVM, NN, random forest
unsupervised - input data ONLY
clustering - k means
dimensionality reduction - PCA
dimensionality reduction
dimension - features, columns
dimensionality reduction - condensing dataset but preserving info
variance - no variation = no information
PCA
all potential linear combinations of features
combinations that 1. spread data the most 2. represent new information
uses high variance to indicate information
unsupervised
k means clustering
break data into k clusters
data within cluster = similar, outside = different
method of measuring distance, scaling of data
supervised
quality input data
data β known input and output data used to predict future outputs
goal β good predictions for new data

partition β training data β validation data β testing data β new data
linear regression
y = mx + b β line of best fit, minimizes sum of squared errors
r2 = the amount of variation that can be explained in y (100% = every point lies on the line)
p value
small β strong statistical relationship between variables
large β weak relationship between variables
classification
categorical outcomes
logistic regression
p(success) = 1 / (1+ e-1(mx+b))
decision trees
intuitive split of the data
leaves and root nodes
overfitting (learning of trends) - use pruning, minimum error trees
ensemble methods
random forest: builds a series of trees in parallel using a sample of the training data and averages the outputs for a final prediction
gradient boosting: series of sequential trees, built to correct
drawback: black box model
classification accuracy
accuracy = % of correct classifications
sensitivity / recall = true positive rate = correctly predicted positive / actual positive predictions
specificity = true negative rate = correctly predicted negative / actual negative predictions