SV statistics 4

📚 SV_statistics 4.docx

Brief overview

This document provides a comprehensive guide to advanced statistical analysis techniques. It covers methods for comparing group means, understanding interactions, analyzing longitudinal data, and predicting binary outcomes, essential for drawing robust conclusions from experimental and observational data.

Key points

  • Overview of one-way ANOVA for comparing multiple group means and interpreting F-statistics and effect sizes.
  • Analysis of core assumptions in statistical models, their impact on results, and strategies for addressing violations.
  • Understanding main effects and interactions in factorial ANOVA designs.
  • Methods for analyzing data with repeated measures, including assumptions and complex designs.
  • Application of simple and multiple linear regression for modeling relationships between variables.
  • Principles and application of logistic regression for analyzing binary outcome data.

1. One-way ANOVA: comparing group means

1.1 Introduction to one-way ANOVA

  • One-way ANOVA is a statistical method to compare the means of two or more groups.
  • It is a generalization of the independent groups t-test.
  • ANOVA uses variances to make inferences about means, particularly in experimental data.
  • The core idea is to partition the total variability in the data into components attributable to different sources.

📝 Example: In a study comparing depression treatment, ANOVA can assess if the average scores on a depression rating scale differ significantly between groups receiving placebo, cognitive therapy (CT), or antidepressant medication (ADM).

1.2 The ANOVA model and hypotheses

  • The full model assumes that population means can differ across groups (YijY_{ij} represents the score of person ii in group jj, with j=1,…,aj=1, \dots, a groups). Yij=μj+ϵijY_{ij} = \mu_j + \epsilon_{ij}
  • The reduced model is a special case where all population means are assumed to be equal. H0:μ1=μ2=⋯=μaH_0: \mu_1 = \mu_2 = \dots = \mu_a
  • This null hypothesis (H0H_0) forms the basis for the statistical test.

📝 Example: For depression treatment, the full model allows for different average HDRS scores at week 8 for placebo, CT, and ADM groups. The reduced model assumes the average HDRS score is the same across all three treatments.

1.3 Exploratory data analysis

  • Exploratory Data Analysis (EDA) is crucial before formal analysis.
  • It helps identify data errors, extreme values, and patterns.
  • Visualizing data, even just looking at data matrices, can reveal obvious trends.

🔑 Important: Sometimes, the data pattern is so clear it's called the "interocular trauma test"—the conclusion hits you between the eyes.

1.4 Parameter estimation and sums of squares

  • Unknown parameters (like population means μj\mu_j) are estimated from sample data using a criterion, typically least squares.

  • This minimizes the sum of squared differences between observations and model-predicted values (residuals).

  • Sums of squares (SS) quantify the size of residuals.

    • SSE_Reduced: Sum of squared errors from the reduced model (grand average).
    • SSE_Full: Sum of squared errors from the full model (group averages).
    • SSE_Effect: The reduction in error achieved by using the full model instead of the reduced model. SSEEffect=SSEReduced−SSEFullSSE_{Effect} = SSE_{Reduced} - SSE_{Full}.
    • SSTot: Total sum of squares, deviation from the grand sample average. SSTot=SSEReducedSSTot = SSE_{Reduced}.

📝 Example: For the depression study, SSE_Reduced measures variability around the overall average HDRS score. SSE_Full measures variability around each treatment group's average HDRS score. SSE_Effect quantifies how much the treatment groups reduce this overall variability.

1.5 Degrees of freedom (df)

  • Degrees of freedom (df) relate to the number of freely estimated parameters.
  • They inform model complexity and constrain residuals.
  • Each sum of squares has associated degrees of freedom.
Sum of SquaresDegrees of FreedomFormula
SSEReducedSSE_{Reduced}dfReduced=n−1df_{Reduced} = n - 1n−1n - 1
SSEFullSSE_{Full}dfFull=n−adf_{Full} = n - an−an - a
SSEEffectSSE_{Effect}dfEffect=a−1df_{Effect} = a - 1(n−1)−(n−a)=a−1(n-1) - (n-a) = a - 1
  • nn: total number of participants.
  • aa: number of groups (levels of the factor).

1.6 Mean squares (MS)

  • Mean Squares (MS) are calculated by dividing sums of squares by their respective degrees of freedom. MSError=SSEFulldfFull=SSEFulln−aMS_{Error} = \frac{SSE_{Full}}{df_{Full}} = \frac{SSE_{Full}}{n-a} MSEffect=SSEEffectdfEffect=SSEEffecta−1MS_{Effect} = \frac{SSE_{Effect}}{df_{Effect}} = \frac{SSE_{Effect}}{a-1}
  • These represent average variability. MSErrorMS_{Error} is often called the Mean Squared Error (MSE).

1.7 The F-statistic

  • The F-statistic is the test statistic for ANOVA.
  • It compares the variability between groups to the variability within groups. F=MSEffectMSErrorF = \frac{MS_{Effect}}{MS_{Error}}
  • The numerator (MSEffectMS_{Effect}) is sensitive to both sampling variability and systematic variability (treatment effect).
  • The denominator (MSErrorMS_{Error}) is sensitive only to sampling variability.

🔑 Important: If the null hypothesis (H0H_0) is true, the expected values of MSEffectMS_{Effect} and MSErrorMS_{Error} are equal (σ2\sigma^2). If H0H_0 is false, E(MSEffect)>E(MSError)E(MS_{Effect}) > E(MS_{Error}).

