Biostatistics Assignment 5: Hypothesis Testing, Paired Analysis, and Diagnostic Methods

Administrative Overview and Submission Details

  • Course: Biostatistics (Biostatistik)

  • Term: Winter Semester 2026/272026/27

  • Assignment Sheet: Sheet 55 (Blatt 55)

  • Submission Deadline: November 1616, 20262026, at 10:1510:15

  • Total Point Value: 3232 points across four exercises (88 points per exercise)

Exercise 1: Analysis of Sleep Duration Across Age Groups

  • Total points allocated: 88 points

  • Core objective: Investigate whether there is a statistically significant difference in mean sleep duration between younger students and older students using an empirical survey dataset (umfrage).

  • Age cohort definitions:

    • Younger students: Age ≤23\le 23 years

    • Older students: Age >23> 23 years

  • Part a) Data Import, Classification, and Exploratory Visualization (22 points):

    • Import the survey dataset and assign it to an R variable named umfrage.

    • Generate a categorical binary variable named Altersgruppe within the umfrage data frame using conditional evaluation:

    • Code implementation: umfrageAltersgruppe<−ifelse(umfrageAltersgruppe <- ifelse(umfrageAlter<=23,"jung","alt")

    • Operational behavior: The ifelse() function checks the logical condition umfrage$Alter <= 23. For rows evaluating to TRUE, it assigns the label "jung"; for rows evaluating to FALSE (ages strictly greater than 2323), it assigns the label "alt".

    • Consult the official R documentation via ?ifelse to examine the parameter requirements and vectorization properties of conditional element selection.

    • Construct a clean, fully labeled boxplot with notches:

    • Dependent variable: Sleep duration (Schlafdauer)

    • Grouping factor: Age group (Altersgruppe)

    • Requirement: Visual comparison via notches (notch = TRUE in R) to provide an approximate 95%95\% confidence interval around the medians.

    • Labeling criteria: Explicit title, defined axis labels with proper units, and legible category names.

    • Formulate an initial hypothesis/conjecture based on the visual inspection of the boxplot regarding sleep duration patterns in younger versus older students.

  • Part b) Hypothesis Testing and Group Comparisons (66 points):

    • Data subsetting:

    • Construct two independent subset data frames containing exclusively the younger cohort ("jung") and the older cohort ("alt"), respectively.

    • Normality assessment:

    • Test the sleep duration distribution within each independent group for normal distribution using the Shapiro-Wilk test (shapiro.test()).

    • Statistical test selection:

    • If both subsets meet the assumption of normality, apply a two-sample t-test (evaluating variance homogeneity or using Welch's t-test via t.test()).

    • If the normality assumption is violated in either group, apply the non-parametric Wilcoxon-Mann-Whitney rank-sum test (wilcox.test()).

    • Reporting requirements:

    • State the complete test statistics cleanly (test name, degrees of freedom if applicable, test statistic value, and exact pp-value).

    • Provide explicit mean values for both the younger and older student groups.

Exercise 2: Association Between Caraway Preference and Body Height

  • Total points allocated: 88 points

  • Core objective: Evaluate whether self-reported preference for caraway (Kümmel) is associated with a statistically significant difference in body height (Körpergröße).

  • Part a) Cohort Subsetting and Notched Boxplot Generation (22 points):

    • Load the complete survey dataset into the working environment.

    • Filter the dataset to retain only data from the student's specific matriculation cohort/year (eigener Jahrgang).

    • Construct a notched boxplot displaying body height as a function of caraway preference:

    • Incorporate complete and detailed labeling (plot title, axis descriptions, measurement units).

    • Note: Incomplete or missing plot labels result directly in point deductions.

    • Provide a clear written conjecture stating whether an empirical relationship or difference between caraway liking and height appears to exist based on the graphical representation.

  • Part b) Subset Creation and Inferential Statistical Testing (66 points):

    • Generate two distinct subsets derived from the cohort-filtered dataset:

    • Subset 11: Students who like caraway.

    • Subset 22: Students who do not like caraway.

    • Normality testing:

    • Conduct the Shapiro-Wilk test (shapiro.test()) separately on body height for both groups to assess the normality assumption.

    • Statistical test execution:

    • Determine and perform the correct parametric or non-parametric test depending on the outcome of the normality assessment.

    • Comprehensive reporting:

    • Report the complete statistical test outcome, including test name, test statistic, and pp-value.

    • Report the arithmetic group means for both the caraway-liking and caraway-disliking cohorts.

