BA midterm 2

chp 10: summary measures

  1. central location

    • arithmetic mean

    • mode

    • median

  2. 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

  3. 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

  4. 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

  5. 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

  6. 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

  1. single categorical variable

    • frequency distribution table

    • bar chart/column chart

  2. 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)

  3. two categorical variables

    • contingency table

    • stacked bar chart/column char t - composition within each category

  4. two numerical variables

    • scatter plot

      • linear relationship

      • non linear relationship

      • no relationship

    • with 1 categorical variable = colour of bubble

  5. three numerical variables

    • bubble plot

      • third variable = size of bubble

  6. other representations

    • line chart (changes/ trends over time)

    • heat map

  7. 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

  1. 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

  2. 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

  3. measures of forecast error

    • MSE = βˆ‘ (𝑒𝑑)2 / n

    • MAD = βˆ‘ |𝑒𝑑| / n

    • MAPE = (1 / 𝑛) * βˆ‘ |𝑒𝑑| βˆ— 100 / 𝐷𝑑

  4. 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

  5. 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)

  6. 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

  7. 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?)

  8. 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)

  9. 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

  10. 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

  11. 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

  12. holt-winters

    • uses β€˜y’ for seasonality of the data

chp 15: python 14

chp 16: intro to ML

  1. ML - learn from data, local patterns in an iterative manner

    • stats - focus on average

    • ML - focus on individual

  2. 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

  3. 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

  4. unsupervised

    • k means clustering

      • break data into k clusters

      • data within cluster = similar, outside = different

      • method of measuring distance, scaling of data

  5. 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

  6. 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