1.8 Sampling distribution and p-value

  • Under the null hypothesis (H0H_0), the F-statistic follows an F-distribution with dfEffectdf_{Effect} and dfFulldf_{Full} degrees of freedom. F∼Fa−1,n−aF \sim F_{a-1, n-a}
  • The p-value is the probability of observing an F-statistic as extreme as, or more extreme than, the one calculated from the sample, assuming H0H_0 is true. p=Pr(Fa−1,n−a>Fobserved∣H0)p = \text{Pr}(F_{a-1, n-a} > F_{observed} | H_0)

🔑 Important: A small p-value (typically < 0.05) provides evidence against the null hypothesis, suggesting a significant difference between group means.

1.9 Interpreting results

  • Fisher's perspective: The p-value is a continuous measure of evidence against H0H_0. Smaller p-values indicate stronger evidence.
  • Neyman-Pearson perspective: The p-value is compared to a significance level (α\alpha, e.g., 0.05). If p<αp < \alpha, reject H0H_0.
  • Both perspectives are used. The choice of α\alpha depends on the context and risk of false positives.

📝 Example: If the p-value for the depression study is 0.027, and α=0.05\alpha=0.05, we reject H0H_0. This suggests there is a significant difference in HDRS scores among the treatment groups.

1.10 The ANOVA table

  • ANOVA results are commonly summarized in an ANOVA table.
  • It typically includes sources of variation (Effect, Error), Sums of Squares, Degrees of Freedom, Mean Squares, F-statistic, and p-value.
SourceSSdfMSFp
TreatmentSSEEffectSSE_{Effect}a−1a-1MSEffectMS_{Effect}FobsF_{obs}pobsp_{obs}
ErrorSSEFullSSE_{Full}n−an-aMSErrorMS_{Error}
TotalSSTotSSTotn−1n-1

1.11 Effect size

  • Effect size measures the magnitude of the observed effect, independent of sample size.

  • It is crucial for clinical or practical relevance.

  • Proportion of variance explained (η2\eta^2) is a common effect size. η2=SSEEffectSSTot\eta^2 = \frac{SSE_{Effect}}{SSTot}

    • It represents the proportion of the total variance in the outcome variable that is associated with the factor (groups).
  • The unbiased proportion of variance explained (ω2\omega^2) is a less biased estimator, especially for small sample sizes, but can be negative (set to zero if so).

🔑 Important: A small effect size means the factor explains only a small portion of the outcome's variability. Rules of thumb exist (small ≈ 1%, medium ≈ 6%, large ≈ 14%), but context is key.

📝 Example: An η2\eta^2 of 0.03 indicates that 3% of the variability in HDRS scores is explained by the type of treatment received. This is considered a small effect.

🔑 Important: Both the F-statistic and p-value depend on both the effect size and the sample size, whereas effect size measures focus solely on the magnitude of the relationship.

🔑 Important: For the entire topic of one-way ANOVA, understanding how to partition total variance into between-group and within-group components using sums of squares and then forming an F-statistic to test differences in means is paramount.

2. Assumptions and robustness in statistical analysis

2.1 Core assumptions and robustness

Statistical assumptions are premises for scientific reasoning. If these premises are invalid, conclusions drawn from the analysis may also be invalid.

Key assumptions at the population level include:

  • Normality of errors: The errors (residuals) from the model follow a normal distribution.
  • Independence of errors: Errors are not related to each other.
  • Equal population variances (homoscedasticity): The variance of the errors is the same across all groups or levels of predictors.
  • No outliers: The dataset does not contain observations that are inconsistent with the rest of the data.

A statistical method is considered robust against a violation if statistical inferences remain valid even when the assumption is not met. Robustness ensures that the stated uncertainty (e.g., confidence interval width) accurately reflects the true uncertainty.

🔑 Important: Robustness means that the method's conclusions are still reliable despite minor assumption violations, but significant violations can invalidate inferences.

Violations of assumptions can be investigated using informal graphical checks and formal statistical tests.

  • Graphical checks: Residual plots (residuals vs. fitted values) and QQ plots help visualize the distribution of errors and their relationship with fitted values.
  • Formal tests: Tests like Levene's test can assess homoscedasticity, but their own validity depends on other assumptions.
AssumptionViolation Impact
HomoscedasticityInflated or deflated pp-values and confidence intervals, especially with unequal group sizes.
NormalityCan affect pp-values and confidence intervals, particularly with skewed distributions and unequal group sizes.
IndependenceCan lead to seriously underestimated or overestimated uncertainty, invalidating all inferences.
OutliersCan heavily distort means and variances, making ANOVA results unreliable.

🔑 Important: Graphical checks are often preferred over formal tests for assumptions, as they provide a more intuitive understanding of potential issues.

2.2 Dealing with assumption violations and outliers

When assumptions are violated, several strategies can be employed.

2.2.1 Transformations

  • Logarithmic transformation (ln⁡(x)\ln(x)): Often used when homoscedasticity is violated, especially with response time data where the mean and variance are positively correlated. This transformation is only applicable to positive values.

2.2.2 Analysis of ranks

  • Ranks: Convert observed values to their ranks. This method is robust against outliers and non-normality.
  • Advantages: Handles outliers and non-normality well.
  • Disadvantages: Still requires independence and equal variance assumptions. It does not allow for estimation of differences and is less suitable for multi-factor designs.

🔑 Important: The "garden of forking paths" refers to the numerous decisions made during data analysis, where different choices can lead to different results. Preregistration helps mitigate this by pre-specifying analysis plans.

2.3 Contrasts: Specific comparisons

While an overall FF-test in ANOVA indicates if any differences exist between group means, contrasts allow for specific, directed comparisons between groups.

2.3.1 Terminology

  • Contrast/Comparison: A linear combination of sample averages involving two or more conditions.
  • Coefficients (cjc_j): Numbers used in the linear combination to define the contrast.
  • Planned contrast: Specified before data collection, based on a priori hypotheses. These are confirmatory.
  • Post-hoc contrast: Identified after looking at the data, often inspired by observed patterns. These are exploratory.

