Probability Statistics

Cover

Laws of probability PP.pdf

📚 Laws of probability PP.pdf

Brief overview

This document introduces fundamental concepts of probability, essential for understanding data analysis and decision-making in various fields. It covers basic probability calculations, the analysis of data through tables, and the critical concept of event independence.

Key points

  • Overview of basic probability questions involving dice, students, and sports preferences.
  • How to determine the independence of events using probability calculations.
  • Analyzing data tables to compute probabilities, including conditional probabilities.
  • Exploring complex probability scenarios based on score products and differences.
  • Solving probability problems with multiple conditions and data interpretations.

1. Basic probability questions en Independence of events

1.1 Understanding independent events

Events are independent if the outcome of one event does not affect the outcome of another. This means that the occurrence of one event does not change the probability of the other event occurring.

For two events, A and B, to be independent, the following condition must hold: P(A∩B)=P(A)×P(B)P(A \cap B) = P(A) \times P(B) This equation states that the probability of both events A and B happening is equal to the product of their individual probabilities. If this condition is met, the events are independent.

🔑 Important: If P(A∩B)≠P(A)×P(B)P(A \cap B) \neq P(A) \times P(B), then events A and B are dependent.

1.2 Calculating probabilities of independent events

When dealing with independent events, you can calculate the probability of both events occurring by multiplying their individual probabilities.

Consider the example of throwing two fair dice. Let event A be 'the first die shows a 4' and event B be 'the second die shows a 6'.

Since the outcome of the first die does not affect the outcome of the second die, these events are independent.

  • The probability of event A is P(A)=16P(A) = \frac{1}{6}.
  • The probability of event B is P(B)=16P(B) = \frac{1}{6}.
  • The probability of both A and B occurring is P(A∩B)=P(A)×P(B)=16×16=136P(A \cap B) = P(A) \times P(B) = \frac{1}{6} \times \frac{1}{6} = \frac{1}{36}.

This principle applies to any scenario where events are independent, such as coin tosses or drawing cards with replacement.

1.3 Determining independence in practice

To determine if two events are independent, you need to compare the probability of their intersection with the product of their individual probabilities.

Here is a step-by-step process:

  1. Calculate P(A)P(A): Find the probability of the first event.
  2. Calculate P(B)P(B): Find the probability of the second event.
  3. Calculate P(A∩B)P(A \cap B): Find the probability of both events occurring together.
  4. Compare: Check if P(A∩B)P(A \cap B) is equal to P(A)×P(B)P(A) \times P(B).

1.3.1 Example: Dice product and parity

Ashfaq throws two fair dice. Event R is 'the product of the two numbers is 12'.

Event T is 'one of the numbers is odd and one is even'. Are R and T independent?

First, list all possible outcomes when throwing two dice (36 outcomes).

Event R (Product is 12): The pairs that give a product of 12 are (2, 6), (3, 4), (4, 3), (6, 2). So, P(R)=436=19P(R) = \frac{4}{36} = \frac{1}{9}.

Event T (One odd, one even): This occurs when one die shows an odd number (1, 3, 5) and the other shows an even number (2, 4, 6).

  • (Odd, Even): 3 options for odd ×\times 3 options for even = 9 outcomes.
  • (Even, Odd): 3 options for even ×\times 3 options for odd = 9 outcomes. Total outcomes for T = 9 + 9 = 18. So, P(T)=1836=12P(T) = \frac{18}{36} = \frac{1}{2}.

Event R∩TR \cap T (Product is 12 AND one odd, one even): From the pairs for R:

  • (2, 6): Even, Even (not in T)
  • (3, 4): Odd, Even (in T)
  • (4, 3): Even, Odd (in T)
  • (6, 2): Even, Even (not in T) The pairs that satisfy both R and T are (3, 4) and (4, 3). So, P(R∩T)=236=118P(R \cap T) = \frac{2}{36} = \frac{1}{18}.

Comparison: Calculate P(R)×P(T)=19×12=118P(R) \times P(T) = \frac{1}{9} \times \frac{1}{2} = \frac{1}{18}. Since P(R∩T)=P(R)×P(T)P(R \cap T) = P(R) \times P(T), events R and T are independent.

📝 Example:

Cover

lec01-data-analysis.pdf

📚 lec01-data-analysis.pdf

Brief overview

This document introduces fundamental data analysis concepts, emphasizing data literacy and its significance in transforming data into actionable information. It outlines the essential components of study design, sampling, and variable measurement crucial for drawing valid conclusions.

