Basic code structure for Linear models
Linear models with numeric dependent variable and no clustering variable
| Linear model used | Relevant chapters | Code |
---|---|---|---|
Comparing two means from two independent samples | Linear model with
| Chapter 6 |
|
Comparing more than two means from independent samples | Linear model with
| Chapter 6 | If x is a factor variable
If x is stored as a numeric variable
|
Testing the interaction effect of two categorical variables on a numeric dependent variable | Linear model with
| Chapter 9 | If x and z are factor variables
|
Testing the interaction effect of two numeric variables on a numeric dependent variable | Linear model with
| Chapter 9 | If x and z are numeric variables
|
Testing the interaction effect of one independent numeric variable and one numeric dependent variable | Linear model with
| Chapter 9 |
|
Regression | Linear model with
| Chapter 4 and 6.5 |
|
MODELS WITH A NUMERIC DEPENDENT VARIABLE AND A CLUSTERING VARIABLE (DUE TO REPEATED MEASUREMENTS)
New approach | Relevant chapters | Code | |
---|---|---|---|
Comparing two means from two related samples | Linear mixed model with
| Chapter 12 |
|
Comparing more than two means from related samples | Linear mixed model with
| Chapter 13 |
|
MODEL WITH A DUMMY OR A COUNT DEPENDENT VARIABLE
New approach | Relevant chapters | Code | |
---|---|---|---|
Logistic regression | Generalized linear model with
| Chapter 15 |
|
Testing the independence of two categorical variables | Generalized linear model with
| Chapter 16 |
|
Manuals & Websites
Please keep in mind that when working with R it is normal to search for the specific codes needed.
The UT provides a manual with different R codes for several types of analyses. It is mainly aimed at codes used in the statistics courses of several Bachelor programmes but can be a good starting point.
If you need information on how to analyse data using linear models you can have a look at this book.
If you have questions regarding Bayesian statistics please have a look at this book. It also provides information on how to set up R and how to install libraries from cran but also other sources.