The formal definition of a contrast for three conditions (a=3a=3) with sample averages yˉ1,yˉ2,yˉ3\bar{y}_1, \bar{y}_2, \bar{y}_3 and coefficients c1,c2,c3c_1, c_2, c_3 is: g=c1yˉ1+c2yˉ2+c3yˉ3g = c_1 \bar{y}_1 + c_2 \bar{y}_2 + c_3 \bar{y}_3 where the sum of coefficients ∑cj\sum c_j must equal zero.

🔑 Important: Planned contrasts are generally more powerful than post-hoc contrasts because they focus on specific hypotheses.

2.3.2 Single planned contrast

For a single planned contrast (gg), its sampling distribution is normal under the assumption of normality of errors. The expected value of gg is the population contrast (CC), and its variance can be estimated using the Mean Squared Error (MSEFullMSE_{Full}) from the ANOVA.

The standard error of gg is SE(g)=MSEFull∑cj2mjSE(g) = \sqrt{MSE_{Full} \sum \frac{c_j^2}{m_j}}.

Statistical inference can be performed using:

  • Confidence intervals (CI): Preferred as they provide a point estimate and uncertainty. The CI is g±tα/2,dfFull×SE(g)g \pm t_{\alpha/2, df_{Full}} \times SE(g).
  • Hypothesis testing: Testing H0:C=0H_0: C = 0 using a tt-statistic: t=g−CSE(g)t = \frac{g - C}{SE(g)}.

2.3.3 Multiple testing

When many contrasts are tested simultaneously, the chance of making at least one Type I error (false alarm) increases. This is known as the familywise (FW) error rate.

MethodControlsPowerDescription
BonferroniFW error rate (αFW\alpha_{FW})LowerDivides the overall αFW\alpha_{FW} by the number of tests (PP), setting a stricter threshold for each individual test (αFW/P\alpha_{FW}/P).
Holm's methodFW error rate (αFW\alpha_{FW})HigherA sequential procedure that sorts pp-values and applies increasingly lenient adjusted thresholds, offering better power than Bonferroni.

🔑 Important: For non-pairwise multiple comparisons, use Holm's method. Avoid Bonferroni due to its conservatism, which reduces power.

2.3.4 Pairwise contrasts

  • Tukey-Kramer procedure: Used for all pairwise comparisons, especially post-hoc. It controls the FW error rate by using the studentized range distribution.
  • Simultaneous confidence intervals: Used with Tukey-Kramer to guarantee that all intervals simultaneously contain their true values.

🔑 Important: For pairwise contrasts, use the Tukey-Kramer procedure.

2.3.5 Post-hoc contrasts

Evaluating post-hoc contrasts requires caution.

  • Fishing expeditions: Formulating hypotheses based on observed data without independent replication leads to an overestimation of confidence.
  • Replication: If strong claims are made from post-hoc findings, a new, preregistered replication study is ideal.
  • HARKing (Hypothesizing After the Results are Known): Presenting a hypothesis as confirmatory when it was actually developed after seeing the data is poor scientific practice.

🔑 Important: Always clearly distinguish between planned confirmatory hypotheses and exploratory, data-derived hypotheses in presentations.

2.3.6 Additional questions on contrasts

  • Orthogonal contrasts: A set of a−1a-1 contrasts that are independent of each other. The result of one does not inform the result of another. The sum of squares for these contrasts equals the total sum of squares for the effect in ANOVA.
  • ANOVA vs. Contrasts: ANOVA tests for any difference, while contrasts test specific, predefined differences. They often work together.
  • Method choice: Use Holm's for non-pairwise contrasts and Tukey-Kramer for pairwise contrasts.

3. Factorial ANOVA: interactions and main effects

3.1 Introduction to factorial designs

  • Factorial ANOVA analyzes data with multiple factors simultaneously.
  • Factors are independent variables, and levels are the specific conditions within a factor.
  • A cell represents a unique combination of factor levels.
  • The goal is to understand the independent and combined effects of these factors on a dependent variable.

3.2 Understanding cell means, marginal means, and grand mean

  • In factorial designs, we analyze different types of sample averages.
  • Cell sample averages are the means for each specific combination of factor levels.
  • Marginal averages represent the mean of a factor's levels, averaging across the other factor(s).
  • The grand average is the overall mean of all observations.

For a two-way design with factors A and B, the marginal mean for level jj of A is denoted as μj⋅\mu_{j \cdot}, and for level kk of B as μ⋅k\mu_{\cdot k}. The grand mean is μ⋅⋅\mu_{\cdot \cdot}.

3.3 Interactions and main effects

  • Main effects examine the average effect of one factor across all levels of the other factor.
  • An interaction occurs when the effect of one factor depends on the level of another factor.

Key Relationship: No interaction allows straightforward interpretation of main effects; interaction means effects are not additive.

3.3.1 No interaction

  • If there is no interaction, the effect of one factor is consistent across all levels of the other factor.
  • This means the effects of the factors are additive.
  • For example, the difference between levels of factor B is the same for factor A's level 1 and level 2.

Example: Going from single to committed increases religiosity by 2 points, and going from low to high fertility adds 4 points. If there's no interaction, the combined effect is 2+4=62 + 4 = 6 points.

3.3.2 Interaction effects

  • If an interaction is present, the lines on a graph of cell means will not be parallel.
  • The effect of one factor varies depending on the other factor's level.
  • Interactions can be ordinal (order of effects is preserved) or disordinal (order of effects is reversed).

