Probability Statistics

Cover

Lecture13-14_RSS.pdf

📚 Lecture13-14_RSS.pdf

Brief overview

This document introduces the mathematical underpinnings of regression models, focusing on the concept and calculation of residual sum of squares. Understanding RSS is crucial for evaluating the fit of regression models to data.

Key points

  • Mathematical formulation of regression models
  • Definition and calculation of residuals
  • The formula for residual sum of squares (RSS)
  • Relationship between observed and predicted values

1. Mathematical formulation of regression models

1.1 Model definition and residuals

Regression models aim to predict an observed value, yy, using a set of input features, XX, and model parameters, ww. The model's prediction for yy is denoted by y^\hat{y}.

This prediction is calculated as a linear combination of the features and their corresponding weights.

  • Model prediction: y^=Xw\hat{y} = Xw
  • Features matrix (XX): Contains the input variables.
  • Parameter vector (ww): Contains the model weights.

The difference between the observed value yy and the predicted value y^\hat{y} is called the residual. Residuals represent the error of the model for a specific observation.

  • Residual for an observation: e=y−y^e = y - \hat{y}
  • Residual vector (ee): Contains residuals for all observations. e=y−Xwe = y - Xw. This is a vector where each element is yi−⟨xi,w⟩y_i - \langle x_i, w \rangle.

1.2 Residual sum of squares (RSS)

The Residual Sum of Squares (RSS) quantifies the total error of the model across all observations. It is calculated by summing the squares of all individual residuals.

Minimizing RSS is a common objective in regression to find the best-fitting parameters.

RSS(w)=∑i=1Mei2=∑i=1M(yi−⟨xi,w⟩)2RSS(w) = \sum_{i=1}^{M} e_i^2 = \sum_{i=1}^{M} (y_i - \langle x_i, w \rangle)^2

This can also be expressed in matrix notation as:

RSS(w)=(y−Xw)T(y−Xw)RSS(w) = (y - Xw)^T (y - Xw)

  • yy: Vector of observed values.
  • XX: Matrix of input features.
  • ww: Vector of model parameters (weights) 1.

🔑 Important: The goal in many regression analyses is to find the parameter vector ww that minimizes the Residual Sum of Squares (RSS), effectively making the model's predictions as close as possible to the actual observed data.

📝 Example: If a model predicts a house price of 300,000 dollars and the actual price was 320,000 dollars, the residual is 20,000 dollars. Squaring this and summing across all houses helps us evaluate the overall model performance.

🔑 Important: Minimizing RSS(w)RSS(w) is equivalent to minimizing the squared error between observed and predicted values. This is the foundation of Ordinary Least Squares (OLS) regression.

🔑 Important: The dimension of the residual vector ee is M×1M \times 1, where MM is the number of observations. The dimension of the parameter vector ww is (d+1)×1(d+1) \times 1, where dd is the number of features.

Cover

lecture 1-corrected.pdf

1. Course introduction and hypothesis testing fundamentals

This section summarizes the introductory material covering the course outline, the fundamental procedure of statistical hypothesis testing, and a detailed review of the one-sample t-test, including its non-parametric alternative, the Wilcoxon Signed-Rank test.

1.1 Course Outline and Lecture Overview

The course, HLST 2302 3.0 Statistical Methods in Health Studies II, begins by introducing the structure of the course and immediately delves into statistical concepts. The first lecture focuses specifically on the One-sample t-test and differentiates between parametric tests and their non-parametric counterparts. Subsequent topics scheduled include comparisons between two groups, independent t-tests, paired t-tests, and effect size calculations using Cohen's d 2 5.

1.2 Recap of Hypothesis Testing Fundamentals

Hypothesis testing is the primary method of statistical inference used to ascertain whether an observed difference between samples, or between a sample and a known population value, is attributable to random sampling error or reflects a genuine underlying effect. This method relies on establishing two competing hypotheses: the null hypothesis (H0H_0), which posits no effect, no difference, or no association, and the alternative (research) hypothesis (H1H_1), which reflects the investigator's belief. The entire process is designed to use information derived from a carefully selected sample to draw reliable conclusions about the entire target population 6.

This diagram illustrates the process of statistical inference where a sample is drawn from a target population to infer the behavior of the entire population.

The standardized steps for executing a hypothesis test are as follows 12 7:

  1. State the null hypothesis (H0H_0) and the alternative hypothesis (H1H_1).
  2. Select an appropriate test statistic and determine its corresponding sampling distribution.
  3. Compute the value of the test statistic using the collected sample data.
  4. Calculate the p-value and compare this value against the pre-determined significance level, α\alpha.
  5. Formulate a conclusion, deciding whether to reject or fail to reject the null hypothesis.

1.3 Review of the One-Sample t-Test

The one-sample t-test is employed to determine if the mean (xˉ\bar{x}) calculated from a single sample significantly deviates from a hypothesized population constant (μ\mu) when the true population standard deviation (σ\sigma) is unknown.

Example: An investigator tests if the mean weight of men in 2006 (μ\mu) is greater than the reported 2002 mean of 191 pounds.

  • H0H_0: μ=191\mu = 191
  • H1H_1: μ>191\mu > 191