Key points

  • Course administration, schedules, and essential readings.
  • Defining data literacy and the objectives of data analysis.
  • Study design principles and methods for selecting representative samples.
  • Understanding variables, bias, and the impact of sample size.
  • Differentiating between numerical and categorical variable types for analysis.

1. Course administration and overview

1.1 Course structure and schedule

  • Lectures: Live lectures are held on Thursdays from 12:30 PM to 2:00 PM.
  • Consultation Hours: To be announced (TBA).
  • SGTAs (Smaller Group Teaching Activities): These run from Week 2 through Week 13.
    • Attendance and participation are essential for this course.
    • SGTA activities reinforce lecture content and help prepare for assessments.
    • Enrol in SGTAs via eStudent.
  • Required Readings:
    • Business Analytics and Statistics (Black et al., n.d.).
    • Excel readings are available on iLearn.

1.2 Weekly lecture and assessment schedule

This table outlines the topics covered each week and associated assessments.

WeekLecture TopicsAssessments
8Hypothesis Tests IIMid Session Break Report
11Simple Linear Regression IIQuantitative Analysis Task

1.3 Data analysis: Objectives and scope

  • Data literacy: This is the ability to analyse, interpret, and question data. It is an increasingly valuable skill in our data-rich world.
  • Data vs. Information:
    • Data: Raw, unprocessed facts. For example, one record of a transaction.
    • Information: Processed data that adds meaning and knowledge, enabling decision-making. For example, monthly sales figures for a specific product over three years.

📝 Example: Google collects data on user clicks and demographics. This data becomes information when analysed to understand marketing effectiveness.

  • Objective of Data Analysis: To gain information about a target population using a sample.

    • Target Population: All subjects of interest.
    • Sample: A manageable subset selected for feasibility.
  • Business Questions: A sample is used to answer business questions about a population.

  • Scope of Data Analysis: The process involves several stages:

    • Study Design
    • Data Collection or Extraction
    • Data Analysis
    • Interpretation and presentation of Results
    • Report Writing
    • Identifying the next research question

🔑 Important: Understanding the difference between data and information is crucial for making informed business decisions.

🔑 Important: Samples are used to infer properties about larger populations, making analysis feasible.

2. Study design and sample selection

2.1 Defining the study's core elements

A study begins by defining key aspects of the research. This includes the business question, which is the central query the study aims to answer.

It also involves identifying the target population. This is the group or set of entities about which the business question is being asked.

Finally, researchers must determine the specific variables or measurements needed to address the question.

2.2 Sample selection and data collection

The process extends to how the study will be conducted. Sample selection

Cover

Lecture01_pipeline-7-12.pdf

Table of contents

  1. Definition: Data Definition: Data
  2. Types of variables
  3. Example: A small dataset of students I

1. Definition: Data Definition: Data

1.1 Data

Data are recorded values that describe the characteristics of objects, individuals, or events. Each value is a result of a measurement, observation, count, or declaration, and it is associated with a named characteristic of the object it describes.

The term "data" originates from the Latin word "datum," meaning "that which is given" 2 3.

1.2 Structure of a dataset

Three fundamental concepts structure every dataset:

  • Statistical unit: This is the entity being described, which could be a person, a transaction, a plot of land, or a day 3.
  • Characteristic: This is the named attribute of the statistical unit that is being measured or observed.
  • Recorded value: This is the specific measurement, observation, count, or declaration associated with a characteristic of a statistical unit 2.

A key implicit assumption in the tabular format of data is that the rows are exchangeable. This means the order of the rows conveys no information, and any subset of rows is as representative as any other 3.

This diagram categorizes variables into Quantitative and Qualitative types, further subdividing them into Continuous, Discrete, Nominal, and Ordinal with their definitions and examples.

1.3 Types of variables

Variables, which represent the characteristics being measured, can be broadly categorized into quantitative and qualitative types .

Variable TypeSubtypeDefinitionExamples
QuantitativeContinuousCan take any value within a given range.Height, weight, temperature
QuantitativeDiscreteCan only take specific, separate values, often counts.Number of siblings, number of cars, number of defects
QualitativeNominalCategories with no inherent order.Gender, color, country of origin
QualitativeOrdinalCategories with a meaningful order.Education level (e.g., High School, Bachelor's, Master's), satisfaction rating (e.g., Poor, Fair, Good, Excellent)

1.4 Example dataset

