konstats is the companion package of my courses Statistics and Advanced Statistics at the Department of Linguistics, University of Konstanz. It is written for their students and is not meant for general use; the data sets of the courses are in simling, which anyone can use.
Installation
konstats is not on CRAN. Install it from R-universe:
install.packages("konstats", repos = c("https://mcanzi.r-universe.dev", "https://cloud.r-project.org"))This also installs every package the Statistics course uses, simling included. For Advanced Statistics, install its extra packages once:
konstats::install_course("advanced")Before the first session, check that your computer is ready:
library(konstats)
check_setup("statistics")
check_setup("advanced")Usage
Lectures and slides
lectures() lists the lectures of both courses, with their textbook chapters and data sets. slides() opens the slides of one, by number or by part of its topic:
Exercise sheets
Each tutorial has an exercise sheet with the exercises and an empty code chunk for each answer. Some sheets end with a weekly assignment, which you complete at home. In Advanced Statistics, the practical lectures 4, 6, 9 and 11 have a sheet each. The Statistics sheets are R Markdown files (.Rmd), the Advanced Statistics sheets Quarto documents (.qmd); RStudio opens and renders both. get_tutorial() copies a sheet into your project folder, or all of them at once:
tutorials()
get_tutorial(4, ".")
get_tutorial("all", ".")
get_tutorial(4, ".", course = "advanced")You write your answers in the copy, and a sheet that is already in the folder is never overwritten unless you ask.
Weekly assignments
In RStudio, File > New File > R Markdown > From Template > Weekly assignment (konstats) starts the file you hand in for a weekly assignment, with a section per exercise.
Helpers from the slides
The functions written in the Advanced Statistics slides are in the package too:
| Function | What it does | Session |
|---|---|---|
resid_acf() |
Autocorrelation of model residuals within trajectories | 3, 4 |
partial_dependence() |
Mean prediction of a model as one predictor changes (partial() in the slides) |
5, 6 |
cv_speakers() |
Accuracy of a random forest on speakers it has not seen | 6 |
theme_paper() |
A plain ggplot2 theme for papers and theses | 11 |
The packages of each course
course_packages() lists them, with what each is used for in the course:
course_packages("advanced")License
Code: MIT © Massimiliano Canzi. The exercise sheets in inst/sheets are course materials, © Massimiliano Canzi, licensed under CC BY 4.0.