Example (Disordinal Interaction): For low fertility, single women are more religious than those in relationships. For high fertility, the reverse is true: single women are less religious.

  • When an interaction is significant, interpreting main effects directly can be misleading. It's often better to examine simple effects (effects of one factor at a specific level of the other).

3.4 Effect parameters and the factorial model

  • A factorial model uses effect parameters to represent the contributions of the grand mean, main effects, and interactions.

  • The model is: yijk=μ+αj+βk+(αβ)jk+ϵijky_{ijk} = \mu + \alpha_j + \beta_k + (\alpha\beta)_{jk} + \epsilon_{ijk}

    • μ\mu: the grand mean.
    • αj\alpha_j: the main effect parameter for level jj of factor A.
    • βk\beta_k: the main effect parameter for level kk of factor B.
    • (αβ)jk(\alpha\beta)_{jk}: the interaction effect parameter for cell (j,k)(j,k).
    • ϵijk\epsilon_{ijk}: the residual error.
  • Constraints:

    • Main effect parameters for a factor sum to zero across its levels (∑jαj=0\sum_j \alpha_j = 0, ∑kβk=0\sum_k \beta_k = 0).
    • Interaction effect parameters sum to zero across each factor's levels (∑j(αβ)jk=0\sum_j (\alpha\beta)_{jk} = 0 for any kk, and ∑k(αβ)jk=0\sum_k (\alpha\beta)_{jk} = 0 for any jj).

Key Advantage: Effect parameters clearly show the presence and nature of interactions. For a 2×22 \times 2 design, knowing one interaction parameter allows derivation of the others.

  • The number of free parameters in an a×ba \times b design is 1+(a−1)+(b−1)+(a−1)(b−1)1 + (a-1) + (b-1) + (a-1)(b-1).

Test Yourself 2:

If μem=3\mu_{em} = 3, μew=2\mu_{ew} = 2, and μom=2\mu_{om} = 2, and there is no interaction, then μow=3\mu_{ow} = 3.

If μow=5\mu_{ow} = 5 (with interaction):

  • μ=3.5\mu = 3.5
  • αe=0.5\alpha_e = 0.5
  • βm=0.5\beta_m = 0.5
  • (αβ)em=−0.5(\alpha\beta)_{em} = -0.5

This interaction is disordinal.

Claim: "Women have more side effects than men." This is FALSE, as the interaction shows this isn't always true.

3.5 Analyzing a balanced two-way factorial design

  • Three main hypotheses are tested: main effect of factor A, main effect of factor B, and the interaction effect.
  • The analysis involves comparing a full model (including all effects) with reduced models (with specific effects removed).
  • The error sum of squares (SSE) is minimized in each model.

3.5.1 Testing for interaction

  • Hypothesis: H0:(αβ)jk=0H_0: (\alpha\beta)_{jk} = 0 for all j,kj, k (no interaction).
  • Test statistic: The F-statistic is calculated as F=MSinteractionMSerrorF = \frac{MS_{interaction}}{MS_{error}}, where MSinteraction=SSAXB∣A,BdfinteractionMS_{interaction} = \frac{SSA_{XB|A,B}}{df_{interaction}} and MSerror=SSEFulldfFullMS_{error} = \frac{SSE_{Full}}{df_{Full}}.
  • Degrees of freedom: dfinteraction=(a−1)(b−1)df_{interaction} = (a-1)(b-1) and dfFull=ab(m−1)df_{Full} = ab(m-1).
  • Effect size: Partial eta-squared (ηp2\eta_p^2) measures the proportion of variance uniquely explained by the interaction.

Test Yourself 3:

  • Reported effect sizes are helpful when planning new studies. TRUE
  • Reported effect sizes are helpful to understand the practical relevance of an effect. TRUE
  • In a one-way design, the non-partial and the partial are equal. TRUE

3.5.2 Testing for main effects

  • Hypothesis for Factor A: H0:αj=0H_0: \alpha_j = 0 for all jj (no main effect of A).
  • Test statistic: F=MSAMSerrorF = \frac{MS_{A}}{MS_{error}}, where MSA=SSAdfAMS_{A} = \frac{SSA}{df_{A}} and MSerror=SSEFulldfFullMS_{error} = \frac{SSE_{Full}}{df_{Full}}.
  • Degrees of freedom: dfA=a−1df_A = a-1 and dfFull=ab(m−1)df_{Full} = ab(m-1).
  • Effect size: Partial eta-squared (ηp2\eta_p^2) measures the proportion of variance uniquely explained by the main effect.

Test Yourself 4:

For factor B (Fertility), with dfB=1df_B = 1 and dferror=140df_{error} = 140 (using balanced data from example):

  • The F-statistic for the main effect of fertility is approximately 3.19.
  • The corresponding p-value is approximately 0.076.

We can conclude that there is SUGGESTIVE evidence for a main effect of Fertility.

3.6 Handling unbalanced designs

  • Unbalanced designs occur when cell sizes (mjkm_{jk}) are unequal.
  • Basic analytical ideas remain, but formulas become more complex.
  • Software packages often require specific instructions (e.g., Type III sum of squares in many programs) to provide valid results.
  • Unbalancedness can make sources of variance (main effects, interactions) dependent, complicating interpretation.

🔑 Important: For unbalanced designs with equal cell importance, Type III sum of squares is crucial for correct hypothesis testing.

3.7 The data multiverse

  • Data are often constructed through arbitrary decisions (e.g., how to define "single" or "high fertility").
  • The data multiverse refers to the large number of possible datasets that could be constructed from the same raw observations.
  • If an effect is real and robust, it should appear consistently across many justifiable data constructions.

📝 Example: A study might construct 120 different datasets by varying classification criteria for relationship status and fertility. If the interaction effect is robust, it should be significant in a substantial portion of these datasets.

  • Examining the distribution of p-values across these datasets helps assess the robustness of findings.