A dataset can be visualized as a table where each row represents a statistical unit and each column represents a characteristic. For instance, a dataset might include information about students, detailing their age, region, mark, and grade .

A table displaying data for three students, including their age, region, mark, and grade.

2. Types of variables

2.1 Variable classification

The type of a variable dictates the meaningful operations and applicable analytical methods. Variables are broadly categorized into quantitative and qualitative types, each with specific subtypes that define the nature of their values and the statistical treatments they can undergo.

Understanding these distinctions is crucial for appropriate data analysis and interpretation 4 5.

TypeSubtypeDefinitionExample
QuantitativeContinuousAny real value within an interval; means and distances are meaningful.Mark, temperature
QuantitativeDiscreteCountable values, usually integers.Number of children
QualitativeNominalCategories without order; only equality is meaningful.Region, colour
QualitativeOrdinalCategories with a natural order; ranks are meaningful, differences are not.Grade, satisfaction level

2.2 Admissible summary statistics

The scale of measurement for a variable determines the admissible summary statistics. Different variable types support different levels of statistical summarization, ranging from simple counts to complex measures of central tendency and dispersion 5.

  • Nominal variables: Allow for the calculation of the mode (the most frequent category).
  • Ordinal variables: Support the calculation of the median and quantiles, reflecting the ordered nature of their categories.
  • Quantitative variables: Enable the calculation of the mean, variance, and correlation, as their numerical values allow for arithmetic operations and the assessment of relationships 5.

3. Example: A small dataset of students I

3.1 Dataset structure

This section illustrates a small dataset containing information about three students. The dataset comprises statistical units, which are the in

Cover

Lecture 03 Frequency Distribution and Their Graphs.pdf

Table of contents

  1. Introduction

  2. Frequency Distributions

  3. Graphs of Frequency Distributions

  4. Key Idea

1. Introduction

This section introduces the fundamental concepts of organizing and presenting statistical data in psychology. Researchers gather numerical data, such as test scores or reaction times, and need systematic methods to make this raw information understandable and interpretable.

Frequency distributions and statistical graphs are presented as essential tools for this purpose 2 3.

2. Frequency Distributions

A frequency distribution is a table that organizes data into classes or intervals, showing the count of data entries within each class. This organization helps in summarizing and presenting large datasets effectively 4.

2.1 Definition of frequency distribution

  • Frequency distribution: A table that lists data entries by class or interval, along with the number of entries in each class.

  • Frequency: The number of data entries that fall within a specific class 4.

2.2 Components of a frequency distribution

  • Class limits: Each class has a lower and an upper limit, defining the minimum and maximum values that can belong to that class 5.

  • Range: The difference between the maximum and minimum data entries in a dataset 6.

2.3 Guidelines for constructing a frequency distribution

  1. Number of classes: Decide on the number of classes, typically between 5 and 20, to reveal patterns.

  2. Class width: Calculate the class width by dividing the range by the number of classes and rounding up to a convenient number.

  3. Class limits: Set the minimum data entry as the lower limit of the first class. Add the class width to find subsequent lower limits. Determine upper limits ensuring classes do not overlap.

  4. Tally marks: Mark each data entry with a tally in its corresponding class.

  5. Frequency count: Count the tally marks for each class to determine its frequency 7.

2.4 Example: Constructing a frequency distribution for reaction times

The following steps illustrate constructing a frequency distribution for 30 reaction time measurements in milliseconds:

  • Determine the number of classes: The problem specifies seven classes.

  • Calculate the range: The minimum reaction time is 59 ms and the maximum is 450 ms, giving a range of 450−59=391450 - 59 = 391 ms.

  • Calculate the class width: Divide the range by the number of classes: 391/7≈55.86391 / 7 \approx 55.86. Round up to 56 9.

  • Determine class limits: The first class starts at 59. Adding the class width of 56 to each lower limit generates the subsequent lower limits. The upper limit of the first class is 114 (one less than the next lower limit).

  • Tally and count frequencies: Tally each data point into its respective class and count the tallies to find the frequency for each of the seven classes 10 11.

The resulting frequency distribution for reaction times is:

Reaction Time (ms)

Frequency

59–114

5

115–170

8

171–226

6

227–282

5

283–338

2

339–394

1

395–450

3

Cover

lecture 10 (1).pdf

1. Principles of observational and interventional studies

This section summarizes the core distinctions between observational and interventional study designs, detailing methods to mitigate bias in the former and establish causality in the latter, including the role of control, randomization, and blinding techniques.

1.1 Observational studies and sources of bias