Given a sample (n=100n=100) with a mean xˉ=197.1\bar{x} = 197.1 and a sample standard deviation s=25.6s = 25.6, with α=0.05\alpha = 0.05. The test statistic calculation proceeds as follows:

z=xˉ−μ0sn=197.1−19125.6100=6.12.56=2.38z = \frac{\bar{x} - \mu_0}{\frac{s}{\sqrt{n}}} = \frac{197.1 - 191}{\frac{25.6}{\sqrt{100}}} = \frac{6.1}{2.56} = 2.38

The resulting p-value is calculated as P(xˉ>197.1)=1−P(z<2.38)=1−0.9913=0.0087P(\bar{x} > 197.1) = 1 - P(z < 2.38) = 1 - 0.9913 = 0.0087. Since p-value=0.0087<α=0.05p\text{-value} = 0.0087 < \alpha = 0.05, the null hypothesis is rejected 8.

Calculation of the z-score for a one-sample t-test example.

The key characteristic defining the t-distribution, used in the one-sample t-test, is its degrees of freedom (df), which for this test is calculated simply as df=n−1df = n - 1. The t-distribution is a continuous probability model that resembles the standard normal distribution but adjusts its shape based on the sample size via the degrees of freedom.

A comparison of the standard normal z-distribution with t-distributions having different degrees of freedom (df), illustrating how the t-distribution becomes flatter and wider as df decreases.

A critical assumption of the t-test is that the variable of interest is approximately normally distributed in the population. Although the sample size in the previous example (n=100n=100) is large enough that the t-distribution closely approximates the z-distribution, the t.test() function in R is still appropriately used for this scenario9.

Cover

Lecture 1 - Introduction-to-Statistics.pdf

Table of contents

  1. Descriptive and History of Statistical Science DC-EC SP: Descriptive and Inferential Statistics
  2. Statistics as a Science
  3. Differences based on tools
  4. Descriptive vs. Inferential Statistics

1. Descriptive and History of Statistical Science DC-EC SP: Descriptive and Inferential Statistics

1.1 Definition of statistics

Statistics is defined as a branch of science dedicated to the processes of data collection, organization, analysis, interpretation, and presentation. The term itself has historical roots in Latin, Italian, and German, relating to councils of state, statesmen, politicians, and data about a state 3.

1.2 Data processes in statistics

The core processes within statistics involve several key stages:

  • Data collection: This is the gathering of relevant information, typically achieved through methods like sampling or conducting a census 4.
  • Data organization: This stage involves classifying, validating, and arranging the collected data in a systematic manner 5.
  • Data analysis: Here, various statistical tools, tests, and methods are employed to extract meaningful information from the data 6.
  • Data interpretation: This process focuses on deriving insights and understanding from the analyzed data 7.
  • Data presentation: The final step is communicating the results of the statistical process to others 8.

1.3 Statistics as a science

Statistics is distinct from mathematics, operating on different principles. While mathematics is deductive and deals with general, abstract truths that may not directly apply to the real world, statistics is inductive and concerned with probable truths derived from real-world data 9.

1.4 Aspects of statistics

Statistics can be viewed through two main lenses:

  • Theoretical Statistics: This aspect focuses on the development, derivation, and proof of statistical theorems and formulas.
  • Applied Statistics: This aspect involves the practical application of these theorems and formulas to solve real-world statistical problems 10.

1.5 Branches of statistics

Statistics is broadly divided into two main branches:

  • Descriptive Statistics: This branch deals with organizing, displaying, and describing data using tools like tables, graphs, and summary measures.
  • Inferential Statistics: This branch uses sample results to make predictions or draw conclusions about a larger population 11.

1.6 Population and sample

  • Population: This refers to the entire group that forms a set of data, including all its members.
  • Sample: This is a subset of the population, containing only a few members. Samples are used to represent the characteristics of the population 11.

📝 A survey of 1,000 employees to understand job satisfaction involves collecting data. Analyzing this data to find the average satisfaction score is descriptive statistics, while using this average to estimate the job satisfaction of all workers in the industry is inferential statistics 13.

2. Statistics as a Science

2.1 Aspects of statistics

Statistics encompasses two primary aspects: theoretical and applied. Theoretical statistics is concerned with the development and proof of statistical theorems and formulas, forming the mathematical foundation of the field.

Applied statistics, on the other hand, focuses on using these theorems and formulas to address and solve practical problems encountered in the real world 10.

2.2 Branches of statistics

The field of statistics is divided into two main branches: descriptive and inferential statistics.

  • Descriptive Statistics: This branch focuses on summarizing and presenting data in a meaningful way. It involves organizing data, using tables and graphs, and calculating summary measures to describe the characteristics of a dataset.
  • Inferential Statistics: This branch uses data from a sample to make predictions, draw conclusions, or generalize findings about a larger population 11.

2.3 Population and sample

  • Population: The population is the complete set of individuals or items that are of interest in a study.
  • Sample: A sample is a subset of the population that is selected for study. Samples are used because it is often impractical or impossible to collect data from an entire population 11.
Cover

Lecture%203%20logistic%20regression.pdf

