Data analysis beyond BIO144
Prof. Owen Petchey · University of Zurich
Data that meet their assumptions: regression, ANOVA, several explanatory variables, interactions.
Count data and binary data.
Grouped or repeated-measures data.
Many variables at once.
That's a lot. And there is much more to learn.
Not an exhaustive list. For each: what's the situation, what's the method, and where to start in R.
Observations close in time are usually similar: they are not independent, which breaks an assumption of most standard methods. Time series methods (e.g. ARIMA, seasonal decomposition, forecasting) handle this.
acf() forecast rEDMAt 0, each value is independent. Near 1, neighbouring values are very similar, so 100 values carry much less information than 100 independent ones.
Nearby points tend to be similar (spatial autocorrelation), so again observations are not independent. Methods include spatial regression, kriging and geostatistics.
Spatial CRAN Task ViewEstimate the parameters of a specific non-linear function, such as logistic growth, f(x) = L / (1 + e−k(x−x₀)), and assess how well it fits.
nls() (base R)The relationship changes at some point, e.g. before and after an intervention, or once a threshold is passed. Estimate where the break is, and the relationship on each side.
segmentedSmooth functions capture non-linear effects, while the model stays interpretable. They extend the GLMs you know. Rather elegant!
mgcvVariables can be explanatory and response at the same time. Model direct and indirect effects, even latent variables: build and test causal models.
sem lavaanDecision trees, random forests, support vector machines, neural networks… They make predictions or classify, can handle large datasets and complex relationships, but may sacrifice interpretability.
install.packages(c( "ranger", # random forests "xgboost", # gradient boosting "glmnet", # lasso/ridge/elastic net "kernlab", # support vector machines "kknn", # k-nearest neighbours "earth", # adaptive regression splines "nnet" # simple neural networks ))
Combine the effect sizes from different studies to draw broader conclusions, and assess how much they differ (heterogeneity). Another reason to report effect sizes (Principle 3).
metafor (and others)Time-to-event data: time until death, failure, germination, flowering… Some individuals haven't had the event by the end of the study (censoring). Kaplan–Meier curves, Cox proportional hazards models.
survival (and others)type: tumour DNA profile (1 aneuploid, 2 diploid) · time: weeks to death or end of study · delta: 0 alive, 1 dead
Rank-based tests, bootstrapping and permutation tests make fewer assumptions about the distribution of the data.
kruskal.test() (and other packages)Kruskal–Wallis is somewhat equivalent to a one-way ANOVA, on the ranks of the data.
But first: can you make a model that fits, e.g. a transformation, or a GLM with a suitable distribution (Principle 2)?
Power is the probability of detecting an effect if it is really there. It depends on the effect size, the variation, the number of observations and the significance level. Use it to work out the sample size you need, before you collect data.
pwrd = difference in means divided by the standard deviation. Normal approximation to a two-sample t-test.
Combine prior knowledge with the data, using Bayes' theorem: P(H | E) = P(E | H) P(H) / P(E). The result, the posterior, describes what we believe after seeing the data, with its uncertainty.
rstan R-INLA rjags · Book: Statistical Rethinking (McElreath)Repeated measures through time: mixed models and time series. Counts across space: GLMs and spatial methods.
GAMs extend GLMs. Mixed models can be GLMs (GLMMs).
Bayesian methods can be used for most of them.
And there are multiple books about each.
Including the sample size you need (power analysis). Then you collect the right data to answer your question. When something changes, explore the options and talk to experts.
We don't analyse data for its own sake, but to answer questions about the world. Let your questions guide what you learn next.
Principle 1 from Week 1: a focused question first, then plan sampling and analysis to answer it.
Curated lists of R packages, by topic:
TimeSeries Spatial MachineLearning MetaAnalysis Survival Bayesian Psychometrics (SEM) ExperimentalDesign EnvironmetricsRichard McElreath's book on multilevel Bayesian modelling, with free lecture videos.
Chapter 11.2 lists all twelve, with what each is for.
Statisticians, and colleagues who use the methods. Ask early.
A recruiter in quantitative finance and technology told me: after a science Masters or PhD, the most common first job was quantitative researcher, quantitative analyst or data scientist. The skills asked for:
We do all of these in my ecology group :)
Listening: Data Analytics in the Liberal Arts; How to Build Analytics Technical Skills (How to Get an Analytics Job podcast).
So do the books: Getting Started with R (Beckerman & Petchey 2012; 2nd ed. with Childs, 2017), Insights from Data with R (Petchey et al. 2021). Keep learning, and keep updating.
Ordinary multiple regression was once considered cutting edge: something only experts would fiddle with.
Paraphrasing Richard McElreath, Statistical Rethinking.
Today's specialist method (e.g. multilevel Bayesian modelling) may be tomorrow's standard tool.
Necessary, but not sufficient. Think of the UN Sustainable Development Goals: poverty, hunger, health, climate, life on land and in water.
And “we need more data before we act” is often no longer a good argument.
Post on the OLAT forum what you'd like to go over in the review.
Planning and implementing statistical analyses.
The only practical that week: the Thursday group comes on Friday.
10:00–12:00. Mandatory Probeprüfung before then.