Observational studies record data without intervening, making them highly susceptible to various forms of bias. Retrospective studies generally carry the greatest probability of introducing bias.

Key biases in observational studies include:

  • Sampling bias: Occurs based on who was assessed versus who was not.
    • For example, patients in one group might be more likely to die or volunteer information than those in another group.
    • Historical data collection methods can introduce bias, such as landline phone surveys being biased toward older populations.
  • Biased metrics: Results are affected if one group is more likely to report favorable outcomes than another.
    • Example: Placing police in charge of investigating police misconduct illustrates biased metrics.

  • Coverage bias: Relates to how long or how often participants were surveyed.
    • For instance, unvaccinated children might be followed for shorter durations and consequently have fewer doctor visits recorded.
  • Confounding variables: These are external variables that influence both the exposure and the outcome. Ideally, data on all possible confounders should be collected and corrections applied if necessary.

Prospective observational studies, which follow participants through time (e.g., The Framingham Heart Study, The Nurses’ Health Study), help reduce sampling and coverage bias 3.

Tip: Contemporary research often highlights the influence of confounders; for example, studies linking acetaminophen (Tylenol) usage during pregnancy to autism risk were potentially confounded by factors related to the mother (e.g., underlying health status), which was controlled for in paired tests comparing multiple pregnancies within the same mother, where the effect disappeared 2.

1.2 Interventional studies and causality

Interventional studies are considered the only sure way to establish causality. These studies are generally easier and cheaper to execute in model organisms.

Key components of interventional studies include:

  • Control group: Essential for comparison. In some cases, such as experimental cancer treatment protocols, a control group may be omitted, requiring comparison against an empirical expectation instead.
    • Example: A study comparing patients who successfully adhered to a diet eliminating fish, dairy, meat, and added oils (0.6% recurrence of cardiovascular events) versus non-adherent patients (62% recurrence) demonstrated a massive effect size, potentially warranting less rigorous control groups.

  • Randomization: The process of assigning participants randomly to intervention or control groups. Randomization effectively controls for all confounding variables related to baseline characteristics.
    • It is best practice to generate evenly-sized groups through randomization.
    • If group sizes are small, purposefully matching key variables between groups is preferred over pure randomization.
    • Caveat: The advantages of randomization can be lost if there is high dropout or low patient adherence during the study 4.

1.3 Psychological effects: Placebo and nocebo

Psychological factors significantly influence perceived outcomes, especially concerning subjective metrics.

  • The mere act of being treated and listened to by an expert can directly induce positive outcomes (placebo effect).
  • The nature of the intervention affects the magnitude of the effect; for instance, an injection or a large red pill induces larger placebo or nocebo effects than a small pill.
  • Prognoses and treatments that cause psychological distress can induce negative nocebo effects.
  • Subjective metrics (e.g., pain scores, fatigue) are highly susceptible to these effects.
  • Objective metrics (e.g., blood marker levels) are much less affected, although outcomes tied to mood, such as test scores or even cancer survival, are susceptible to placebo/nocebo influence 5.

1.4 Mitigating psychological bias through controls and blinding

Designing effective controls is crucial to isolate the true treatment effect from psychological influence.

  • Placebo controls: Comparing one active treatment against another active treatment can sometimes eliminate the need for a pure placebo, although the possibility of a placebo effect should still inform interpretation.
    • Designing adequate placebos can be difficult for certain interventions, such as diet studies, surgeries (requiring mock surgeries), or psychoactive drugs.
    • Using objective metrics helps mitigate concerns when placebos are difficu
Cover

Lecture 10 Inference from Small Samples.pdf

1. Introduction to Student's t distribution and its properties

This section introduces the Student's t distribution, its historical origins, its relationship to the standard normal distribution, and the critical role of degrees of freedom in defining its shape.

1.1 Historical Development and Definition

The Student's t distribution was derived by W. S. Gosset in 1908, who published his work under the pseudonym "Student." It is a probability distribution that arises in the context of estimating a population mean when the sample size is small and the population standard deviation is unknown. The statistic associated with this distribution is commonly denoted as tt.

The tt statistic is defined as: t=xˉ−μs/nt = \frac{\bar{x} - \mu}{s / \sqrt{n}} where:

  • xˉ\bar{x} is the sample mean.
  • μ\mu is the population mean.
  • ss is the sample standard deviation.
  • nn is the sample size.

Both xˉ\bar{x} and ss are considered random variables, contributing to the nature of the tt distribution.