3.8 Other topics

  • Hidden multiplicity: Testing multiple effects (main effects, interaction) can be seen as multiple testing, but corrections are often not applied unless hypotheses are exploratory.
  • Assumptions: Visual checks of residual plots and QQ-plots are preferred for assumption assessment. Robust alternatives to ANOVA are less common.
  • Contrasts: Can be defined for marginal means (main effects) or cell means. They are most meaningful when the interaction is not important.

🔑 Important: The core of factorial ANOVA is understanding how main effects and interactions partition variance and how to test hypotheses about them.

4. Repeated measures ANOVA and its complexities (part 1)

4.1 Introduction to repeated measures designs

  • Repeated measures: A study design where participants are measured multiple times.
  • Between-subject (BS) factor: A factor that partitions participants into subgroups.
  • Within-subject (WS) factor: A factor where participants are measured at each of its levels.

4.2 Terminology and basic concepts

  • A design can have both BS and WS factors.
  • In a BS factor, different participants are in each level.
  • In a WS factor, the same participants are measured at each level.

A participant is nested within a BS factor level, but not within a WS factor level.

4.3 The simplest repeated measures design: paired samples

  • Paired t-test: Used for two related groups or two measurements from the same group.
  • This design evaluates differences within individuals, reducing error.
  • It significantly reduces error variance compared to independent groups t-tests.
FigureDescriptionCorrelation (ρ)t-test p-valueMeasurement Error Variance Ratio
AIndependent groups0Not applicableLargest
BPaired groups (repeated measures)HighSmallSmallest

4.4 More complex repeated measures designs

  • One WS factor (e.g., multiple time points):

    • If more than two levels, a simple paired test is insufficient.
    • A more general ANOVA model is used.
    • The model includes random effects for individuals, accounting for consistent differences.
  • Model notation: yik=μ+βk+τi+ϵiky_{ik} = \mu + \beta_k + \tau_i + \epsilon_{ik}

    • yiky_{ik}: Score for person ii at level kk.
    • μ\mu: Grand mean.
    • βk\beta_k: Effect of factor level kk.
    • τi\tau_i: Random effect of person ii.
    • ϵik\epsilon_{ik}: Random error.
  • Individual differences: The variance of τi\tau_i indicates the extent of inter-individual differences.

    • Large τi\tau_i variance means large individual differences.
    • Zero τi\tau_i variance means no individual differences.
  • Sphericity assumption: For WS factors with more than two levels, correlations between all pairs of measurements are assumed to be equal.

    • This is similar to homoscedasticity in BS designs.
    • It requires constant variance and equal correlations between all pairs of measurements.
  • One BS and one WS factor (split-plot design):

    • Example: Nicotine group (BS) and measurement moment (WS).
    • Model notation includes person effects nested within BS factor levels: yi(j)k=μ+αj+βk+(αβ)jk+τi(j)+ϵi(j)ky_{i(j)k} = \mu + \alpha_j + \beta_k + (\alpha\beta)_{jk} + \tau_{i(j)} + \epsilon_{i(j)k}
    • αj\alpha_j: Effect of BS factor level jj.
    • (αβ)jk(\alpha\beta)_{jk}: Interaction effect of BS factor jj and WS factor kk.
    • τi(j)\tau_{i(j)}: Random effect of person ii nested within BS level jj.

In split-plot designs, the interaction between the BS factor and the WS factor is key.

4.5 Statistical inference for repeated measures

  • F-tests for one WS factor:

    • Null hypothesis (H0H_0): All effect parameters for the WS factor are zero.
    • The F-statistic compares the variance due to the WS factor to the variance of the interaction between the WS factor and participants.
    • F=MSBMSB×SF = \frac{MS_B}{MS_{B \times S}}
    • Degrees of freedom: dfnum=b−1df_{num} = b-1, dfden=(b−1)(n−1)df_{den} = (b-1)(n-1).
  • F-tests for one BS and one WS factor:

    • Main effect of BS factor A: Tested like a simple one-way BS ANOVA using averaged scores.
      • F=MSAMSerrorF = \frac{MS_A}{MS_{error}}
      • Degrees of freedom: dfnum=a−1df_{num} = a-1, dfden=n−adf_{den} = n-a.
    • Main effect of WS factor B:
      • Degrees of freedom: dfnum=b−1df_{num} = b-1, dfden=(n−a)(b−1)df_{den} = (n-a)(b-1).
    • Interaction effect A x B:
      • F=MSA×BMSA×B×SF = \frac{MS_{A \times B}}{MS_{A \times B \times S}}
      • Degrees of freedom: dfnum=(a−1)(b−1)df_{num} = (a-1)(b-1), dfden=(n−a)(b−1)df_{den} = (n-a)(b-1).

4.6 Assumptions and violations

  • Key assumptions:

    • Normality of residuals.
    • Independence of errors (between participants).
    • Compound symmetry (or sphericity) for WS factors.
    • No outliers.
  • Sphericity violation:

    • Diagnosed using Mauchly's test (WW).
    • If violated, adjusted F-tests (e.g., Greenhouse-Geisser, Huynh-Feldt) are used.
    • These corrections adjust the degrees of freedom, often leading to non-integer values.
    • ϵ\epsilon measures the deviation from sphericity; ϵ=1\epsilon=1 means sphericity holds.
  • Alternative analyses:

    • Friedman test: A non-parametric alternative for a single WS factor if sphericity is violated.
    • Mixed models: More flexible for complex designs, unequal measurements, and certain assumption violations.

Sphericity is crucial for WS factors with more than two levels.