Table of contents

  1. Logistic regression predictions and extensions
  2. Missing data
  3. Examples
  4. What we’ve learned so far
  5. Test yourself
  6. Coming up

1. Logistic regression predictions and extensions

1.1 Recap: Modelling a binary outcome

Logistic regression is employed when the outcome variable is binary, typically coded as 0 (absence) or 1 (presence). This type of data originates from a binomial or Bernoulli distribution.

The model utilizes a logit link function to connect the probability of the outcome to a linear combination of predictor variables, with parameters estimated via maximum likelihood 3.

  • Binary data distribution: Y follows a Binomial or Bernoulli distribution, Y∼B(n,p)Y \sim B(n, p), where P(Y=y)=(ny)py(1−p)n−yP(Y=y) = \binom{n}{y} p^y (1-p)^{n-y}.
  • Logit link function: The core of logistic regression relates the log odds of the outcome to a linear predictor: log⁡(p1−p)=logit(p)=β0+β1X1+⋯+βkXk\log\left(\frac{p}{1-p}\right) = \text{logit}(p) = \beta_0 + \beta_1X_1 + \dots + \beta_kX_k 3.

1.2 Recap: Simple logistic regression one continuous X

In simple logistic regression with one continuous predictor (X1X_1), the log odds of the outcome are linearly related to X1X_1. The intercept (β0\beta_0) represents the expected log odds when X1=0X_1=0, and its exponentiation (exp⁡(β0)\exp(\beta_0)) gives the expected odds.

The coefficient β1\beta_1 quantifies the change in log odds per unit increase in X1X_1, while exp⁡(β1)\exp(\beta_1) represents the odds ratio, indicating the multiplicative change in odds 4.

📝 For a male (where SexFemale=0\text{Sex}_{\text{Female}}=0) in the model log⁡(p^(hypertension=yes)1−p^(hypertension=yes))=−1.12−0.93×SexFemale\log\left(\frac{\hat{p}(\text{hypertension} = \text{yes})}{1-\hat{p}(\text{hypertension} = \text{yes})}\right) = -1.12 - 0.93 \times \text{Sex}_{\text{Female}}, the log odds of hypertension is −1.12-1.12 12.

1.3 Recap: Simple logistic regression one categorical X

When the predictor (X1X_1) is categorical, the intercept (β0\beta_0) represents the expected log odds of the outcome in the reference group. The coefficient β1\beta_1 represents the difference in log odds between a specific category and the reference category, and its exponentiation (exp⁡(β1)\exp(\beta_1)) is the odds ratio comparing that category to the reference 5.

📝 For a male aged 59 in the model logit(p^(hypertension=yes))=−3.22+0.05×Age−1.05×SexFemale\text{logit}(\hat{p}(\text{hypertension} = \text{yes})) = -3.22 + 0.05 \times \text{Age} - 1.05 \times \text{Sex}_{\text{Female}}, the log odds of hypertension is −3.22+0.05×59−1.05×0=−0.27-3.22 + 0.05 \times 59 - 1.05 \times 0 = -0.27 13.

1.4 Recap: Multiple logistic regression

Multiple logistic regression extends the model to include multiple predictor variables (X1,…,XkX_1, \dots, X_k), either to enhance predictive accuracy or to control for confounding factors. The intercept (β0\beta_0) represents the expected log odds when all predictors are zero.

Each coefficient βk\beta_k represents the adjusted change in log odds for a unit increase in XkX_k, holding all other variables constant 6.

1.5 Recap: logistic regression inference

Hypothesis testing for a coefficient βk\beta_k typically involves testing H0:βk=0H_0: \beta_k = 0 against HA:βk≠0H_A: \beta_k \neq 0. Confidence intervals (CIs) for βk\beta_k are constructed using the estimated coefficient and its standard error.

For large samples, the Wald 95% CI for βk\beta_k is β^k±1.96×SE(β^k)\hat{\beta}_k \pm 1.96 \times \text{SE}(\hat{\beta}_k) on the log odds scale. Exponentiating the bounds of this CI provides the CI for the odds ratio 7.

1.6 Model predictions

Fitted logistic regression models can be used to generate predictions on various scales: the log odds scale, the odds scale, and the probability scale. Predictions on the log odds scale are a direct result of the linear predictor β^0+β^1X1+⋯+β^kXk\hat{\beta}_0 + \hat{\beta}_1X_1 + \dots + \hat{\beta}_kX_k 8.

1.7 Probability prediction

To predict probabilities, the odds are first calculated as odds=exp⁡(β^0+β^1X1+⋯+β^kXk)\text{odds} = \exp(\hat{\beta}_0 + \hat{\beta}_1X_1 + \dots + \hat{\beta}_kX_k). The probability p^\hat{p} is then derived from the odds using the formula p^=odds1+odds\hat{p} = \frac{\text{odds}}{1 + \text{odds}}, which simplifies to p^=exp⁡(β^0+⋯+β^kXk)1+exp⁡(β^0+⋯+β^kXk)\hat{p} = \frac{\exp(\hat{\beta}_0 + \dots + \hat{\beta}_kX_k)}{1 + \exp(\hat{\beta}_0 + \dots + \hat{\beta}_kX_k)}.