1.2 Properties and Comparison with the Standard Normal Distribution

The Student's t distribution shares similarities with the standard normal (z) distribution but possesses distinct characteristics, particularly concerning its tails and dependence on sample size.

1.2.1 Shape and Tails

  • Similarity to z: The t-distribution is conceptually similar to the standard normal distribution, which has a mean of 0 and a variance of 1.
  • Heavier Tails: A key difference is that the t-distribution exhibits "heavier tails" compared to the z-distribution. This means that extreme values are more likely to occur in the t-distribution than in the standard normal distribution. This phenomenon arises because the tt statistic incorporates two random quantities (xˉ\bar{x} and ss), whereas the z statistic typically involves only the sample mean (xˉ\bar{x}) when the population standard deviation (σ\sigma) is known.
  • Approximation to Normal Distribution: As the sample size (nn) becomes large, the t-distribution increasingly approximates the standard normal distribution. This is because as nn increases, the sample standard deviation (ss) becomes a more reliable estimate of the population standard deviation (σ\sigma).

Note: The concept of "heavier tails" implies that the probability density function (PDF) of the t-distribution assigns more probability mass to values far from the mean than the PDF of the standard normal distribution.

1.3 The Role of Degrees of Freedom

The shape of the t-distribution is not fixed but is determined by a parameter known as the degrees of freedom (df).

  • Definition of Degrees of Freedom: For the sample variance s2s^2, the degrees of freedom are calculated as n−1n-1, where nn is the sample size. The formula for sample variance is: s2=∑i=1n(xi−xˉ)2n−1s^2 = \frac{\sum_{i=1}^{n} (x_i - \bar{x})^2}{n-1} The term n−1n-1 arises because when calculating the sample variance, one degree of freedom is "lost" due to the constraint that the sum of deviations from the sample mean must be zero (∑i=1n(xi−xˉ)=0\sum_{i=1}^{n} (x_i - \bar{x}) = 0).

  • Impact on Distribution Shape: The number of degrees of freedom directly influences the spread and tail heaviness of the t-distribution.

    • Lower df: With fewer degrees of freedom (i.e., smaller sample sizes), the t-distribution has fatter tails and is more spread out.
    • Higher df: As the degrees of freedom increase, the t-distribution becomes narrower and its tails become lighter, converging towards the standard normal distribution.

Example: For a sample of size n=10n=10, the degrees of freedom are df=10−1=9df = 10 - 1 = 9. This specific value of dfdf dictates the precise shape of the t-distribution used for inference.

1.3.1 Finding Critical Values

Critical values of the t-distribution are determined by both the degrees of freedom and the desired significance level (or tail probability).

Example 10.2: Find a value of tt such that only 1% of all values of tt will be smaller, for a sample of size n=10n = 10 from a normal distribution.

Solution: The degrees of freedom are df=n−1=10−1=9df = n - 1 = 10 - 1 = 9. We are looking for a tt-value with an area of 0.010.01 to its left. Due to the symmetry of the t-distribution around 0, this value is the negative of the tt-value that has 0.010.01 area to its right. Using a t-table or statistical software for df=9df=9 and a tail probability of 0.010.01, we find the critical value to be approximately −2.821-2.821. Thus, t0.01=−2.821t_{0.01} = -2.821 8.

1.4 Assumptions for Using the Student's t Distribution

To make reliable inferences using critical values from the Student's t distribution, certain assumptions about the sample and population must be met:

  • Random Sampling: The sample must be randomly selected from the population.
  • Normality of Population: The population from which the sample is drawn must be normally distributed.
Cover

Lecture 10 Inference from Small Samples.pdf

This document provides an in-depth exploration of small-sample inference using Student’s t distribution, including hypothesis tests, confidence intervals, and comparisons of population means.

Inference from small samples

The document begins by discussing inference from small samples with a focus on the Student’s t distribution, its derivation, and application to real-world examples 1.

student’s t distribution

  • W. S. Gosset derived the density function for samples drawn from a normal population, publishing his results under the pen name “Student” 3.
  • The t statistic relies on both xˉ\bar{x} and ss, making these quantities random variables, unlike the z statistic which only involves the fixed sample mean 3.

Tip: When using the t distribution, remember that its “heavier tails” accommodate extra uncertainty from estimating the standard deviation with ss 4.

  • The sample variance is calculated as s2=∑i=1n(xi−xˉ)2n−1s^2=\frac{\sum_{i=1}^{n}(x_i-\bar{x})^2}{n-1} where the divisor n−1n-1 represents the degrees of freedom 5.