4.7 Effect sizes and sample size

  • Effect sizes: "Generalized" effect sizes are used, accounting for participants as a factor but not a manipulated one.
  • Sample size advantage: Repeated measures designs require fewer participants than BS designs for the same statistical power, especially when correlations between measurements are high.
    • nBS=nWS×b×(1−ρ)n_{BS} = n_{WS} \times b \times (1 - \rho)

A higher correlation (ρ\rho) between repeated measures leads to a greater sample size advantage.

🔑 Important: Repeated measures ANOVA offers increased power with fewer participants but relies on stricter assumptions like sphericity, requiring careful assessment and potential adjustments.

4.8 Understanding regression and its assumptions

Regression analysis aims to predict one variable based on another. The regression line shows the best linear prediction.

It often lies below the identity line. This occurs due to the regression effect, where extreme scores tend to be less extreme upon re-measurement.

🔑 Important: Regression is named so because scores tend to "regress" toward the mean.

4.9 Key assumptions for accurate regression interpretation

Accurate interpretation of regression estimates relies on several assumptions. Checking these assumptions is crucial.

It is done more effectively through residual plots than just looking at R2R^2.

AssumptionDescription
LinearityThe expected value of y is a linear function of x.
HomoscedasticityThe variability around the regression line is constant.
Independence of errorsThe errors (residuals) are independent of each other.
Normal distributionThe errors are normally distributed (less critical for prediction).
No outliersNo data points significantly deviate from the general trend.

4.10 Checking assumptions with residuals

Residual plots offer a powerful way to check regression assumptions. They visualize the difference between observed and predicted values.

  • Scatterplots: Can reveal non-linearity.
  • Residual plots: Show patterns that indicate assumption violations.
    • A random scatter of points around zero suggests assumptions are met.
    • A "fan" or "cone" shape indicates heteroscedasticity (non-constant variance).
    • A curved pattern suggests a linearity violation.
  • QQ plots: Assess the normality of residuals.

📝 Example: A curved pattern in a residual plot suggests the relationship might be non-linear.

4.11 Handling non-linearity and outliers

When linearity is violated, flexible regression methods can be used. These methods allow for smoother, non-linear functions.

  • Outliers: Observations inconsistent with the rest of the data.
    • They can severely distort model fits.
    • Detection is often done via residual or QQ plots.
    • If an outlier is confirmed as an error, it can be removed.
    • If uncertain, analyze with and without the outlier.

📝 Example: Including an outlier in Olympic 100m winning times made predictions for future times less reliable and wider.

4.12 Measurement error in predictors

Measurement error in a predictor variable (xx) can introduce bias. This is called attenuation.

  • If xx is measured with error (x=xT+ηx = x_T + \eta), the regression coefficient (β\beta) is biased downwards.
  • This means the observed relationship is weaker than the true relationship.
  • The lower the reliability of the measurement, the larger the bias.

🔑 Important: Measurement error in predictors systematically weakens the observed relationship.

5. Multiple linear regression and special predictors

5.1 Multiple linear regression model

  • Multiple linear regression (MLR): An extension of simple linear regression that uses more than one predictor variable.

  • Model notation: yi=β0+β1xi1+⋯+βpxip+ϵiy_i = \beta_0 + \beta_1 x_{i1} + \dots + \beta_p x_{ip} + \epsilon_i

    • yiy_i: outcome score for observation ii.
    • xikx_{ik}: score of unit ii on predictor kk.
    • β0\beta_0: intercept.
    • βk\beta_k: regression weight for predictor kk.
    • ϵi\epsilon_i: random error.
  • Assumptions: Similar to simple linear regression, including normality of errors, equal variances (homoscedasticity), linearity, and independence of errors.

  • Intercept: The expected value of yy when all predictors are zero.

  • Regression weight (βk\beta_k): The expected change in yy for a unit increase in xkx_k, while holding other predictors constant.

Interpretation of regression weights is always relative to the other predictors in the model.

5.2 Parameter estimation and interpretation

  • Least squares principle: Minimizes the sum of squared residuals (SSresSS_{res}).

  • Estimated regression coefficients: For p>2p>2, no simple formula exists without matrix algebra.

  • Residual standard error (RMSE): SSresn−p−1\sqrt{\frac{SS_{res}}{n-p-1}} is a measure of unexplained variability.

  • Example interpretation:

    • A unit increase in test anxiety, controlling for mock exam score, is associated with an expected change of -0.004 in the final exam score.
    • A unit increase in mock exam score, controlling for test anxiety, is associated with an expected change of 0.621 in the final exam score.

5.3 Effect size measures

  • Coefficient of multiple determination (R2R^2): The proportion of variance in the outcome explained by all predictors.
  • Partial correlation (ry⋅xkr_{y \cdot x_k}): The correlation between yy and xkx_k after removing the linear influence of other predictors.
  • Semi-partial correlation (sry⋅xksr_{y \cdot x_k}): The correlation between yy and xkx_k, after removing the linear influence of other predictors from xkx_k only.

If predictors are uncorrelated, R2R^2 is the sum of squared semi-partial correlations. This is not generally true when predictors are correlated.

5.4 Hypothesis testing

  • Full model hypothesis test: Tests if all predictors jointly explain a significant portion of the variance.
    • H0:β1=β2=⋯=βp=0H_0: \beta_1 = \beta_2 = \dots = \beta_p = 0
    • Uses an FF-statistic: F=R2/p(1−R2)/(n−p−1)F = \frac{R^2 / p}{(1-R^2) / (n-p-1)}
  • Reduced model hypothesis test: Tests if a subset of predictors adds significant explanatory value.
    • H0:βq+1=⋯=βp=0H_0: \beta_{q+1} = \dots = \beta_p = 0
    • Uses an FF-statistic: F=(Rfull2−Rreduced2)/(p−q)(1−Rfull2)/(n−p−1)F = \frac{(R^2_{full} - R^2_{reduced}) / (p-q)}{(1-R^2_{full}) / (n-p-1)}
  • Individual predictor test: Tests if a single predictor is significant after controlling for others.
    • H0:βk=0H_0: \beta_k = 0
    • Uses a tt-test: t=β^kSE(β^k)t = \frac{\hat{\beta}_k}{SE(\hat{\beta}_k)}
    • The square of the tt-statistic for a single predictor equals the FF-statistic for the reduced model with q=p−1q = p-1.

