Statistics, Statistical Modeling and Data Analytics
Statistics, Statistical Modeling and Data Analytics
Unit-2:Statistical Modelling
A linear model is a function, like that is fit to a set of data, often to model a process that
generated the data or something like the data. Linear models are mathematical models that
describe the relationship between a dependent variable and one or more independent variables
using a linear equation. These models are widely used in statistics, machine learning, and
econometrics for prediction and inference.
Y=β0+β1X+ε
Where:
• β0 = Intercept
• β1= Slope
• ε = Error term
Use Cases:
Equation:
Y=β0+β1X1+β2X2+⋯+βnXn+ε
Where:
Extends linear regression to allow for response variables that have distributions other than
normal. Common types:
• Logistic Regression: Used for binary outcomes (e.g., pass/fail, spam/not spam)
• Poisson Regression: Used for count data (e.g., number of customer complaints)
All students are familiar with the idea of a linear model from learning the equation of a line,
which is
Y=mX+b (8.1)
where mm is the slope of the line and bb is the YY-intercept. It is useful to think of
equation (8.1) as a function that maps values of XX to values of YY. Using this function, if we
input some value of XX, we always get the same value of Y as the output.
A linear model is a function, like that in equation (8.1), that is fit to a set of data, often to model
a process that generated the data or something like the data. The line in Figure 8.1A is just that,
a line, but the line in Figure 8.1B is a linear model fit to the data in Figure 8.1B.
Figure 8.1: A line vs. a linear model. (A) the line y=−3.48X+105.7y=−3.48X+105.7 is drawn.
(B) A linear model fit to the data. The model coefficients are numerically equal to the slope and
intercept of the line in A.
Y=β0+β1X+εε∼N(0,σ2)(8.2)Y=β0+β1X+ε(8.2)ε∼N(0,σ2)
The first line of this specification has two components: the linear
predictor Y=β0+β1XY=β0+β1X and the error εε. The linear predictor component looks like
the equation for a line except that 1) β0β0 is used for the intercept and β1β1 for the slope and
2) the intercept term precedes the slope term. This re-labeling and re-arrangement make the
notation for a linear model more flexible for more complicated linear models. For
example Y=β0+β1X1+β2X2+εY=β0+β1X1+β2X2+ε is a model where YY is a function of
two XX variables.
The linear predictor is the deterministic or systematic part of the specification. As with the
equation for a line, the linear predictor component of a linear model is a function that maps a
specific value of XX to a unique value of YY. This mapped value is the expected value, or
expectation, given a specific input value of XX. The expectation is often written
as E[Y|X]E[Y|X], which is read as “the expected value of YY given XX”, where “given X”
means a specific value of X. This text will often use the word conditional in place of “given”.
For example, I would read E[Y|X]E[Y|X] as “the expected value of YY conditional on XX”. It
is important to recognize that E[Y|X]E[Y|X] is a conditional mean – it is the mean value
of YY when we observe that XX has some specific value xx (that is X=xX=x).
The second line of the specification (8.2) is read as “epsilon is distributed as Normal with mean
zero and variance sigma squared”. This line explicitly specifies the distribution of the error
component of line 1. The error component of a linear model is a random “draw” from a normal
distribution with mean zero and variance σ2σ2. The second line shows that the error component
of the first line is stochastic. Using the error-model specification, we can think of any
measurement of YY as an expected value plus some random value sampled from a normal
distribution with a specified variance. Because the stochastic part of this specification draws
an “error” from a population, I refer to this as the error-draw specification of the linear model.
yi∼N(μi,σ2)E(Y|X)=μμi=β0+β1xi(8.3)yi∼N(μi,σ2)E(Y|X)=μ(8.3)μi=β0+β1xi
The first line states that the response variable YY is a random variable independently drawn
from a normal distribution with mean μμ and variance σ2σ2. This first line is
the stochastic part of the statistical model. The second line simply states that μμ (the greek
letter “mu”) from the first line is the conditional mean (or expectation). The third line is the
liner predictor, which states how μiμi is generated given that X=xiX=xi. Again, the linear
predictor is the systematic (or deterministic) part of the statistical model. It is systematic
because the same value of xixi will always generate the same μiμi. With the conditional-draw
specification, we can think of a measurement (yiyi) as a random draw from the specified
distribution. Because it is YY and not some “error” that is drawn from the specified
distribution, I refer to this as the conditional-draw specification of the linear model.
8.1.3 Comparing the error-draw and conditional-draw ways of specifying the linear
model
These two ways of specifying the model encourage slightly different ways of thinking about
how the data (the response varible YY) were generated. The error-draw specification
“generates” data by 1) constructing what yiyi “should be” given xixi (this is the conditional
expection), then 2) adding some error eiei drawn from a normal distribution with mean zero
and some specified variance. The conditional-draw specification “generates” data by 1)
constructing what yiyi “should be” given xixi, then 2) drawing a random variable from some
specified distribution whose mean is this expectation. This random draw is not “error” but the
measured value yiyi. For the error draw generation, we need only one hat of random numbers,
but for the conditional draw generation, we need a hat for each value of xixi.
Here is a short script that generates data by implementing both the error-draw and conditional-
draw specifications. See if you can follow the logic of the code and match it to the meaning of
these two ways of specifying a linear model.
n <- 5
b_0 <- 10.0
x <- 1:n
y_expected <- b_0 + b_1*x
# error-draw. Note that the n draws are all from the same distribution
set.seed(1)
data.table(X = x,
## 1: 1 10.94942 10.94942
## 2: 2 12.47346 12.47346
## 3: 3 13.26575 13.26575
## 4: 4 15.43811 15.43811
## 5: 5 16.13180 16.13180
rnorm() is a pseudorandom number generator that simulates random draws from a normal
distribution with the specified mean and variance. The algorithm to generate the numbers is
entirely deterministic – the numbers are not truly random but are “pseudorandom”. The list of
numbers returned closely approximates a set of true, random numbers. The sequence of
numbers returned is determined by the “seed”, which can be set with the set.seed() function (R
will use an internal seed if not set by the user).
The error-draw specification is not very useful for thinking about data generation for data
analyzed by generalized linear models, which are models that allow one to specify distribution
families other than Normal (such as the binomial, Poisson, and Gamma families). In fact,
thinking about a model as a predictor plus error can lead to the misconception that, in a
generalized linear model, the error (or residuals from the fit) has a distribution from the non-
Normal distribution modeled. This cannot be true because the distributions modeled using
generalized linear models (other than the Normal) do not have negative values (some residuals
must have negative values since the mean of the residuals is zero). Introductory biostatistics
textbooks typically only introduce the error-draw specification because introductory textbooks
recommend data transformation or non-parametric tests if the data are not approximately
normal. This is unfortunate because generalized linear models are extremely useful for real
biological data.
Although a linear model (or statistical model more generally) is a model of a data-generating
process, linear models are not typically used to actually generate any data. Instead, when we
use a linear model to understand something about a real dataset, we think of our data as one
realization of a process that generates data like ours. A linear model is a model of that process.
That said, it is incredibly useful to use linear models to create fake datasets for at least two
reasons: to probe our understanding of statistical modeling generally and, more specifically, to
check that a model actually creates data like that in the real dataset that we are analyzing.
Many textbooks treat ANOVA differently from regression and express a linear model as an
ANOVA model (and generally do not use the phrase “linear model”). ANOVA models are all
variations of
yij=μ+τi+εij(8.4)(8.4)yij=μ+τi+εij
Unlike the error and conditional draw specifications above, the ANOVA model doesn’t have a
linear predictor in the form of a regression equation (or the equation for a line) – that is, there
are neither XX variables nor coefficients (ββ). Instead, the ANOVA model is made up of a
linear combination of means and deviations from means. In (8.4), μμ is the grand mean (the
mean of the means of the groups), τiτi is the deviation of the mean of group ii from the grand
mean (these are the effects), and εijεij is the deviation (or error) of individual jj from the mean
of group ii. Traditional ANOVA computes effects and the statistics for inference by computing
means and deviations from means. Modern linear models compute effects and the statistics for
inference by solving for the coefficients of a regression model.
8.2 A linear model can be fit to data with continuous, discrete, or categorical XX variables
In the linear model fit to the data in Figure 8.1B, the XX variable is continuous, which can
take any real number between the minimum XX and maximum XX in the data. For biological
data, most variables that are continuous are positive, real numbers (a zero is not physically
possible but could be recorded in the data if the true value is less than the minimum measurable
amount). One exception is a composition (the fraction of a total), which can be zero. Negative
values can occur with variables in which negative represent a direction (work, electrical
potential) or a rate. Discrete variables are numeric but limited to certain real numbers. Most
biological variables that are discrete are counts, and can be zero, but not negative. Categorical
variables are non-numeric descriptions of a measure. Many of the categorical variables in this
text will be the experimentally controlled treatment variable of interest (the
variable treatmenttreatment containing the values “wild type” and “knockout”) but some are
measured covariates (the variable sexsex containing the values “female” and “male”).
8.2.1 Fitting linear models to experimental data in which the XX variable is continuous
or discrete
A linear model fit to data with a numeric (continous or discrete) XX is classical regression and
the result is typically communicated by a regression line. The experiment introduced in
Chapter ?? [Linear models with a single, continuous X] is a good example. In this experiment,
the researchers designed an experiment to measure the effect of warming on the timing of
photosynthetic activity. Temperature was experimentally controlled at one of five settings (0,
2.25, 4.5, 6.75, or 9 °C above ambient temperature) within twelve, large enclosures. The
response variable in the illustrated example is Autumn “green-down”, which is the day of year
(DOY) of the transition to loss of photosynthesis. The intercept and slope parameters of the
regression line (Figure 8.2) are the coefficients of the linear model. The slope (4.98 days per 1
°C added warmth) estimates the effect of warming on green-down DOY. What is not often
appreciated at the introductory biostatistics level is that the slope is a difference in conditional
means. Any point on a regression line is the expected value of YY at a specified value of XX,
that is, the conditional mean E(Y|X)E(Y|X). The slope is the difference in expected values
for a pair of points that differ in XX by one unit.
b1=E(Y|X=x+1)−E(Y|X=x+1)b1=E(Y|X=x+1)−E(Y|X=x+1)
I show this in Figure 8.2 using the points on the regression line at x=5x=5 and x=6x=6.
Thinking about a regression coefficient as a difference in conditional means is especially useful
for understanding the coefficients of a categorical XX variable, as described below.
Figure 8.2: Illustration of the slope in a linear model with a numeric X. The slope (the
coefficient of X) is the difference in expected value for any two X that are one unit apart. This
is illustrated for the points on the line at x = 5 and x = 6.
8.2.2 Fitting linear models to experimental data in which the XX variable is categorical
Linear models can be fit to experimental data in which the XX variable is categorical – this is
the focus of this text! For the model fit to the data in Figure 8.1B, the coefficient of XX is the
slope of the line. Perhaps surprisingly, 1) we can fit a model like equation (8.2) to data in which
the XX variable is categorical and 2) the coefficient of XX is a slope. How is this possible?
The slope of a line is y2−y1x2−x1y2−y1x2−x1 where (x1,y1)(x1,y1) and (x2,y2)(x2,y2) are
the graph coordinates of any two points on the line. What is the denominator of the slope
function (x2−x1)(x2−x1) when XX is categorical?
The solution to using a linear model with categorical XX is to recode the factor levels into
numbers. An example of this was outlined in Chapter ?? (Analyzing experimental data with a
linear model). The value of XX for individual mouse i is a number that indicates the treatment
assignment – a value of 0 is given to mice with a functional ASK1 gene and a value of 1 is
given to mice with a knocked out gene. The regression line goes through the two group means
(Figure 8.3). With the (0, 1)
coding, ¯¯¯xASK1Δadipo−¯¯¯xASK1F/F=1x¯ASK1Δadipo−x¯ASK1F/F=1, so the
denominator of the slope is equal to one and the slope is simply equal to the
numerator ¯¯¯yASK1Δadipo−¯¯¯yASK1F/Fy¯ASK1Δadipo−y¯ASK1F/F. The coefficient
(which is a slope!) is the difference in conditional means.
Figure 8.3: Illustration of the slope in a linear model with categorical X. The slope (the
coefficient of X) is the difference in conditional means.
8.3 Statistical models are used for prediction, explanation, and description
With observational designs, biologists are often not very explicit about which of these is the
goal of the modeling and use a combination of descriptive, predictive, and causal language to
describe and discuss results. Many papers read as if the researchers intend explanatory
inference but because of norms within the biology community, mask this intention with
“predictive” language. Here, I advocate embracing explicit, explanatory modeling by being
very transparent about the model’s goal and assumptions.
The inputs to a linear model (the XX variables) have many names. In this text, the XX variables
are typically
• treatment variables – this term makes sense only for categorical variables and is often
used for variables that are a factor containing the treatment assignment (for example
“control” and “knockout”)
• factor variables (or simply, factors) – again, this term makes sense only for categorical
variables
• covariates – this term is usually used for the non-focal XX variables in a statistical
model.
A linear model is a regression model and in regression modeling, the XX variables are typically
called
• independent variables (often shortened to IV) – “independent” in the sense that in a
statistical model at least, the XX are not a function of YY.
• predictor variables (or simply, “predictors”) – this makes the most sense in prediction
models.
In this text, the output of a linear model (the YY variable or variables if the model is
multivariate) will most often be calle either of
These terms have a causal connotation in everyday english. These terms are often used in
regression modeling with observational data, even if the model is not explicitly causal. On
other term, common in introductory textbooks, is
• dependent variable – “dependent” in the sense that in a statistical model at least,
the YY is a function of the XX.
A “best practice” sequence of steps used throughout this text to analyze experimental data is
• examine individual points and identify outliers that are likely due to data transcription
errors or measurement blunders
• examine outlier points that are biologically plausible, but raise ref flags about undue
influe on fit models. This information is used to inform the researcher on the strategy
to handle outliers in the statistical analysis, including algorithms for excluding data or
implementation of robust methods.
• provide useful information for initial model filtering (narrowing the list of potential
models that are relevant to the question and data). Statistical modeling includes a
diverse array of models, yet almost all methods used by researchers in biology, and all
models in this book, are generalizations of the linear model specified in (8.3). For some
experiments, there may be multiple models that are relevant to the question and data.
Model checking (step 3) can help decide which model to ultimately use.
2. fit the model, in order to estimate the model parameters and the uncertainty in these
estimates.
3. check the model, which means to use a series of diagnostic plots and computations of
model output to check that the fit model reasonably approximates the data. If the
diagnostic plots suggest a poor approximation, then choose a different model and go
back to step 2.
4. inference from the model, which means to use the fit parameters to learn, with
uncertainty, about the system, or to predict future observations, with uncertainty.
5. plot the model, which means to plot the data, which may be adjusted, and the estimated
parameters (or other results dervived from the estimates) with their uncertainty.
Note that step 1 (exploratory plots) is not data mining, or exploring the data for patterns to test.
For the linear model specified in Model (8.2), the fit model is
yi=b0+b1xi+ei(8.5)(8.5)yi=b0+b1xi+ei
where b0b0 and b1b1 are the coefficients of the fit model and the eiei are the residuals of the
fit model. We can use the coefficients and residuals to recover the yiyi, although this would
rarely be done. More commonly, we could use the coefficients to calculate conditional means
(the mean conditional on a specified value of XX).
^yi=b0+b1xi(8.6)(8.6)y^i=b0+b1xi
The conditional means are typically called fitted values, if the XX are the XX used to fit the
model, or predicted values, if the XX are new. “Predicted values” is often shortened to “the
prediction”.
If our goal is inference, we want to use the fit parameters to learn, with uncertainty, about the
system. Using equation (8.5), the coefficients b0b0 and b1b1 are point estimates of the true,
generating parameters β0β0 and β1β1, the eiei are estimates of εiεi (the true, biological
“noise”), and ∑e2iN−2∑ei2N−2 is an estimate of the true, population variance σ2σ2 (this will
be covered more in chapter xxx but you may recognize that ∑e2iN−2∑ei2N−2 is the formula
for a variance). And, using equation (8.6), ^yiy^i is the point estimate of the parameter μiμi (the
true mean conditional on X=xiX=xi). Throughout this text, Greek letters refer to a theoretical
parameter and Roman letters refer to point estimates.
Our uncertainty in the estimates of the parameters due to sampling is the standard error of the
estimate. It is routine to report standard errors of means and coefficients of the model. While a
standard error of the estimate of σσ is available, this is effectively never reported, at least in
the experimental biology literature, presumably because the variance is thought of as a nuisance
parameter (noise) and not something worthy of study. This is a pity. Certainly treatments can
effect the variance in addition to the mean.
Parametric inference assumes that the response is drawn from some probability distribution
(Normal, or Poisson, or Bernouli, etc.). Throughout this text, I emphasize reporting and
interpreting point estimates and interval estimates of the point estimate. A confidence
interval is a type of interval estimate. A confidence interval of a parameter is a measure of the
uncertainty in the estimate. A 95% confidence interval has a 95% probability (in the sense of
long-run frequency) of containing the parameter. This probability is a property of the
population of intervals that could be computed using the same sampling and measuring
procedure. It is not correct, without further assumptions, to state that there is a 95% probability
that the parameter lies within the interval. Perhaps a more useful interpretation is that the
interval is a compatability interval in that it contains the range of estimates that are
compatible with the data, in the sense that a tt-test would not reject the null hypothesis of a
difference between the estimate and any value within the interval (this interpretation does not
imply anything about the true value).
Another kind of inference is a significance test, which is the computation of the probability of
“seeing the data” or something more extreme than the data, given a specified null hypothesis.
This probability is the p-value, which can be reported with the point estimate and confidence
interval. There are some reasonable arguments made by very influential statisticians that p-
values are not useful and lead researchers into a quagmire of misconceptions that impede good
science. Nevertheless, the current methodology in most fields of Biology have developed in a
way to become completely dependent on p-values. I think at this point, a p-value can be a
useful, if imperfect tool in inference, and will show how to compute p-values throughout this
text.
Somewhat related to a significance test is a hypothesis test, or a Null-Hypothesis Signficance
Test (NHST), in which the pp-value from a significance test is compared to a pre-specified
error rate called αα. Hypothesis testing was developed as a formal means of decision making
but this is rarely the use of NHST in experimental biology. For almost all applications of p-
values that I see in the literature that I read in ecology, evolution, physiology, and wet-bench
biology, comparing a pp-value to αα adds no value to the communication of the results.
1. The data were generated by a process that is “linear in the parameters”, which means
that the different components of the model are added together. This additive part of the
model containing the parameters is the linear predictor in
specifications (8.2) and (8.3) above. For example, a cubic polynomial model
E(Y|X)=β0+β1X+β2X2+β3X3E(Y|X)=β0+β1X+β2X2+β3X3
is a linear model, even though the function is non-linear, because the different components are
added. Because a linear predictor is additive, it can be compactly defined using matrix algebra
E(Y|X)=XβE(Y|X)=Xβ
where mathbfXmathbfX is the model matrix and ββ is the vector of parameters. We discuss
these more in chapter xxx.
A Generalized Linear Model (GLM) has the form g(μi)=ηig(μi)=ηi where ηη (the Greek
letter “eta”) is the linear predictor
η=Xβη=Xβ
GLMs are extensions of linear models. There are non-linear models that are not linear in the
parameters, that is, the predictor is not a simple dot product of the model matrix and a vector
of parameters. For example, the Michaelis-Menten model is a non-linear model
E(Y|X)=β1Xβ2+XE(Y|X)=β1Xβ2+X
that is non-linear in the parameters because the parts are not added together. This text covers
linear models and generalized linear models, but not non-linear models that are also non-linear
in the parameters.
2. The draws from the probability distribution are independent. Independence
implies uncorrelated YY conditional on the XX, that is, for any two YY with the same
value of XX, we cannot predict the value of one given the value of the other. For
example, in the ASK1 data above, “uncorrelated” implies that we cannot predict the
glucose level of one mouse within a specific treatment combination given the glucose
level of another mouse in that combination. For linear models, this assumption is often
stated as “independent errors” (the εε in model (8.2)) instead of independent
observations.
There are lots of reasons that conditional responses might be correlated. In the mouse example,
correlation within treatment group could arise if subsets of mice in a treatment group are
siblings or are housed in the same cage. More generally, if there are measures both within and
among experimental units (field sites or humans or rats) then we’d expect the measures within
the same unit to err from the model in the same direction. Multiple measures within
experimental units (a site or individual) creates “clustered” observations. Lack of independence
or clustered observations can be modeled using models with random effects. These models go
by many names including linear mixed models (common in Ecology), hierarchical models,
multilevel models, and random effects models. A linear mixed model is a variation of
model (8.2). This text introduces linear mixed models in chapter xxx.
Measures that are taken from sites that are closer together or measures taken closer in time or
measures from more closely related biological species will tend to have more similar values
than measures taken from sites that are further apart or from times that are further apart or from
species that are less closely related. Space and time and phylogeny create spatial and temporal
and phylogenetic autocorrelation. Correlated error due to space or time or phylogeny can be
modeled with Generalized Least Squares (GLS) models. A GLS model is a variation of
model (8.2).
Many biological processes generate data in which the error is a function of the mean. For
example, measures of biological variables that grow, such as lengths of body parts or population
size, have variances that “grow” with the mean. Or, measures of counts, such as the number of
cells damaged by toxin, the number of eggs in a nest, or the number of mRNA transcripts per
cell have variances that are a function of the mean. Heteroskedastic error can be modeled
with Generalized Least Squares, a generalization of the linear model, and with Generalized
Linear Models (GLM), which are “extensions” of the classical linear model.
A common misconception is that inference from a linear model assumes that the raw response
variable is normally distributed. Both the error-draw and conditional-draw specifications of a
linear model show precisely why this conception is wrong. Model (??) states explicitly that it
is the error that has the normal distribution – the distribution of YY is a mix of the distribution
of XX and the error. Model (8.3) states that the conditional outcome has a normal distribution,
that is, the distribution after adjusting for variation in XX.
Statistical modeling terminology can be confusing. The XX variables in a statistical model may
be quantitative (continuous or integers) or categorical (names or qualitative amounts) or some
mix of the two. Linear models with all quantitative independent variables are often called
“regression models.” Linear models with all categorical independent variables are often called
“ANOVA models.” Linear models with a mix of quantitative and categorical variables are often
called “ANCOVA models” if the focus is on one of the categorical XX or “regression models”
if there tend to be many independent variables.
This confusion partly results from the history of the development of regression for the analysis
of observational data and ANOVA for the analysis of experimental data. The math underneath
classical regression (without categorical variables) is the linear model. The math underneath
classical ANOVA is the computation of sums of squared deviations from a group mean, or
“sums of squares”. The basic output from a regression is a table of coefficients with standard
errors. The basic ouput from ANOVA is an ANOVA table, containing the sums of squares along
with mean-squares, F-ratios, and p-values. Because of these historical differences in usage,
underlying math, and output, many textbooks in biostatistics are organized around regression
“vs.” ANOVA, presenting regression as if it is “for” observational studies and ANOVA as if it
is “for” experiments.
It has been recognized for many decades that experiments can be analyzed using the technique
of classical regression if the categorical variables are coded as numbers (again, this will be
explained later) and that both regression and ANOVA are variations of a more general, linear
model. Despite this, the “regression vs. ANOVA” way-of-thinking dominates the teaching of
biostatistics.
Regression Analysis
Regression analysis is a statistical method used to model the relationship between a
dependent variable and one or more independent variables. It helps in prediction, trend
analysis, and understanding how variables influence each other.
• Models the relationship between one independent variable (X) and one dependent
variable (Y).
• Equation: Y=β0+β1X+ε
• Use Cases: Predicting house prices based on size, sales based on advertising spend.
• Equation: Y=β0+β1X1+β2X2+⋯+βnXn+ε
• Equation: Y=β0+β1X+β2X2+β3Xn+⋯+ε
• Equation: log(p1−p)=β0+β1X1+β2X2+⋯+βnXn
•
Use Cases: Feature selection, high-dimensional datasets.
3. Assumptions of ANOVA
• Independence – Observations are independent.
• Normality – Data follows a normal distribution.
• Homogeneity of Variance (Homoscedasticity) – Variances in different
groups should be similar.
6. Applications of ANOVA
• Medical Research: Comparing drug effectiveness.
• Education: Evaluating different teaching methods.
• Manufacturing: Testing variations in production processes.
• Marketing: Assessing the impact of different advertising strategies.
• One-Way ANOVA checks for differences across one factor.
• Two-Way ANOVA checks for the impact of two factors and interactions.
• Interpretation of FFF-statistic and p-value determines significance.
Gauss-Markov Theorem
1. Introduction
The Gauss-Markov theorem states that in a linear regression model
where the errors satisfy certain conditions, the Ordinary Least Squares
(OLS) estimator is the Best Linear Unbiased Estimator (BLUE).
This means that among all possible linear unbiased estimators, OLS has
the smallest variance.
No Perfect Multicollinearity
o The independent variables are not perfectly correlated.
4. Conclusion
Since OLS estimators satisfy the conditions of unbiasedness and have the
minimum variance among all linear estimators, they are Best Linear
Unbiased Estimators (BLUE).
Conclusion
Regression models are powerful tools for data analysis. The choice of model
depends on the type of data, assumptions, and objective.
Low Low 75
Low High 80
High Low 85
High High 95
• Main Effects:
o Temperature Effect: (Avg. Quality at High – Avg. Quality at Low)
o Pressure Effect: (Avg. Quality at High – Avg. Quality at Low)
• Interaction Effect:
o If (High, High) quality is higher/lower than expected based on
individual effects of Temperature and Pressure.
6. Conclusion
Factorial experiments provide efficient, cost-effective analysis of multiple
factors and their interactions.
2. Model of ANCOVA
The general ANCOVA model is:
How ANCOVA Works
1. Removes variability in YYY due to ZZZ (covariate).
2. Adjusts means for the categorical groups based on the covariate.
3. Tests for group differences after controlling for ZZZ.
3. Assumptions of ANCOVA
For ANCOVA to be valid, these assumptions must hold:
Traditional 50 65
Teaching Method Pre-Test Score (Covariate) Final Test Score
Traditional 60 72
New Method 50 75
New Method 60 82
Analysis
• The covariate (Pre-Test Score) affects the dependent variable (Final
Score).
• ANCOVA removes this effect and tests whether the New Method is
significantly better.
Regression Diagnostics
Regression diagnostics is the process of evaluating how well a regression
model fits the data and checking if it meets key assumptions. If these
assumptions are violated, predictions and inferences may be unreliable.
B. Checking Homoscedasticity
• Residual Plot: Plot residuals against fitted values.
• Breusch-Pagan Test: A statistical test for homoscedasticity.
E. Checking Multicollinearity
• Variance Inflation Factor (VIF): A VIF > 10 indicates severe
multicollinearity.
Residuals help in diagnosing whether the model fits the data well.
2. Properties of Residuals
• The sum of residuals in OLS regression is zero:
Raw Residuals:
Influence diagnostics
1.Influence diagnostics identify data points that have a large impact on the
regression model. A few extreme observations (outliers or high-leverage points)
can skew the model, making predictions unreliable.
2. Types of Transformations
A. Log Transformation (Y’=logY or X’=logX)
Used when the relationship is exponential.
• Helps stabilize variance and make residuals more normal.
• Example:
• Commonly used in economics, biology, and finance.
B. Square Root Transformation :
Regression Classification
Metric
Models Models
Adjusts R² for
Adjusted R² number of N/A
predictors
Measures
AUC-ROC N/A classification
performance
Balances precision
F1-Score N/A
and recall
4. Model Building Strategies
1. Start with a Simple Model
o Fit a baseline model first.
o Avoid using too many variables initially.
2. Iterative Feature Selection
o Use correlation analysis, VIF (Variance Inflation Factor), and
domain knowledge.
3. Compare Models Using Cross-Validation
o Use train-validation-test split to ensure model generalization.
4. Check for Assumptions
o Linearity → Scatter plots.
o Homoscedasticity → Residual plots.
o Normality of Residuals → Q-Q plot.
5. Hyperparameter Tuning
o Use Grid Search or Random Search to optimize model
parameters.
Metric Purpose
Standard Poisson
Assumes mean = variance Counts of emails per day
Regression
Zero-Inflated Defects in a
Accounts for excess zeros
Poisson (ZIP) manufacturing process
Metric Purpose