comparing t and normal distributions

  • Both Student’s t distribution and the standard normal (z) distribution appear similar; however, the t distribution has heavier tails, meaning it gives more probability to extreme events 4.
  • As the sample size nn increases, the value of ss becomes a more accurate estimator of the population standard deviation σ\sigma, causing the t distribution to resemble the standard normal distribution 4 5.

example: finding a critical t value

  • A practical example is provided where a sample size of n=10n=10 is considered, and one must find a value of tt so that only one percent of the values will be smaller 6.
  • With degrees of freedom calculated as df=n−1=9df = n - 1 = 9, the critical t value is found by noting that, due to symmetry, the value is the negative of the corresponding right-tail value, leading to −t0.01=−2.821-t_{0.01}=-2.821 7 8.

Note: Ensure that your sample meets the requirements of a random selection from a normally distributed population before applying these inferences 9.

assumptions for using the t distribution

  • The validity of inferences using the t distribution depends on:
    • The sample being randomly selected 9.
    • The underlying population being normally distributed 9.
    • For small samples (n<30n<30), the population standard deviation σ\sigma should be unknown, necessitating the use of the t distribution rather than the z distribution 10.

small-sample inferences concerning a population mean

This section focuses on hypothesis tests and confidence intervals for a single population mean when the sample size is less than 30 and σ\sigma is unknown 11.

hypothesis testing for a mean

  1. The null hypothesis is stated as:

    H0:μ=μ0H_0: \mu = \mu_0

    while the alternative hypothesis can be one-tailed (e.g., Ha:μ>μ0H_a: \mu > \mu_0 or Ha:μ<μ0H_a: \mu < \mu_0) or two-tailed (Ha:μ≠μ0H_a: \mu \neq \mu_0) 12.

  2. The test statistic is given by

    t=xˉ−μ0s/nt=\frac{\bar{x}-\mu_0}{s/\sqrt{n}}

    which compares the sample mean xˉ\bar{x} against the hypothesized population mean μ0\mu_0 12.

  3. The rejection region is set based on the chosen significance level α\alpha. For instance, in a one-tailed test, one would reject H0H_0 if

    t>tαt > t_\alpha

    (or t<−tαt < -t_\alpha when the alternative is Ha:μ<μ0H_a: \mu < \mu_0), and in a two-tailed test if t>tα/2t > t_{\alpha/2} or t<−tα/2t < -t_{\alpha/2}, or by comparing the p-value with α\alpha 13.

  4. Critical values of tt depend on n−1n-1 degrees of freedom; tables or online calculators may be used to obtain these values 14 15.

confidence interval for the mean

  • A (1−α)100%(1-\alpha)100\% confidence interval for μ\mu is constructed as: xˉ±tα/2sn\bar{x} \pm t_{\alpha/2}\frac{s}{\sqrt{n}} where sn\frac{s}{\sqrt{n}} is the estimated standard error of xˉ\bar{x} 16.

example: small-sample hypothesis test for a population mean

An example explores whether a new process for producing synthetic diamonds results in an average weight greater than 0.5 karat 17.

  • Six diamond samples are measured, with weights recorded as 0.46, 0.61, 0.52, 0.48, 0.57, and 0.54 karat.
  • The hypotheses are:
    • H0:μ=0.5H_0: \mu = 0.5
    • $H_a: \mu >
Cover

lecture 11 (1).pdf

1. Introduction to regression and statistical modeling

This topic covers foundational concepts in statistical modeling, specifically multivariate linear regression, its implementation using standard libraries, issues like collinearity, and an introduction to unsupervised learning techniques through hierarchical and K-means clustering.

1.1 Multivariate linear regression and loss functions

Multivariate linear regression extends simple two-dimensional linear regression, which minimizes the sum of squares (SOS), to models with more than one independent variable. When dealing with multiple predictors, parameter fitting often involves iterative methods like gradient descent . A significant advantage of using the Sum of Squares (SOS) loss function is its convexity, which guarantees that gradient descent, a greedy algorithm, will converge to the global minimum 2.

In the context of regression, the Ordinary Least Squares (OLS) method seeks to minimize this loss function. Practical implementation in Python can utilize libraries like statsmodels or scikit-learn. When using statsmodels, it is crucial to explicitly add a constant term using sm.add_constant() to the independent variables matrix (XX) to correctly model the intercept, preventing its confounding influence on the regressor weights 3.