5.5 Special predictors

5.5.1 Categorical predictors

  • A categorical variable has distinct groups, not a quantity.

  • Dummy coding: Represents categories using binary (0/1) variables called dummy variables.

  • For a categorical predictor with KK levels, K−1K-1 dummy variables are typically included. The omitted category is the reference level.

  • In a main effects model, dummy variables create parallel regression lines for each category.

    • The intercept represents the reference group's intercept.
    • A dummy coefficient represents the difference in intercepts between its category and the reference category.
  • Example (Mental Rotation):

    • Stimulus type (Same/Different). If "Same" is reference:
      • Different dummy variable: 1 if Different, 0 if Same.
      • β0\beta_0: Log RT for Same stimuli at 0° rotation.
      • βDifferent\beta_{\text{Different}}: Difference in Log RT between Different and Same stimuli at 0° rotation.

5.5.2 Interaction terms

  • An interaction occurs when the effect of one predictor depends on the level of another.

  • Modeled by including the product of the predictors as a new term.

  • Categorical x Continuous Interaction:

    • Model: y=β0+β1X+β2D+β3(X⋅D)+ϵy = \beta_0 + \beta_1 X + \beta_2 D + \beta_3 (X \cdot D) + \epsilon
    • If β3≠0\beta_3 \neq 0, the regression lines for the two categories (D=0D=0 and D=1D=1) are not parallel.
    • β1\beta_1: Effect of XX for the reference category (D=0D=0).
    • β1+β3\beta_1 + \beta_3: Effect of XX for the other category (D=1D=1).
    • β2\beta_2: Difference in intercepts between categories when X=0X=0.
    • β3\beta_3: Difference in the effect of XX between the two categories.
  • Continuous x Continuous Interaction:

    • Model: y=β0+β1X1+β2X2+β3(X1⋅X2)+ϵy = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \beta_3 (X_1 \cdot X_2) + \epsilon
    • Interpretation often requires centering predictors or choosing specific values to visualize the interaction surface.

5.5.3 Squared terms

  • Squared predictors model non-linear relationships (e.g., quadratic effects).
  • Model: y=β0+β1X+β2X2+ϵy = \beta_0 + \beta_1 X + \beta_2 X^2 + \epsilon
  • The sign of β2\beta_2 indicates if the curve has a maximum (β2<0\beta_2 < 0) or minimum (β2>0\beta_2 > 0).
  • The rate of change of yy depends on the value of XX.

Adding squared terms allows the regression model to represent curved relationships.

5.6 Multicollinearity

  • Multicollinearity: Strong linear relationships among predictor variables.
  • Manifestations:
    • Unstable and large regression coefficients ("bouncing betas").
    • Large standard errors for coefficients.
    • Individual predictors may appear non-significant despite the overall model being significant.
  • Detection:
    • Informal: Observe large changes in coefficients when adding/removing predictors; large standard errors.
    • Formal: Variance Inflation Factor (VIF); VIF > 10 is a common rule of thumb.
  • Solutions:
    • Remove one of the correlated predictors.
    • Combine correlated predictors into a single summary variable (e.g., using Principal Component Analysis).

Extreme multicollinearity means predictors are hard to distinguish, making their individual contributions unclear.

5.7 Checking assumptions

  • Methods are similar to simple linear regression:
    • Residual plots: Check for homoscedasticity (constant variance) and linearity.
    • QQ plots: Check for normality of residuals.
  • Generalized Additive Models (GAMs): Can assess linearity in MLR when predictors are limited.
  • Sensitivity analysis: Varying assumptions, models, or data to see if conclusions change significantly.

Violation of independence is common in hierarchical data (e.g., repeated measures, nested data), often requiring multilevel models.

🔑 Important: Multiple linear regression is a powerful tool that becomes highly versatile with the inclusion of categorical predictors, squared terms, and interaction terms.

6. Logistic regression for binary outcomes

6.1 Model for a binary outcome

  • Binary outcome: y∈{0,1}y\in\{0,1\}, where y=1y=1 means “event” (e.g., graduate).
  • Probability: model π=Pr⁡(Y=1∣x)\pi=\Pr(Y=1\mid x).
  • Bernoulli: YY is Bernoulli with E(Y)=πE(Y)=\pi when y∈{0,1}y\in\{0,1\}.
  • Why not linear regression: a straight line for π\pi can give values outside (0,1)(0,1).

🔑 Important: In logistic regression, we keep π\pi valid by modeling a transformed scale.

The logit link (linear in log-odds)

  • Logit: logit(π)=log⁡(π1−π)\text{logit}(\pi)=\log\left(\frac{\pi}{1-\pi}\right).
  • Inverse logit: π=11+exp⁡(−η)\pi=\frac{1}{1+\exp(-\eta)} with η=β0+β1x\eta=\beta_0+\beta_1 x.
  • Logistic model: Pr⁡(Y=1∣x)=11+exp⁡(−(β0+β1x))\Pr(Y=1\mid x)=\frac{1}{1+\exp\left(-(\beta_0+\beta_1 x)\right)}.

