ME2 lab
Everything on the site to practice ME2 with nothing to install: the R playground, with the RStudio panes and each exercise data file already loaded, ME2’s own simulators and the ME1 ones that are useful again, in syllabus order.
sergio@learns:~/lab/me2$ ls --by-topic
Inference with Rthe R practicals
- webRRLike RStudio, in your browser
- Topic
- Tests, Bayes, regression and ANOVA with the data files
- Helps you see
- Running the topic scripts with «Open in the playground», with the exercise .csv or .rdata already loaded, and reading every t.test, lm, glm or aov output straight away.
$ Rscript grades.R - Bayes · RFrom prior to posteriorThree conjugate models (beta-binomial, gamma-Poisson and normal-normal): you move what you believe beforehand and the data, and see the posterior, its estimators, the credible interval and the predictive, with the R command for each
- Topic
- Bayesian inference
- Helps you see
- The prior, the data and the posterior in three conjugate models (beta-binomial, gamma-Poisson and normal-normal), with the credible interval, the predictive and the R command for each.
$ prior-posterior --prior "beta(3, 9)" --data "8 of 20" - R · lm()Regression and residualsAdd, move and remove points: the least-squares line, the residuals, R², the diagnostics and what an influential point does, with the summary(lm()) output live
- Topic
- Linear regression
- Helps you see
- The least-squares line with its residuals and R², the diagnostic plots and what an influential point does (leverage and Cook’s distance), with the summary(lm()) output live.
$ regression --data flats - MCMC · RMetropolis step by stepA Markov chain that draws a posterior with no closed form: it proposes a nearby value, compares two heights and accepts or repeats, with the trace, the acceptance rate and the effective size depending on the step size
- Topic
- Approximate Bayesian inference: Metropolis and MCMC
- Helps you see
- Why rejecting means repeating the value rather than skipping the iteration, which stretch of the trace is warm-up and how a step that is too short or too long shows in the acceptance rate and the effective size.
$ metropolis --step 0.25 --iter 1500
What helps from ME1review
- d · p · qProbability distributionsEleven distributions with R’s d, p and q functions: the area each call computes, the ≥ trick for discrete variables and the quantiles
- Topic
- The test distributions: normal, t, chi-squared and F
- Helps you see
- Where a p-value comes from: the area the statistic leaves in the tail of its distribution, with pt, pchisq and pf.
$ distribution --pbinom 3 --size 10 --prob 0.25 - x̄ ± z · σ/√nConfidence intervalsA hundred samples, a hundred intervals: how many catch μ with z, with t or for a proportion, and what happens when you change the level or n
- Topic
- Confidence intervals, the other side of tests
- Helps you see
- Why a two-sided 5 % test rejects exactly when the 95 % interval leaves out the hypothesised value.
$ interval --level 0.95 --n 25 - x̄ · σ/√nCentral limit theoremThousands of samples from a die, a bus wait or a loaded coin: their means form a bell N(μ, σ/√n)
- Topic
- The central limit theorem
- Helps you see
- Why the mean is treated as normal with large samples, in tests and in the normal approximation to the posterior.
$ clt --population die --n 30