A standard OLS summary provides several key statistics for model assessment ]:

  • R-squared (R2\text{R}^2): Represents the proportion of variance in the dependent variable (YY) explained by the model. A value near 1.0 suggests a very strong fit .
  • F-statistic and its p-value: These assess the overall significance of the correlation explained by the entire set of regressors .
  • Coefficients (coef\text{coef}), standard errors (std err\text{std err}), and t-statistics/p-values (P>∣t∣\text{P}>|t|): These detail the estimated slope (weight) for each individual regressor 4.

A table summarizing the results of an Ordinary Least Squares (OLS) regression analysis, including model fit statistics and coefficient estimates.

The scikit-learn implementation of LinearRegression directly fits the model to find the coefficients and intercept, which can be accessed via .coef_ and .intercept_ respectively . While linear regression is an example of supervised machine learning, capable of predicting unseen data points, proper separation of training and validation sets is necessary for robust extrapolation . Furthermore, many machine learning algorithms, including deep neural networks, share the paradigm of defining a loss function and fitting all parameters simultaneously via gradient descent 5 6.

1.2 Collinearity in regression models

Collinearity, or multicollinearity, occurs when two or more independent variables in a model are highly correlated, making one effectively redundant . When collinearity is present, the specific weights assigned to the highly correlated variables become arbitrary ("a matter of luck") and should not be interpreted as indicating a differential predictive potential between them . However, collinearity does not typically invalidate the overall model significance or affect the interpretation of weights for variables that are weakly correlated or uncorrelated with the others . A common diagnostic step to identify this issue is calculating all pairwise correlations among predictors (e.g., using df.corr(axis=0)) 7.

1.3 Unsupervised learning: Clustering basics

Clustering is a core technique in unsupervised machine learning, as it seeks to discover inherent structure by identifying similar subgroups (of rows or columns) without relying on external labels or ground truth . The two primary types introduced are hierarchical clustering and K-means clustering 8.

1.3.1 Hierarchical clustering and distance metrics

Hierarchical clustering builds a nested sequence of partitions, represented by a tree-like structure called a dendrogram, without requiring prior knowledge of the number of clusters (KK) . This method is particularly suitable for data exhibiting processes that are naturally hierarchical, such as evolutionary sequences (e.g., organisms or product iterations) . The algorithm iteratively merges the closest pair of elements or clusters based on a chosen distance metric until all elements form a single group 9.

The fundamental building block is the distance metric, such as Euclidean distance, which calculates the shortest path in multi-

Cover

lecture 12.pdf

1. Introduction and fundamental statistical concepts

Statistics serves as an essential component in scientific claims due to the inherent uncertainty present in data, stemming from measurement noise and uncontrolled variability like genetics or chance. Relying solely on individual anecdotes (n=1n=1) provides weak evidence because random chance cannot be ruled out as the explanation for observed results. The primary goal of statistics in science is typically to test a hypothesis, determining whether observations merely reflect noise or indicate a genuine trend 2.

1.1 Key fundamental concepts

A strong understanding of core statistical principles is necessary for rigorous scientific practice. These foundational concepts govern how data variability and probability are managed and interpreted.

Key concepts that must be understood include:

  • The law of large numbers.

  • The central limit theorem.

  • Null models and PP-values.

  • Identifying different types of "averages".

  • The mean, standard deviation, and standard error 3.

  • Expected value and confidence intervals.

  • Concepts related to probability, such as operations on probabilities and conditional probabilities, including Bayes’ theorem.

  • Understanding independent, identically distributed (i.i.d) variables.

  • Distinguishing between Type I and Type II errors.

Tip: Always adhere to the guiding principle: "Don’t try anything complicated unless it is well justified". Start with simple, standard statistical methods before resorting to complex simulations like Monte Carlo methods, unless necessary to control for important confounders.

1.2 Measures of central tendency and variability

The mean (mu\\mu or barx\\bar{x}) represents the arithmetic average. The standard deviation (sigma\\sigma or ss) quantifies the spread or dispersion of individual data points around the mean.

The standard error (SE) is crucial as it estimates the precision of a sample statistic (like the mean) as an estimate of the population parameter. It is fundamentally related to the Central Limit Theorem (CLT), which allows for the estimation of the standard error for means or sums.

The standard error of the mean (textSE_barx\\text{SE}\_{\\bar{x}}) is calculated as the sample standard deviation divided by the square root of the sample size nn: textSEbarx=fracssqrtn\\text{SE}{\\bar{x}} = \\frac{s}{\\sqrt{n}}