logit(π)=log⁡(π1−π)=β0+β1x\text{logit}(\pi)=\log\left(\frac{\pi}{1-\pi}\right)=\beta_0+\beta_1 x

π=11+exp⁡(−(β0+β1x))\pi=\frac{1}{1+\exp\left(-(\beta_0+\beta_1 x)\right)}

key link: β0+β1x\beta_0+\beta_1 x is linear, but π\pi stays in (0,1)(0,1).

6.2 Interpret coefficients with odds and odds ratios

  • Odds: for π=Pr⁡(Y=1)\pi=\Pr(Y=1), odds for Y=1Y=1 are π1−π\frac{\pi}{1-\pi}.
  • Log-odds: logit(π)=log⁡(odds)\text{logit}(\pi)=\log(\text{odds}).
  • Odds ratio: compares odds between two xx values.

Coefficient meaning in one predictor models

  • Slope β1\beta_1: a one-unit increase in xx changes log-odds by β1\beta_1.
  • Odds ratio form: exp⁡(β1)\exp(\beta_1) is the factor change in odds when x→x+1x\to x+1.
  • Intercept β0\beta_0: log-odds at x=0x=0, so odds at x=0x=0 are exp⁡(β0)\exp(\beta_0).

📝 Example: If β1=log⁡(3)\beta_1=\log(3), then exp⁡(β1)=3\exp(\beta_1)=3: odds triple per one-unit increase in xx.

Quick memory table: odds vs probabilities

ConceptKey fact
odds for Y=1Y=1π1−π\dfrac{\pi}{1-\pi}
log-oddslog⁡(odds)=logit(π)\log(\text{odds})=\text{logit}(\pi)
odds ratio for x→x+1x\to x+1exp⁡(β1)\exp(\beta_1)

🔑 Important: Odds-ratio effects are constant on the odds scale, but probability effects depend on the starting xx.

Why probability effects are not constant

  • Nonlinear mapping: π=inverse logit(η)\pi=\text{inverse logit}(\eta) makes probability changes vary with xx.
  • Exam takeaway: use odds ratios for “one unit” interpretation, not raw probability differences.

6.3 Estimate parameters and test hypotheses

Maximum likelihood estimation (MLE)

  • MLE: choose β\beta values that maximize the likelihood of the observed yy values.
  • No least squares: logistic regression does not use SSE-based fitting.
  • Computation: closed-form estimates are usually unavailable, so software uses iterative algorithms.

Wald confidence intervals for parameters

  • Wald CI: for one coefficient, use a normal approximation.
  • 95% CI idea: coefficient ±\pm (about 1.961.96)×\times its standard error.
  • Odds ratio CI: exponentiate the CI endpoints for β1\beta_1.

CIβ1=β^1±1.96⋅SE(β^1)\text{CI}_{\beta_1}=\hat{\beta}_1 \pm 1.96\cdot \text{SE}(\hat{\beta}_1)

key conversion: CI for odds ratio = [exp⁡(L),exp⁡(U)]\left[\exp(L),\exp(U)\right].

Wald test for a single coefficient

  • Hypotheses: test H0:β1=cH_0:\beta_1=c vs H1:β1≠cH_1:\beta_1\neq c.
  • Test statistic: use a z-statistic from β^1\hat{\beta}_1 and its SE.
  • p-value: compare to the standard normal distribution.

6.4 Use dummy predictors and multiple logistic regression

Logistic regression with a binary (dummy) predictor

  • Dummy coding: set xbin=1x_{\text{bin}}=1 for “yes” and 00 for “no”.
  • Coefficient meaning: β1\beta_1 compares log-odds between “yes” and “no”.
  • Odds ratio: in this case, exp⁡(β1)\exp(\beta_1) matches the odds ratio from the 2×22\times2 table.

Decision table: interpreting a binary predictor

StepQuestionAction/Answer
1Is the predictor 0/10/1?Treat it as “no vs yes”.
2What does β1\beta_1 do?It shifts log-odds for yes vs no.
3What is the effect size?exp⁡(β1)\exp(\beta_1) is the odds ratio.

🔑 Important: Always interpret odds ratios relative to how the dummy variable is coded.

Multiple predictors and adjusted odds ratios

  • Multiple logistic regression: includes predictors x1,…,xpx_1,\dots,x_p.
  • Context dependence: interpret one βj\beta_j while holding other predictors constant.
  • Adjusted odds ratio: exp⁡(βj)\exp(\beta_j) is the odds factor for xjx_j given the others.

key relationship: adjusted odds ratio comes from “change xjx_j by one unit, keep other xx fixed”.

Example anchors (from the academic-success data)

  • Gender effect after control: with admission grade and gender, females’ odds multiply by 3.2053.205 vs males.
  • Meaning of that number: it is an odds ratio, not a probability difference.
  • Uncertainty: use the reported 95% CI for the adjusted odds ratio.

Likelihood ratio test (LRT) for multiple coefficients

  • Nested models: compare a reduced and full model that differ by parameters.
  • Test statistic: G2=Dreduced−DfullG^2=D_{\text{reduced}}-D_{\text{full}} using (residual) deviance DD.
  • Null distribution: for large samples, G2≈χ2G^2\approx \chi^2 with df equal to parameter difference.
  • Wald vs LRT: they may differ for finite samples, but agree asymptotically.

G2=Dreduced−DfullG^2=D_{\text{reduced}}-D_{\text{full}}

🔑 Important: To test several coefficients at once, LRT uses deviance differences, not just one coefficient’s z-test.

🔑 Important: In logistic regression, the slope turns into an odds ratio via exp⁡(β)\exp(\beta), and adjusted interpretations come from holding other predictors fixed.

© 2026 Maeve. All rights reserved. This content is protected by copyright.

See also