Rohit Gajendragadkar
R Assignments (3) - 2%
Tutorial Quizzes (2) - 7%
Term Test 1 - 20%
Final - 60%
1 | Introduction to Statistical Sciences
1.1 | Empirical Studies and Statistical Sciences
Review: Binomial, Poisson, Multinomial, Normal / Gaussian, Uniform, Exponential
1.2 | Data Collection
Populations and Processes
- Population = collection of units
- Process = mechanism by which units are picked over period of time
Variates = Characteristics of units represented by variables ()
- Continuous (measurable, weight)
- Categorical (hair colors)
- Discrete (countable, presence vs absence of disease)
- Ordinal (small, medium, large)
- Complex (open-ended response)
Attributes = function of a variate defined for all units
- Ex: proportion of adults in Ontario who own a smartphone
- Ex: average drop in blood pressure due to a medical treatment
Approaches to data collection
- Sample Surveys
- General polls (“this poll is said to be accurate to within ” 19 times out of 20”)
Experiments and Observational studies
- It would be unethical to assign a person to drink and smoke all day
- Experiments are conducted with random assignment
- Eliminates bias (a systematic favoring of one outcome over another)
- Guards against confounding factors
1.3 | Data Summaries
Numerical Summaries
Summarizing numerical data
- Measures of location (mean, median, mode)
- Measures of variability and dispersion (sample variance, STD, range, IQR)
- Measures of shape (skewness, kurtosis)
Measures of location Sample mean (average)
Median (50th percentile)
Mode = most commonly occurring datapoint
Order statistics
Let . For let . The quantile (or percentile) of is defined as
For an odd number of observations, the median is defined as
For an even number,
Measures of variability
Sample Variance (where is the sample mean)
Sample standard deviation
Sample range:
Sample inter-quartile range:
Summary: Measure of variability
- Always non-negative
- Range, sample variance, sample std deviation are all susceptible to outliers
- IQR is is more robust, since it discards the most extreme 50%
Histograms Given a dataset , split its range into non-overlapping intervals (bins) for with
For each bin , let be the number of observations which fall into each bin. , since each observation in the dataset is counted exactly once.
The proportionality constant for the interval is usually 1 (frequency histogram), or (relative frequency / density histogram.
Measures of shape
Skewness = measures the symmetry / asymmetry of a distribution
- Right/positively skewed if most values are on the left side and there’s a longer tail on the right. In this case,
- Left/positively skewed if most values are on the right side and there’s a longer tail on the left. In this case,
- Symmetric if neither
Sample Skewness
- The denominator is always positive and accounts for the “scale”
- The numerator is positive (negative) if the contributions from the values over (under) are larger in magnitude, i.e. there is a long right (left) tail.
Kurtosis = measures the “heaviness” of the tails: how frequent the more extreme values are
Sample Kurtosis
- Kurtosis is always positive, and the numerator is larger when extreme values are common
- If kurtosis (), we say that the data has “heavier” (lighter) tails than normally distributed data
Summary: Measures of shape
- Measures of shape tell us what the relative frequency histogram should look like, eg. means the data looks similar to a normal distribution
- Measures of shape should be invariant under linear transformations
Graphical Summaries
Empirical cumulative distribution function (ecdf) Given a dataset , for all
(what fraction of the data is within a certain range)
Properties
- Is a stepwise increasing function
- Helps us determine
- If the data could have been generate by a specific probability model
- If two datasets are similar
- Remarks
- Horizontal separation means one dataset is consistently larger
- Steeper ecdf means less variability (more values concentrated in a smaller range)
- ecdf is the “integral” of the relative frequency histogram
- cdf is the “integral” of the pdf
1.4 | Probability Distributions and Statistical Models
Box Plots / Five number summary
- Lower whisker =
- Upper whisker =
- Anything outside the whiskers is considered an outlier
Other plots
- Run chart (to show change over time)
- Scatter plot (to show relationship between two variables)
Numerical Summaries
Sample correlation coefficient
- Numerator is positive when are above or below the mean at the same time
- Numerator is negative when one is above and one is below
- The denominator (multiplying the std) accounts for the scale of the data
Takeaways
- close to 1 in a linear relationship
- close to 1 with a positive relationship, and -1 with a negative relationship
- when no linear relationship or a non-linear relationship
Explanatory vs response variables (independent means something else)
- explanatory (independent) variate
- response (dependent) variate
1.5 | Data Analysis and Statistical Inference
Data Analysis and Statistical Inference
- Descriptive statistics + Exploratory data analysis
- Statistical inference
- Estimation
- Hypothesis testing
- Prediction
Motivation of Ch 2: Take random variable - one Bernoulli trial
Motivation of ECDF (stepwise chart)
Law of Large Numbers: ECDF converges to true CDF as
2 | Statistical Models and Maximum Likelihood Estimation
2.1 | Choosing a Statistical Model
STAT 230 Review
Cumulative Distribution Function (cdf) (non-decreasing)
Probability Mass Function (pmf)
Probability Density Function (pdf)
Splitting up expectation and variance
Statistical Models
Uppercase = random variable / Lowercase = observed value Let be a collection of independent and identically distributed (iid) random variables The observed data are realizations of random variables
Sample Mean
Suppose that for each , . Then
Derivation
Sample Variance
Simplify
Example: Smoking habits of teens
Example: Lifetime of brake pads “What proportion of brake pads fail within the first 100,000 km?”
2.2 | Point Estimates and Maximum Likelihood Estimation
Choosing a statistical model Determined by
- Background knowledge/assumptions
- Past experience
- A current dataset
Parametric family = family of distributions indexed by some parameter
Point Estimate A point estimate of a parameter is the value of a function of the observed data and known quantities such as the sample size . We use denote a point estimate of as
depends on the sample . Any function which only depends on the observed data and not any unknown parameters is called a statistic
Likelihood Function The likelihood function for is defined as
= parameter space = set of possible values for NOTE: this is a function of , NOT the observed data
Maximum Likelihood Estimate The value of which maximizes for some given data is called the MLE, and is denoted The MLE is an example of a point estimate and a statistic
Relative Likelihood Function
Log-Likelihood Function
Log Concavity A function is logarithmically concave if is a concave function
Likelihood examples:
- Write out the PMF using the selected distribution
- Simplify (can separate all constants because they get differentiated away)
- Log everything to get the log-likelihood function
- To find MLE, solve
- Plug in and solve for
2.3 | Likelihood Functions for Continuous Distributions
Recall: Likelihood for when data are iid with common pmf
Ex: Exponential Distribution (mean = )
Derive the likelihood function
Obtain the MLE by solving
Ex: Gaussian distribution
To maximize , solve
MLE of
MLE of
Given and , we can rewrite the formula for as
Derivation: Expand the bracket
2.4 | Likelihood Functions for Multinomial Models
nah
2.5 | Invariance Properties of Maximum Likelihood Estimates
Invariance Property of the MLE Let be any function. Suppose that is the maximum likelihood estimate for . Then, is the maximum likelihood estimation for .
Ex: Proportion of individuals over 2m in height (Gaussian MLE)
Ex: Observed vs Expected Frequencies (Poisson)
Expected frequency of particle emissions
Expected frequencies
Other way
2.6 | Checking the Model
Graphical Checks
- Superimposing plots
- Relative frequency histogram VS (theoretical) pdf
- ecdf VS (theoretical) cdf
- New check: (Gaussian) QQ (quantile-quantile) plot
- Motivation: straighten the ecdf plot (easier to check if a line is straight)
QQ Plots For a CRV with a strictly increasing cdf with , define the theoretical quantile function:
The quantile function is the inverse function of the cdf of . is the unique number which solves the equation
QQ Plots tell us about tail behavior of a dataset
- Grows faster than a straight line = heavy tail
- Grows slower than a straight line = light tail
- Grows like a straight line = normal distribution
Step 1: Propose a probability model for the observed data with common pmf/pdf Step 2: Write down the likelihood and log-likelihood functions
Step 3: Find the unique MLE by maximizing . is the unique solution to
Step 4: Perform diagnostic checks (checking model assumptions, checking observed vs empirical frequencies, graphical checks)
Binomial / Bernoulli model: trials of an experiment resulting in success or failure
- Each trial is independent with same probability of success
- Cannot use numerical / graphical summaries (binary outcomes)
Poisson: Assumes independence, individuality, homogeneity
- Can use graphical checks
Exponential: How long to wait for a next occurrence (has the memoryless property)
- Can use graphical (QQ plot should have a U-shape)
Gaussian / Normal: Used a lot
- Symmetric about mean (no skew), Sample mean sample median
- Sample skewness close to 0, sample kurtosis close to 3
- 68% of data within 1 std of mean, 95% within 2, 99.7% within 3
- Can use graphical checks
3 | Planning and Conducting Empirical Studies
3.1 | Empirical Studies
Aspects of Empirical Studies (PPDAC)
- Problem formulation
- Planning of an experiment
- Data collection
- Analysis of the data
- Conclusions
3.2 | The Steps of PPDAC
Problem Descriptive problem: Learn an attribute of a population Causative problem: Establish the existence (or non-existence) of a causal relationship between two variates. The explanatory variate causes a change in the response variate Predictive problems: We want to predict the value of a variate for some unit.
Target population / process The collection of units to which the experimenters conducting the empirical study wish the conclusions to apply.
Plan
Study population / process The collection of units available to be included in the study Sample = selecting a few units from the population with a sampling protocol
Study error Attribute in the study population / process - attribute in target population / process
Sample error Attribute in the sample - attribute in study population / process
Measurement error Measured variate value - true variate value
Data Data management = tracking and measuring data over long periods of time
Analysis and Conclusion
- Select an appropriate model
- Describe the Problem in terms of model parameters and properties
- Conclusion step answers questions posed in Problem
- Quantify or discuss potential errors in Plan, as well as limitations in conclusions
All models are wrong, but some are useful
- Models are simplifications of reality
4 | Estimation
4.1 | Statistical Models and Estimation
This chapter:
- How to estimate an interval for the unknown parameter ?
- How to quantify the probability that is in our constructed interval?
Recall: Point Estimates Likelihood function for random variables with common pmf/pdf :
A “good” guess for is the value which maximizes the likelihood function
Definition A (point) estimator is a random variable which is a function
of the random variables . The distribution of is called the sampling distribution of the estimator.
Recall: Normal / Gaussian Distribution Any linear combination of independent normal RVs is still normal
Example:
Recall: Central Limit Theorem
Suppose are iid, with with . Then, as ,
Takeaway: For large n,
Suppose we have a sequence of RVs , then we say that converges in distribution to , or if
4.2 | Estimators and Sampling Distributions
Interval Estimator An interval estimator is a random interval of the form
- = random lower bound
- = random upper bound
Coverage Probability:
- We want it to be high - tells us we are very likely to have lower and upper bounds
- We want the interval estimator to be narrow - constrains the value of more
- We fix this coverage to be some number - common choices include 0.9, 0.95, 0.99
- Then we construct a narrow interval estimator with coverage probability .
Definition Suppose is an interval estimator for , with coverage probability . Then, the interval estimate
is called a confidence interval for
The confidence interval is a realization of the (random) interval estimator
- Since it’s a function of observed data, we can’t make probability statements about it
- Interpretation: If we were to collect a sample many times, the true will lie in approximately of the confidence intervals we construct.
Example: Suppose with unknown but known. Construct an interval estimator for with coverage probability .
Our interval estimator is
Choose so the resulting intervals are as narrow as possible If we choose for some , then The narrowest interval is obtained when
When ,
is an interval estimator for with coverage probability of 0.95. If we performed this experiment infinitely, should be in the interval for 95% of experiments
Example: For a model with mean , the 95% CI is
- The width depends on
- As , the width , since more data is better
- If we want a higher coverage probability, the interval becomes wider (coverage probability of 1 means the interval would be the whole real line).
Pivotal Quantity A pivotal quantity
is a function of the data and the unknown parameter with known distribution.
To make an interval estimator, fix the coverage probability to be . Choose such that
4.3 | Interval Estimation Using the Likelihood Function
^
4.4 | Confidence Intervals and Pivotal Quantities
Gaussian example: ,
By CLT,
Takeaway
with is an interval estimator for with asymptotic coverage probability . A confidence interval for replaces with
Binomial example: . MLE is
Using the Normal approximation,
Dividing by :
We have A -coverage probability interval estimator is given by
A confidence interval replaces with
Word problem: Coin has probability of heads and flips 65/100 heads. What is a 95% confidence interval for ?
Model: , observed data , compute
Exponential example: .. MLE is
By CLT,
Interval estimator
Word problem: Lightbulb lifetime follows an exponential distribution with mean life . A sample of 50 were collected, with an average of . Give a 90% CI for .
Model: so our MLE is . A 90% CI is
Sample Size / Margin of Error: Candidate needs votes to win. Let be the number of voters,
Point estimator for has width
RHS is maximized when , so choosing
always guarantees that the width of the confidence interval is less than - the margin of error is
Tradeoff: Larger sample size means more accuracy because narrower confidence intervals, but is more expensive
4.5 | The Chi-squared and Distributions
Recap: Pivotal Quantities
- with known (exact)
- (asymptotic)
- (asymptotic)
- (asymptotic)
We use these because it’s hard to find the exact sampling distribution of our estimator A drawback is that these estimators attain the coverage probability if but are inaccurate otherwise
Chi-squared distribution A random variable X has a chi-squared distribution with k degrees of freedom, denoted if it has PDF
The fraction is a constant, ensuring that the integral over the range of equals 1
Properties
- - vertical asymptote at the y-axis
- - same pdf as
- - unimodal but asymmetric
- Always right-skewed
- For large ,
Theorem Let be a standard normal RV. Then
Recall: MGF of a random variable
- Uniqueness: If have the same MGF, they have the same distribution
- If independent, then
Theorem Let for and independent. Let . Then,
Corollary Suppose . Let . Then,
Sample Variance Estimator
Theorem Let and be the sample variance estimator. Then,
Recall , but if you square and sum them, you get the chi-squared So we have that
because are independent when the data comes from a normal distribution.
Student’s t distribution A random variable has a t distribution with k degrees of freedom if it has pdf
The fraction is again, a constant
Properties: Looks similar to a Gaussian
- Unimodal, with a peak at 0
- Symmetric about the y-axis
- As , the density of approaches the density of
- Heavy tailed: Tails decay polynomially while Gaussian tails decay exponentially
Theorem Let and independently. Let
Then .
Takeaways
- We use the chi-square distribution to construct a pivotal quantity in a Gaussian model
- The chi-square distribution is the limiting distribution for likelihood ratios
- We can use the t distribution to construct a pivotal quantity for in a Gaussian model when is unknown
4.6 | Likelihood-Based Confidence Interval
Definition For any , the 100p% likelihood interval for is the set
where is the relative likelihood function
The relative likelihood function depends only on instead of the individual . Then, we say is a sufficient statistic for .
uniroot(f, interval = (a,b)) finds a root on , but returns an error if has the same sign at both endpoints.
Log-relative likelihood function
100p% likelihood ratio for
Random Variables: = random likelihood = random relative likelihood
Wilk’s theorem special case: As ,
Likelihood ratio statistic
A 100% likelihood interval for is a 100q% confidence interval for , where
() is the quantile function of a standard normal Backwards: if we want our likelihood interval to correspond to a 100q% CI,
4.7 | Confidence Intervals for Parameters in the Model
Interval estimators for in a model
Interval Width
One-sided intervals
Quantiles of chi-squared (qchisq in R)
Pivotal quantity of
Interval estimator for in model ( unknown)
Prediction intervals in models Pivotal Quantity
Prediction interval estimator for
5 | Hypothesis Testing
5.1 | Introduction
Chapter 4: estimate the value or (or give a range for) the parameter Chapter 5: is a reasonable value?
Hypothesis Suppose we have . A hypothesis is a restriction on the value of the parameter
Null hypothesis () The “default” or “neutral” hypothesis, assumed to be true.
Alternative hypothesis () A hypothesis that competes with the null hypothesis, suspected to be true. Often the negation of
Test Statistic / Discrepancy Measure A non-negative function of the data constructed to measure the degree of “(dis)agreeement” between the data and null hypothesis
- = agreement
- = disagreement
p-value / observed significant level Probability of observing something as (or more) extreme than what was observed. = theoretical discrepancy, = observed discrepancy
Significance Level () Threshold such that if , we reject , else we fail to reject . Common choices are “How unlucky you’re willing to be” - how unlikely of a guess you’re willing to take on before being fine with a false positive
Ex: flipping a coin 100 times yields 56 heads (Binomial)
Example: Problem 5.2
Test statistic
p-value (calculated assuming is true)
Gaussian approximation
, so 25 is roughly 5 STD above the mean
5.2 | Hypothesis Testing for Parameters in the Model
Steps of hypothesis testing
- Model: the data are
- Null hypothesis: restrict the value of
- Discrepancy measures: small = agreement, large = disagreement
- Data: compute the observed value of the test statistic / discrepancy measure
- p-value: compute the probability (under of observing something something more extreme)
- Interpretation: reject / fail to reject: decide if evidence against is strong enough to reject or fail to reject
| Alternative hypothesis | Discrepancy measure | p-value |
|---|---|---|
Interval estimation Two-sided tests,
One-sided test,
Interval estimation, is a CI for
Hypothesis Testing Test statistic for in models: ( = sample variance, = hypothetical variance)
p-value
Hypothesis Testing with Gaussian Pivotal Quantities
5.3 | Likelihood Ratio Test of Hypothesis
Discrepancy measure / Likelihood ratio statistic
p-value
Likelihood ratio test statistic Under the null hypothesis,
HT and interval estimation CI for
6 | Gaussian Response Models
6.1 | Introduction
We know how to:
- Model: Variate , probability model indexed by parameter
- Data: Collect a sample which are realizations of iid RVs
- Estimation: Estimate the value of with points and intervals
- Test: Test hypotheses of the form
In an empirical study, the goal is to learn about the response variate (weight) They can be studied alone, or in combination with covariates or explanatory variates (height, gender)
Gaussian Response Model Distribution of the response variate given the associated vector of covariates , for an individual unit, is of the form
Linear Model
6.2 | Simple Linear Regression
Simple Linear Regression
MLE
Least Squares Estimation Sum of squared errors (SSE)
Parameters
- = mean response for a unit with covariate
- = change in mean response from increasing the covariate (ie. )
Pivotal quantity for CI / HT involving
Estimator
100p% CI, with
Test statistic
p-value
, and is computed with pt(d, df = n-2)
NEW STUFF Using the pivotal quantity
Interval estimator ()
100p& CI:
Mean response function Maps the covariate value to the mean response for that covariate. In SLR:
Has MLE with estimator
Pivotal Quantity
100p% CI
Pivotal Quantity for
100p% CI
Prediction interval for new data
6.3 | Checking the Model
Assumptions
- Mean response function is linear ()
- Homoscedasticity / homogenous variance assumption = Random errors are independent with common std
Residuals (not independent)
Standardized residuals
Residual plots for model checking
- Plot for
- Plot () for and
- Should be scattered evenly within a horizontal band above and below . Even number should be above and below 0
- If not, the linearity assumption is likely violated (U shape implies quadratic model)
- Plot a QQ plot of
- Should resemble a straight line with more variability at the ends
- If not straight or slope 1, variance is likely not constant (heteroscedasticity)
6.4 | Comparison of Two Population Means
Parameter estimation when
Pooled sample variance
Two-sample t-test Discrepancy for:
p-value
Two sample t-test when No nice distribution, must use estimator
7 | Multinomial Models and Goodness of Fit Tests
7.1 | Likelihood Ratio Tests for Multinomial
Expected frequency ( are the params)
LRT statistic
p-value; ()
Problems To find restricted MLE, write down likelihood in terms of
Observed value of test statistic:
- Create expected / observed frequency table
- Calculate p-value
7.2 | Goodness of Fit Tests
Pearson’s goodness of fit (Pearson’s chi-squared) test statistic:
p-value;
7.3 | Two-Way Contingency Tables
Testing for independence Row-totals
Column-totals
LRT statistic
Maximizing both terms
p-value
Testing for equality
Likelihood function
ML estimators
LRT statistic
p-value
Expected frequencies