Statistical Modelling Practicals

Introduction

StatsModels is an R package of learnr tutorials comprising two practicals on statistical modelling made for BUY22S01 Statistics and Computation at Trinity College Dublin. The package is distributed via GitHub. Each practical is for a 3 hour slot with an estimated completion time of 2.5 hours.

The aim of the practicals is to introduce statistical modelling. It uses functional responses (i.e. Type II models, Holling’s disc equation) as background information.

There are two parts to the practical:

  1. Introduction to statistical modelling
    • Constructing a Type II functional response
    • Designing an experiment
    • Collecting data
  2. Data analysis using statistical models in R
    • Importing data
    • Manipulating data
    • Conducting multiple linear regression (additive)
    • Visualising data

Part 1 requires students collect data by replicating Holling’s disc experiment with two predictor variables: prey density and jar type (lid/ no lid). This practical focuses on Type II models. Part 2 analyses the data using additive multiple linear regression. Simple linear regressions (with one predictor variable) or multiplicative regression are not covered because of time constraints.

Remote version

It is possible to adapt this in-person practical to a remote version by getting students to collect data using a Scratch simulation of a Type II functional response. I have a Scratch model of one.


Set up

We need to set up our computer to download the practical in R.

Follow this checklist in order to make sure you are set up:

  1. Have you installed R version 4.0 or above? - if not, install/update R
    • You can check your R package version using R.Version()$version.string
  2. Have you installed RStudio version 1.0.136 or above? - if not install/update RStudio
    • You can check your RStudio version using RStudio.Version()$version
  3. Have you installed the following packages? - if not use install.packages("<name of package>") to do so
    • learnr - needed to run the tutorials
    • remotes - needed to install the tutorials

If everything works then you should see a Tutorials tab in one of your RStudio windows. There may already be tutorials listed there.


Installing the tutorials

Now we need to install the tutorial. The tutorials are stored in a Package available on GitHub. You will only have to install the package once at the beginning.
Use the following code:

remotes::install_github("jacintak/biostats", dependencies = TRUE, build_vignettes = TRUE)

If you are asked to install any other packages, choose yes.
If you are asked to update any packages, press 1 for updating all of them.
If you are asked to install packages from source (i.e. in a pop-up window), press no.
If the package installed properly, you should automatically see the tutorials in the Tutorial tab.


Running a tutorial

You should be able to run a tutorial from the Tutorial tab when you open RStudio without needing to do anything.
Make sure it’s a tutorial from the StatsModels package.

If you click run tutorial, the tutorial will show up in the tab. You can click the “Show in new window” icon to open it in another window. Press the “Home” icon to return to the Tutorials tab.

If that doesn’t work use this code and the tutorial will open in another window or your browser:

learnr::run_tutorial("<insert name of the tutorial to run>", package = "StatsModels")

Quit a tutorial by pressing the “Stop” icon.

Avatar
Jacinta Kong
Postdoctoral Fellow

My research interests include species distributions, phenology & climate adaptation of ectotherms.

Next
Previous

Related