Exercise 3: Effect of an Eight-Week Endurance Training on Resting Heart Rate

  • Total points allocated: 88 points

  • Study design and parameters:

    • Sample size: n=120n = 120 students

    • Intervention: Eight-week endurance training program (achtwöchiges Ausdauertraining)

    • Outcome metric: Resting heart rate (Ruheherzfrequenz) measured in beats per minute (Schla¨ge/min\text{Schläge/min})

    • Observation timing: Pre-intervention baseline ("vor") versus post-intervention completion ("nach")

    • Data source file: 05_Herzfrequenz.txt

  • Part a) Inferential Analysis of Resting Heart Rate Reduction (66 points):

    • Experimental design identification:

    • Identify whether the dataset consists of independent samples or paired/dependent data (gepaarte Daten).

    • Because measurements are taken from the exact same 120120 individuals before and after the eight-week intervention, the observations are paired/dependent.

    • Assumption testing:

    • For paired data, assess the normality assumption on the intra-individual differences (Δ=before−after\Delta = \text{before} - \text{after} or Δ=after−before\Delta = \text{after} - \text{before}) rather than testing the marginal distributions independently.

    • Apply the Shapiro-Wilk test to these differences.

    • Statistical testing:

    • If differences are normally distributed, apply the paired Student's t-test: t.test(vor, nach, paired = TRUE).

    • If the normality assumption is violated, perform the non-parametric Wilcoxon signed-rank test: wilcox.test(vor, nach, paired = TRUE).

    • Reporting requirements:

    • Report the full statistical results (test statistic, degrees of freedom if parametric, and exact pp-value).

    • Specify whether the endurance training caused a statistically significant reduction in resting heart rate.

    • Quantify and describe the mean change (mittlere Veränderung) in resting heart rate across the sample.

  • Part b) Visual Comparison and Discrepancy Diagnostics (22 points):

    • Visualization:

    • Generate notched boxplots for resting heart rate measured before and after the endurance training program.

    • Visually compare the medians and notch overlaps of the two boxplot distributions.

    • Discrepancy assessment and diagnostic explanation:

    • Contrast the conclusion drawn from visually comparing two marginal boxplots with the statistical test result obtained in part a).

    • Explain why a discrepancy may arise: Side-by-side marginal boxplots treat the data as two independent cross-sectional distributions, masking inter-individual variance and completely ignoring the paired nature of repeated measurements.

    • Identify the lost information: Two independent boxplots discard subject-specific linkage, meaning individual trajectories (the magnitude and consistency of within-subject decreases) cannot be observed, even when nearly every individual shows a systematic reduction in heart rate.