Confidence intervals rely on these concepts to provide a range of values within which the true population parameter is likely to lie 4.

1.3 Guiding statistical hypothesis testing

Science fundamentally operates by testing hypotheses; statistics provides the framework to assess the likelihood that observed data arose by chance alone. When designing statistical assessments, the choice of test depends critically on the nature of the variables being compared 8.

1.3.1 Comparing variables: Categorical data

When testing for an association between two variables, if both are categorical, one typically generates a contingency table showing the counts (overlaps).

  • For large counts, the Chi-squared test is used if the smaller counts are sampled with replacement.

  • If counts are small, the binomial test is preferred when sampling with replacement.

  • If sampling is done without replacement, Fisher’s exact test should be used.

  • If the counts represent events over time, the Poisson distribution can be used to calculate a PP-value 10.

1.3.2 Comparing variables: Continuous or ordinal data

When both variables are continuous or ordinal (e.g., assessing correlation between salt consumption and blood pressure):

  • If the relationship appears approximately linear and the data distribution is close to normal, Pearson’s R (linear correlation) is appropriate.

  • Otherwise, Spearman’s rho (rank-rank correlation) should be attempted.

  • If there are many ties in the data along either axis, Kendall’s Tau is recommended.

  • These correlation methods can be extended to multivariate analysis, modeling one output/dependent variable while controlling for others, such as energy intake in the salt/blood pressure example 11.

1.3.3 Comparing variables: Categorical versus Continuous data

When comparing one categorical variable (group definition) against one continuous variable (measurement) (e.g., comparing performance between student groups):

  • If the continuous data is approximately normally distributed, a t-test is appropriate.

  • If the data is not normal, the Mann-Whitney U-test should be used.

  • If the data is paired (e.g., before/after measurements), use the paired t-test (for normal data) or the Wilcoxon signed rank test 13.

1.4 Parametric versus non-parametric tests and normality

The choice between parametric tests (like the t-test, which assumes normality) and non-parametric tests is cri

Cover

Lecture13-14_Gradient(RSS).pdf

📚 Lecture13-14_Gradient(RSS).pdf

Brief overview

This document introduces the concept of the Residual Sum of Squares (RSS) as a metric for evaluating model performance. Understanding RSS is crucial for gradient-based optimization methods used in statistical modeling.

Key points

  • Calculating the residual sum of squares using its formula.
  • Expressing RSS in vectorial form for computational efficiency.
  • Methods for finding the RSS in a vectorial representation.

1. Calculating the residual sum of squares

1.1 The residual sum of squares formula

The residual sum of squares (RSS) measures the difference between observed values and predicted values. It quantifies the error in a model's predictions.

The formula for RSS, denoted as RSS(W), involves summing the squared differences between the actual values (yiy_i) and the predicted values (<W, x_i>).

The RSS can be expressed in several equivalent forms. One form is: RSS(W)=∑i=1N(yi−⟨W,xi⟩)2\text{RSS}(W) = \sum_{i=1}^{N} (y_i - \langle W, x_i \rangle)^2.

This can be expanded to: RSS(W)=∑i=1N(yi2+⟨W,xi⟩2−2yi⟨W,xi⟩)\text{RSS}(W) = \sum_{i=1}^{N} (y_i^2 + \langle W, x_i \rangle^2 - 2 y_i \langle W, x_i \rangle).

1.2 Vectorial form of RSS

In vectorial form, the RSS calculation becomes more compact. The design matrix XX contains the feature vectors xix_i as rows.

The vector yy contains the observed values. The vector WW represents the model's weights.

The RSS can be written as: RSS(W)=∥y−XW∥2\text{RSS}(W) = \| y - XW \|^2.

This is equivalent to: RSS(W)=(y−XW)T(y−XW)\text{RSS}(W) = (y - XW)^T (y - XW).

1.3 Calculating the gradient of RSS

To minimize the RSS, we often compute its gradient with respect to the weights WW. The gradient tells us the direction of the steepest increase in RSS.

The gradient of RSS(W) is given by: ∇WRSS(W)=−2XT(y−XW)\nabla_{\text{W}} \text{RSS}(W) = -2 X^T (y - XW).

This formula shows how changes in the weights WW affect the total error. Setting this gradient to zero helps find the optimal weights that minimize the RSS.

🔑 Important: Minimizing the RSS is a common objective in regression tasks, as it seeks to find the model that best fits the training data 1.