Biostatistics Assignment 5: Hypothesis Testing, Paired Analysis, and Diagnostic Methods
Administrative Overview and Submission Details
Course: Biostatistics (Biostatistik)
Term: Winter Semester
Assignment Sheet: Sheet (Blatt )
Submission Deadline: November , , at
Total Point Value: points across four exercises ( points per exercise)
Exercise 1: Analysis of Sleep Duration Across Age Groups
Total points allocated: 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 years
Older students: Age years
Part a) Data Import, Classification, and Exploratory Visualization ( points):
Import the survey dataset and assign it to an R variable named
umfrage.Generate a categorical binary variable named
Altersgruppewithin theumfragedata frame using conditional evaluation:Code implementation:
umfrageAlter<=23,"jung","alt")Operational behavior: The
ifelse()function checks the logical conditionumfrage$Alter <= 23. For rows evaluating toTRUE, it assigns the label"jung"; for rows evaluating toFALSE(ages strictly greater than ), it assigns the label"alt".Consult the official R documentation via
?ifelseto 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 = TRUEin R) to provide an approximate 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 ( 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 -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: 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 ( 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 ( points):
Generate two distinct subsets derived from the cohort-filtered dataset:
Subset : Students who like caraway.
Subset : 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 -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: points
Study design and parameters:
Sample size: students
Intervention: Eight-week endurance training program (achtwöchiges Ausdauertraining)
Outcome metric: Resting heart rate (Ruheherzfrequenz) measured in beats per minute ()
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 ( 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 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 ( or ) 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 -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 ( 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: 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 evaluatedPrerequisite / Assumption (
Voraussetzung): Statistical conditions required for test validityR Command (
R-Befehl): Correct syntax and function name in R
Illustrative template model (fictional reference example provided):
Test Name:
pi-kappa-TestDescription: 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 ().
Prerequisites: Continuous numerical data; sample size typically between and 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 ().
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 of a single sample differs significantly from a specified theoretical reference value ().
Prerequisites: Continuous metric data, independent observations, and a normally distributed sample (or adequately large sample size via Central Limit Theorem, typically ).
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 ().
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) ort.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 ().
Prerequisites: Continuous metric scale; dependent/paired sample structure; normal distribution of the pairwise differences ().
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)