Exercise 4: Comprehensive Reference Guide to Statistical Tests and Diagnostic Methods

  • Total points allocated: 88 points

  • Core objective: Construct a structured reference table summarizing all eight statistical tests and diagnostic assessment tools introduced in the biostatistics course to date (including the Quantile-Quantile plot).

  • Required table fields:

    • Test Name (Testname)

    • Description (Beschreibung): Target hypothesis or distribution feature evaluated

    • Prerequisite / Assumption (Voraussetzung): Statistical conditions required for test validity

    • R Command (R-Befehl): Correct syntax and function name in R

  • Illustrative template model (fictional reference example provided):

    • Test Name: pi-kappa-Test

    • Description: Tests whether the distributions of two samples have the same median (Testet, ob die Verteilungen zweier Stichproben den gleichen Median haben)

    • Prerequisite: Data follow a Poisson distribution (Daten sind Poisson-verteilt)

    • R Command: pika(daten1, daten2, var.equal = T/F)

  • Systematic Overview of the Eight Statistical Tests and Diagnostic Tools:

  • 1. Shapiro-Wilk Test (Shapiro-Wilk-Test):

    • Description: Tests whether a continuous univariate sample originates from a normally distributed population (H0:X∼N(μ,σ2)H_0: X \sim N(\mu, \sigma^2)).

    • Prerequisites: Continuous numerical data; sample size typically between n=3n = 3 and n=5000n = 5000 independent observations.

    • R Command: shapiro.test(x)

  • 2. Quantile-Quantile Plot (QQ-Plot / Normal Probability Plot):

    • Description: Graphical diagnostic tool comparing sample empirical quantiles against theoretical quantiles of a standard normal distribution to assess normality.

    • Prerequisites: Continuous quantitative data with independent observations.

    • R Command: qqnorm(x); qqline(x)

  • 3. F-Test of Equality of Two Variances (F-Test / Two-Sample Fisher's Variance Test):

    • Description: Tests the null hypothesis that two independent population distributions possess equal variances (H0:σ12=σ22H_0: \sigma_1^2 = \sigma_2^2).

    • Prerequisites: Two mutually independent samples drawn from normally distributed populations.

    • R Command: var.test(x, y)

  • 4. One-Sample Student's t-Test (Einstichproben-t-Test):

    • Description: Tests whether the population mean μ\mu of a single sample differs significantly from a specified theoretical reference value μ0\mu_0 (H0:μ=μ0H_0: \mu = \mu_0).

    • Prerequisites: Continuous metric data, independent observations, and a normally distributed sample (or adequately large sample size via Central Limit Theorem, typically n≥30n \ge 30).

    • R Command: t.test(x, mu = mu_0)

  • 5. Two-Sample Independent Student's / Welch's t-Test (Zweistichproben-t-Test):

    • Description: Tests whether the population means of two mutually independent samples differ significantly (H0:μ1=μ2H_0: \mu_1 = \mu_2).

    • Prerequisites: Metric continuous scale; independent samples; normal distribution within both groups. If variances are equal, use standard Student's t-test (var.equal = TRUE); if variances are unequal, use Welch's t-test (var.equal = FALSE).

    • R Command: t.test(x, y, var.equal = TRUE) (Student's t-test) or t.test(x, y, var.equal = FALSE) (Welch's t-test, default in R)

  • 6. Paired Student's t-Test (Gepaarter t-Test):

    • Description: Tests whether the mean of intra-individual differences between paired repeated measurements equals zero (H0:μd=0H_0: \mu_d = 0).

    • Prerequisites: Continuous metric scale; dependent/paired sample structure; normal distribution of the pairwise differences (di=xi−yid_i = x_i - y_i).

    • R Command: t.test(x, y, paired = TRUE)

  • 7. Wilcoxon-Mann-Whitney Rank-Sum Test / Mann-Whitney U Test (Wilcoxon-Rangsummentest / U-Test):

    • Description: Non-parametric alternative to the independent two-sample t-test evaluating whether the distributions of two independent groups differ in location/rank sums (stochastic dominance or difference in medians under equal shape assumptions).

    • Prerequisites: At least ordinal scale; two independent samples; does not assume a normal distribution.

    • R Command: wilcox.test(x, y)

  • 8. Wilcoxon Signed-Rank Test (Wilcoxon-Vorzeichen-Rang-Test):

    • Description: Non-parametric counterpart to the paired t-test testing whether the distribution of differences between paired observations is symmetrically centered around zero.

    • Prerequisites: Dependent/paired observations; at least ordinal or interval scale of the differences; continuous symmetric distribution of pairwise differences; no requirement of normality.

    • R Command: wilcox.test(x, y, paired = TRUE)