1 About
Linear models are a fundamental type of statistical model within the broader Generalised Linear Model (GLM) framework. While the GLM can accommodate various types of outcomes (like binary or count data), this cheatsheet focuses on the common case of linear models with continuous outcomes and predictors.
With a linear model, you can answer questions like:
- Is an adult penguin’s body mass related to its flipper length?
- How much does an exam score change for each extra hour of study, after accounting for sleep?
- Do temperature and rainfall together better explain plant growth than either variable on its own?
- Can we predict a future outcome (e.g., plant height) based on a predictor (e.g., temperature)?
Assumed knowledge
- Jamovi is installed and ready to use. This cheatsheet uses Jamovi 2.7.4.0.
- A basic understanding of statistical concepts and terminology, such as the difference between categorical and continuous variables.
- A basic knowledge of how to create model formulae, e.g., y \sim x.
2 Data
We will use the well-known penguins dataset from the palmerpenguins R package. The dataset has been exported from the package in a format that Jamovi can read (.csv).
3 Install the GAMLj module
To fit linear models in Jamovi we will use the GAMLj module, which gives a simple, formula-based interface for modelling.
- Open Jamovi and go to the Analyses tab.
- Click Modules, then select jamovi library.
- Search for “GAMLj3” and select it.
- Click INSTALL and wait for the installation to finish.
- Exit by clicking on the upper-right arrow button.
4 Import data
- Click the hamburger menu at the top-left of the Jamovi window.
- Select Open to open the file dialogue.
- In the dialogue, navigate to the folder where you saved
penguins.csvand click Open.
5 Constructing linear models
You should first think about what your research question is and which variables you want to include in your model. Then, construct the model using the formula syntax. For example:
\mathrm{body\_mass} \sim \mathrm{flipper\_length}
indicates a model where body mass is predicted by flipper length, and both are continuous variables. Where multiple variables are included, the syntax expands to:
\mathrm{body\_mass} \sim \mathrm{flipper\_length} + \mathrm{bill\_depth}
where we are specifying that body mass is predicted by flipper length and bill depth, all of which are continuous variables, and all of which are additive. Finally, it might be important to specify that the predictors are not additive, for example by including an interaction term:
\mathrm{body\_mass} \sim \mathrm{flipper\_length} \times \mathrm{bill\_depth}
6 Fitting the model
- In the Analyses tab, click on the Linear Models button and select General Linear Model.
- Drag the variables you want to include in your model into the appropriate boxes in the GAMLj interface. For example, you might drag
body_massinto the Dependent Variable box andflipper_lengthandbill_depthinto the Covariates box. - Leave the Factors box empty as it is used for categorical variables (which we do not cover in this cheatsheet).
- If you want to include additional predictors, drag those (continuous) variables into the Covariates box.
- If you are interested in model interactions, go to the Model tab, select the variables you want to interact in the Components box, and drag them into the Model Terms box.
Note that interaction terms are available only when two or more predictors are included in the model.
7 Export
To export data, right click on an object in the right pane (e.g. a table), copy the object and paste in your word processor of choice (e.g. MS Word).
Attribution
This cheatsheet was developed using resources that are available under a Creative Commons Attribution 4.0 International license and made available on the SOLES Open Educational Resources repository.