This is equivalent to applying the inverse logit function, p=exp⁡(x)1+exp⁡(x)p = \frac{\exp(x)}{1+\exp(x)}, where xx is the linear predictor 9.

The inverse logit function ensures that predicted probabilities are always between 0 and 1. However, it is crucial to note that probabilities do not change linearly with predictor variables; the relationship is sigmoidal 10.

![This line graph illustrates the sigmoid function, showing how the output probability approaches 1 as the input increases and 0 as the input decreases.](https://ixscdoswnqhohheqmami.supabase.co/storage/v1/object/public/documents/b865b7d1-7f21-457f-9137-917ecf8ab6ba/courses/ff822a28-bc0b-4723-b129-acad0036ca49/figures/a

Cover

Lecture%204%20logistic%20regression.pdf

Table of contents

  1. Logistic regression model validation
  2. Checking model assumptions

1. Logistic regression model validation

1.1 Recap: Model predictions

The fitted logistic regression model allows for predictions on various scales, enabling different interpretations of the model's output. The choice of scale depends on whether the primary goal is prediction or explanation 3.

  • Log odds scale: The linear combination of predictors, logit^(p)=β^0+β^1X1+⋯+β^kXk\hat{\text{logit}}(p) = \hat{\beta}_0 + \hat{\beta}_1X_1 + \dots + \hat{\beta}_kX_k.
  • Odds scale: The exponentiated log odds, p^/(1−p^)=exp⁡(β^0+β^1X1+⋯+β^kXk)\hat{p}/(1-\hat{p}) = \exp(\hat{\beta}_0 + \hat{\beta}_1X_1 + \dots + \hat{\beta}_kX_k).
  • Probability scale: The logistic function applied to the linear predictor, p^=exp⁡(β^0+β^1X1+⋯+β^kXk)1+exp⁡(β^0+β^1X1+⋯+β^kXk)\hat{p} = \frac{\exp(\hat{\beta}_0 + \hat{\beta}_1X_1 + \dots + \hat{\beta}_kX_k)}{1 + \exp(\hat{\beta}_0 + \hat{\beta}_1X_1 + \dots + \hat{\beta}_kX_k)}.
  • Binary scale: A classification of 0 or 1 based on a chosen threshold 3.

1.2 Recap: Prediction or explanation

The purpose of a statistical model dictates the validation approach. Whether the model is intended for prediction or explanation influences the metrics and procedures used to assess its performance and reliability 4.

  • Predictive modeling: Aims to estimate the outcome (YY) given predictors (XX) as accurately as possible, focusing on predicting new observations.
  • Explanatory modeling: Aims to understand the relationship between XX and YY, often testing causal theories and focusing on inference 4.

📝 For explanatory modeling, if each hour spent revising increases the odds of passing Biostats II by a factor of 2.5, this describes the relationship between revision hours and passing odds 4.

1.3 Logistic regression model assumptions

Several core assumptions underpin logistic regression, which are crucial for valid inference and reliable predictions. Violations of these assumptions can lead to biased estimates and inaccurate conclusions 5.

  • Binary outcome: The dependent variable must be binary, representing two distinct categories.
  • Distribution: The outcome variable is assumed to follow a Bernoulli or binomial distribution.
  • Linearity: A linear relationship must exist between the predictor variables and the log odds of the outcome.
  • Independence: Observations must be independent of each other.
  • Other considerations: While not core assumptions, issues like outliers, high leverage points, influential points, and multicollinearity can affect model performance and should be examined 5.

1.4 Residuals in logistic regression

Residuals in logistic regression are used to assess model fit and identify potential issues, though they do not follow the same distributional assumptions as in linear regression. Two commonly used types are Pearson and Deviance residuals 6.

  • Pearson residual: Calculated as the difference between the observed outcome and the predicted probability, scaled by the standard deviation of the predicted probability.
  • Deviance residual: Derived from the difference in log-likelihoods between the current model and a saturated model. It is the default residual for Generalized Linear Models (GLMs) in R and is important for goodness-of-fit assessments 6.

1.5 Deviance

Deviance quantifies the discrepancy between a fitted model and a saturated model, serving as a measure of goodness of fit. A smaller deviance indicates a better fit to the data 7.

  • Definition: Deviance (DD) is calculated as −2-2 times the difference between the log-likelihood of the current model and the log-likelihood of a saturated model (D=−2(logLcurrent−logLsaturated)D = -2(\text{log}L_{\text{current}} - \text{log}L_{\text{saturated}})).
  • Interpretation: A saturated model has as many parameters as observations, perfectly fitting the data. If the current model fits perfectly, its log-likelihood will equal that of the saturated model, resulting in a deviance of zero.
  • Model improvement: As predictors are added to a model, it generally approaches the fit of the saturated model, leading to a decrease in deviance 7.

2. Checking model assumptions

2.1 Checking model assumptions

Traditional residual plots, commonly used in linear regression, are not directly applicable or informative for logistic regression due to the nature of the outcome variable and the model's assumptions. Alternative methods are required to assess key assumptions 8.

  • Limitations of traditional plots: Standard residual plots (e.g., residuals vs. fitted values, Q-Q plots) are not suitable for logistic regression 8.
  • Focus on core assumptions: The primary focus for checking assumptions in logistic regression shifts to the linearity of predictors with log odds and the independence of observations 9.

2.2 Checkin

Cover

Lecture 2 - Descriptive Statistics-2.pdf

📚 Lecture 2 - Descriptive Statistics-2.pdf

Brief overview

This document introduces fundamental descriptive statistics for summarizing and understanding data. It covers how to classify data types and presents methods for visualizing data distributions and quantifying their spread.

Key points

  • Overview of variable types and frequency distributions
  • How to describe the center of a data distribution
  • Measures of data variability and dispersion
  • Effective data presentation using tables and graphs

1. Understanding variable types and frequency distributions

1.1 Variable types

  • Variable: A characteristic that can take on different values.

  • Qualitative variables: Data that describe qualities or categories. They cannot be ordered meaningfully.

  • Dichotomous variables: Qualitative variables with only two possible categories. Example: Yes/No.

  • Nominal variables: Qualitative variables with more than two categories where order does not matter. Example: Marital status.

  • Ordinal variables: Qualitative variables where categories can be ordered, but the differences between them are not meaningful. Example: Health status (e.g., poor, fair, good).

  • Quantitative variables: Data that represent numerical quantities.

  • Discrete variables: Quantitative variables that can only take specific, separate values, often whole numbers. Example: Number of friends.

  • Continuous variables: Quantitative variables that can take any value within a given range. Example: Height or weight.

Variable types guide the choice of statistical methods.

1.2 Frequency distributions

  • Frequency distribution table: Organizes data by showing how often each value or category occurs.
Variable TypeDescriptionExample
DichotomousTwo categoriesYes/No
Nominal (Categorical)Categories, order doesn't matterMarital status
OrdinalOrdered categories, unequal intervalsHealth status (e.g., poor, fair, good)
DiscreteCountable, separate numerical valuesNumber of Facebook friends
ContinuousAny value within a range, measurableAge, height
  • Relative frequency: The proportion of times a specific value or category appears in the dataset. It estimates the likelihood of an outcome 2.
  • Cumulative frequency: The sum of frequencies for a given value and all preceding values.
  • Cumulative relative frequency: The sum of relative frequencies for a given value and all preceding values 5.

Frequency tables summarize raw data for easier interpretation.

1.3 Describing central tendency

  • Descriptive statistics: Numerical summaries used to describe the main features of a dataset 1.
  • Central tendency: A measure indicating the center or typical value of a distribution.
  • Key measures: mean, median, and mode 8.

Central tendency helps us understand the "average" or "typical" value in data.

1.3.1 The mean

  • Mean: The arithmetic average of a dataset. Calculated by summing all values and dividing by the number of values (NN).

  • Formula: xˉ=ΣX÷N\bar{x} = \Sigma X \div N. xˉ\bar{x} represents the sample mean, Σ\Sigma is the sum, XX are the data values, and NN is the number of observations.

  • Population mean is denoted by μ\mu 9 .

  • When mean is not ideal:

  • Sensitive to outliers, which can distort the "typical" value.

  • Less representative when data are skewed .

The mean represents the balance point of the data.

1.3.2 The median

  • Median: The middle value in an ordered dataset, dividing it into two equal halves .
  • Calculation:
  • Order data from smallest to largest.
  • If NN is odd, the median is the middle value.
  • If NN is even, the median is the average of the two middle values .

The median is the 50th percentile.

  • Advantages
Cover

Lecture 2 - Exploratory Data Analysis.pptx

1. Foundational concepts and historical context of exploratory data analysis

Exploratory Data Analysis (EDA) is the essential preliminary approach in data science focused on summarizing the principal characteristics of datasets, primarily through visual methods, serving to guide subsequent modeling by allowing the data to "speak" before formal hypothesis testing begins.

1.1 Defining Exploratory Data Analysis (EDA)

EDA is fundamentally an analysis of data with an open perspective, intended to uncover structure, detect anomalies, and generate preliminary hypotheses before assuming any specific probability model applies. This contrasts sharply with confirmatory analysis, which focuses on rigorously testing pre-existing, defined hypotheses.

The core objectives of EDA include:

  • Understanding Data Structure: Identifying variable types and underlying distributions.
  • Detecting Anomalies: Locating errors, inconsistencies, and outliers within the dataset.
  • Uncovering Patterns: Revealing underlying trends, inherent clusters, and potential relationships.
  • Informing Hypotheses: Developing testable questions that guide more rigorous statistical modeling.

John Tukey famously likened EDA to detective work, where graphical and numerical clues are gathered from the data before firm conclusions are drawn.

A futuristic interface displaying data visualizations, including a holographic globe overlaid with network lines and various charts on the side panels.

1.2 EDA within the Analytics Framework

EDA holds a foundational position across the spectrum of data analytics maturity, which is often categorized into three types: descriptive, predictive, and prescriptive analytics.

  1. Descriptive Analytics (What has happened?): EDA is central here, using summary statistics and visualizations to describe past events and the current state of the data.
  2. Predictive Analytics (What will happen?): EDA identifies relevant patterns and relationships necessary for building robust forecasting models, such as regression or time series analysis.
  3. Prescriptive Analytics (How to make it happen?): Insights derived from EDA help inform the optimization and decision support systems that recommend concrete actions.

Without thorough EDA, all subsequent analytical stages are constructed upon potentially unstable or misunderstood data.

1.3 Historical Context and the Father of EDA

The philosophical and methodological groundwork for modern EDA was established by John Tukey (1915–2000), a pivotal statistician. Tukey championed a shift away from purely rigid hypothesis testing toward flexible, iterative data exploration.

Tukey’s key contributions centered on developing resistant statistical methods (methods less influenced by outliers) and powerful graphical displays that could reveal data structure without strong distributional assumptions. He emphasized the power of visualization, stating that the greatest value of a picture forces us to notice the unexpected.

The timeline of EDA development progressed through several key phases:

  • 1970s: Preliminary editions of Tukey’s EDA materials circulated.
  • 1977: Publication of the landmark book, Exploratory Data Analysis.
  • 1980s–1990s: Conceptual support formalized, and techniques began integrating into major statistical software packages like S-PLUS and SAS.
  • 2000s onward: The emergence of powerful open-source environments (R and Python) fueled rapid expansion in visualization capabilities, leading into the modern era of automated EDA tools.

Tip: Remember the historical context: EDA was developed precisely because standard frequentist statistics struggled to reveal underlying data structure without imposing rigid models first.

1.4 Core Analytical Approaches in EDA

EDA is typically executed through a progression of analytical lenses, moving from simple to complex relationships.

Univariate Analysis

This focuses on analyzing a single variable.

  • Non-Graphical Analysis: Uses measures of central tendency (mean, median, mode) and spread (standard deviation σ\sigma, variance σ2\sigma^2, Interquartile Range (IQR)). It also assesses distribution shape via Skewness, which measures asymmetry (Skewness=E[(X−μ)3]/σ3Skewness = E[(X - \mu)^3] / \sigma^3), and Kurtosis, which measures tail heaviness (Kurtosis=E[(X−μ)4]/σ4Kurtosis = E[(X - \mu)^4] / \sigma^4).
  • Graphical Analysis: Utilizes visualizations like Histograms (for frequency distribution), Box Plots (to show the five-number summary: minimum, Q1, median, Q3, maximum, and outliers), and Density Plots (KDE) for smooth distribution representation.

Bivariate Analysis

This involves examining the statistical relationships between two va

Cover

lecture 2.pdf

1. Introduction to hypothesis testing and non-parametric methods

This section summarizes the review of standard hypothesis testing steps, the rationale for selecting non-parametric tests, and provides a detailed walkthrough of the Mann-Whitney U test (Wilcoxon Rank-Sum test), including its corresponding effect size calculation using Pearson's rr 1.

1.1 Recap of hypothesis testing steps

Hypothesis testing follows a defined sequence of steps to draw statistically sound conclusions:

  1. State the null hypothesis (H0\text{H}_0) and the alternative hypothesis (H1\text{H}_1).
  2. Choose an appropriate test statistic and determine its sampling distribution.
  3. Compute the value of the test statistic based on the collected sample data.
  4. Calculate the pp-value and compare it against the chosen significance level (α\alpha).
  5. Draw a conclusion, deciding whether to reject the null hypothesis or not 3.

1.2 Parametric versus non-parametric tests

The primary consideration when choosing a statistical test involves assessing the nature of the data and its distribution. Parametric tests rely on specific assumptions about the population distribution (like normality), whereas non-parametric tests are less restrictive, making them suitable for different data conditions.

Parametric tests typically assume normality, homogeneity of variance, and independence of observations, often exemplified by T-tests and ANOVA. Conversely, non-parametric tests are employed when these assumptions are violated or when the data structure is inherently ordinal or nominal.

Non-parametric methods are necessary in the following situations:

  • Ordinal or nominal variables: When data can only be ranked or ordered (e.g., Likert scale responses ranging from 1 to 5), not measured numerically on a continuous scale.
  • Scale variables with violations: When dealing with scale data where the population normality is unknown, especially with small sample sizes (e.g., n<30n < 30).

Non-parametric tests achieve robustness by transforming scale data into ranks (treating them as ordinal data), which mitigates the influence of outliers and skewness 4.

Tip: The decision process for selecting a test involves considering the number of groups being compared, whether the groups are independent or repeated, the nature of the variable of interest (scale vs. ordinal), and the distribution assumptions if the variable is scale.

The relationship between these test types, categorized by the number of groups, is visualized in summary charts 5 6. A comparison chart detailing the assumptions and examples for Parametric Tests versus Non-Parametric Tests. This table outlines common statistical tests categorized by whether they are parametric or non-parametric, based on the number of groups (1, 2, or ≥3) and whether the groups are independent or repeated. This table summarizes the appropriate statistical test to use based on the number of groups (1, 2, or ≥3) and whether the data is parametric or non-parametric, and whether the groups are independent or repeated.

1.3 Mann-Whitney U test (Wilcoxon Rank-Sum Test)

The Mann-Whitney U test, equivalent to the Wilcoxon Rank-Sum test, is used to compare two independent groups. Its fundamental goal is to evaluate whether the distribution of scores in one group tends to be systematically higher or lower than the distribution in the other group.

The hypotheses are stated as:

  • H0\text{H}_0: The two populations have the same distribution (no difference in distributions).
  • H1\text{H}_1: The two populations do not have the same distribution (one tends to have higher or lower values) 7.

1.3.1 Steps for the Mann-Whitney U test

The test operates by replacing raw data values with their corresponding ranks. Consider an example comparing fatigue scores (ordinal scale 1 to 7) between an intervention group (Group 1) and a waiting list group (Group 2) 8.

The procedure involves ranking all observations combined across both groups:

  1. Combine and Rank Data: All scores are pooled, and ranks are assigned from smallest (rank 1) to largest.
  2. Handling Tied Scores: When two or more observations share the same score, they are assigned the av
Cover

Lecture 3 - Error VS Mistake.pdf

Table of contents

  1. Error vs mistake
  2. Types of errors
  3. Sources of errors
  4. Precision vs accuracy
  5. Most probable value
  6. Standard error of the mean
  7. Relative precision
  8. Error of a product

1. Error vs mistake

1.1 Mistake

A mistake is a difference from a true value caused by the surveyor's inattention. These inaccuracies result from carelessness, poor judgment, or improper execution during surveying operations 1.

1.2 Error

An error is the difference between the true value and the measured value of a quantity. Errors can arise from imperfections in a person's senses, faulty equipment, or environmental factors like weather 1.

2. Types of errors

2.1 Systematic errors

Systematic errors consistently have the same sign and magnitude as long as field conditions remain constant. These errors are predictable and repeatable under specific conditions 2.

2.2 Accidental errors

Accidental errors are purely random and occur by chance, meaning they can be either positive or negative. These errors tend to compensate or average out over many observations, following the laws of probability 2.

📝 Slight, unpredictable variations in reading a leveling rod due to atmospheric shimmer are accidental errors; some readings might be slightly high, others slightly low, and they tend to cancel out over many observations.

3. Sources of errors

3.1 Instrumental errors

Instrumental errors are caused by imperfections in the surveying equipment itself. These can include manufacturing defects or wear and tear on the instruments 3.

📝 A transit with a misaligned vertical circle will consistently produce incorrect vertical angle readings, leading to instrumental errors.

3.2 Natural errors

Natural errors result from variations in natural phenomena. These environmental factors can affect measurements in unpredictable ways 3.

📝 Temperature changes causing expansion or contraction of a steel tape introduce natural errors in distance measurements.

3.3 Personal errors

Personal errors stem from the limitations of the human observer's senses, such as sight, touch, and hearing. These limitations can lead to erroneous or inaccurate observations 3.

📝 An observer's inability to consistently bisect a target with a crosshair due to visual fatigue can lead to personal errors in angular measurements.

4. Precision vs accuracy

4.1 Precision

Precision refers to the degree of refinement or consistency within a group of observations. It is evaluated based on the size of discrepancies among repeated measurements 4.

4.2 Accuracy

Accuracy denotes how close observed quantities are to their true values. It measures the absolute nearness of a measurement to the actual, correct value 4.

ScenarioDescription
Precise but not accurateMeasurements are consistent with each other but deviate significantly from the true value.
Precise and accurateMeasurements are consistent with each other and very close to the true value.
Neither precise nor accurateMeasurements are inconsistent with each other and far from the true value.

5. Most probable value

5.1 Most probable value (MPV)

The most probable value (MPV) is the quantity that has a higher chance of being correct than any other, based on the available data. It is typically calculated as the arithmetic mean of a series of measurements 5.

MPV=Xˉ=X1+X2+X3+⋯+XnnMPV = \bar{X} = \frac{X_1 + X_2 + X_3 + \dots + X_n}{n}

5.2 Standard error

The standard error estimates the likely accuracy of a number based on the sample size. It quantifies the dispersion of individual measurements around the MPV 5.

E=±Σv2n−1=±Σ(MPV−x)2n−1E = \pm \sqrt{\frac{\Sigma v^2}{n-1}} = \pm \sqrt{\frac{\Sigma (MPV - x)^2}{n-1}} The residual (vv) is the difference between the MPV and an individual measurement (xx), calculated as v=MPV−xv = MPV - x 5.

📝 After calculating the MPV for a series of distance measurements, the standard error can be computed by finding the sum of the squared residuals (differences between each measurement and the MPV), dividing by n−1n-1 (where nn is the number of measurements), and taking the square root.

6. Standard error of the mean

6.1 Standard error of the mean (EmE_m)

The standard error of the mean (EmE_m) indicates the size of the likely discrepancy when compared to that of the largest population. It represents the precision of the sample mean as an estimate of the population mean 6.

Em=±Σ(MPV−x)2n(n−1)=±Σv2n(n−1)=±EnE_m = \pm \sqrt{\frac{\Sigma (MPV - x)^2}{n(n-1)}} = \pm \sqrt{\frac{\Sigma v^2}{n(n-1)}} = \pm \frac{E}{\sqrt{n}}

Cover

Lecture 3 - Simple Linear Regression.pptx

1. Introduction to predictive analytics and regression

This section introduces predictive analytics as a method to forecast future trends by analyzing historical data, explores various mathematical functions used in predictive models, and details the fundamental principles of regression analysis, particularly simple linear regression, as a statistical tool for understanding and quantifying relationships between variables.

1.1 Predictive analytics

Predictive analytics involves forecasting future outcomes by identifying patterns and relationships within historical data and extrapolating these insights forward.

1.1.1 Common mathematical functions in predictive models

Various mathematical functions are employed to model relationships between variables in predictive analytics:

  • Linear: y=a+bxy = a + bx
  • Logarithmic: y=ln⁡(x)y = \ln(x)
  • Polynomial (2nd order): y=ax2+bx+cy = ax^2 + bx + c
  • Polynomial (3rd order): y=ax3+bx2+dx+ey = ax^3 + bx^2 + dx + e
  • Power: y=axby = ax^b
  • Exponential: y=abxy = ab^x

1.2 Regression analysis

Regression analysis is a statistical technique used to build mathematical models that describe the relationships between variables. It helps in predicting the value of one variable based on the value of another.

1.2.1 Key concepts in regression analysis

  • Dependent variable (response variable): The variable that is to be predicted. Its value is assumed to depend on the independent variable(s).
  • Independent variable (predictor or explanatory variable): The variable used to predict the dependent variable.
  • Scatter plot (or scatter diagram): A graphical representation used to visualize the relationship between two variables, typically with the independent variable on the X-axis and the dependent variable on the Y-axis. A linear trend in the scatter plot suggests that a linear regression model may be appropriate.

1.2.2 Simple linear regression

Simple linear regression models the relationship between one independent variable (X) and one dependent variable (Y) using a linear equation.

The general form of the simple linear regression model is: Yi=β0+β1Xi+eiY_i = \beta_0 + \beta_1 X_i + e_i Where:

  • YiY_i is the dependent variable for the ithi^{th} observation.
  • XiX_i is the independent variable for the ithi^{th} observation.
  • β0\beta_0 is the true intercept (the expected value of YY when X=0X = 0).
  • β1\beta_1 is the true slope of the regression line (the expected change in YY for a one-unit increase in XX).
  • eie_i is the random error term, representing the part of YiY_i not explained by XiX_i.

1.2.3 Least-squares regression method

The least-squares method is used to find the best-fitting regression line by minimizing the sum of the squared differences between the observed values of the dependent variable and the values predicted by the regression line. These differences are known as residuals or errors.

The estimated regression line is given by: Y^=b0+b1X\hat{Y} = b_0 + b_1 X Where:

  • Y^\hat{Y} is the predicted value of the dependent variable.
  • b0b_0 is the estimated intercept.
  • b1b_1 is the estimated slope.

Formulas for the least-squares coefficients:

b1=∑i=1n(Xi−Xˉ)(Yi−Yˉ)∑i=1n(Xi−Xˉ)2b_1 = \frac{\sum_{i=1}^{n} (X_i - \bar{X})(Y_i - \bar{Y})}{\sum_{i=1}^{n} (X_i - \bar{X})^2} b0=Yˉ−b1Xˉb_0 = \bar{Y} - b_1 \bar{X}

Note: In practical applications, software like Excel can directly compute these coefficients using functions such as =SLOPE(known_y's, known_x's) and =INTERCEPT(known_y's, known_x's).

1.2.4 Measuring the fit of the regression model

Several metrics are used to evaluate how well the regression model fits the data.

  • Coefficient of Determination (R2R^2): This value represents the proportion of the variance in the dependent variable (YY) that is explained by the independent variable (XX) in the regression model. It ranges from 0 to 1, where 1 indicates a perfect fit. A higher R2R^2 value signifies a better fit.
    • R2=Sum of Squares Regression (SSR)Sum of Squares Total (SST)=1−Sum of Squares Error (SSE)Sum of Squares Total (SST)R^2 = \frac{\text{Sum of Squares Regression (SSR)}}{\text{Sum of Squares Total (SST)}} = 1 - \frac{\text{Sum of Squares Error (SSE)}}{\text{Sum of Squares Total (SST)}}
  • Correlation Coefficient (rr): This measures the strength and direction of the linear relationship between two variables. It ranges from -1 to +1. A value of +1 indicates a perfect positive linear relationship, -1 indicates a perfect negative linear relationship, and 0 indicates no linear relationship. R2R^2 is the square of the correlation coefficient (R2=r2R^2 = r^2).

1.2.5 Estimating variance and standard deviation

  • Estimated Variance (s2s^2 or MSE - Mean Squared Error): This is an estimate of the variance of the error term (σ2\sigma^2) and is calculated as: s2=MSE=SSEn−k−1s^2 = MSE = \frac{SSE}{n-k-1} Where nn is the number of observations and kk is the number of independent variables.
  • Standard Deviation of the Regression (Standard Error of the Estimate, ss): This is the square root of the estimated varianc