# Psychometrics in Exercises using R and RStudio

*Textbook and data resource*

*2024-01-26*

# Preface

This textbook provides a comprehensive set of exercises for practicing all major Psychometric techniques using R and RStudio. The exercises are based on real data from research studies and operational assessments, and provide step-by-step guides that an instructor can use to teach students, or readers can use to learn independently. Each exercise includes a worked example illustrating data analysis steps and teaching how to interpret results and make analysis decisions, and self-test questions that readers can attempt to check own understanding.

You can read this book online here for free. Copies in printable format may be ordered from the author.

Data and supporting materials for all exercises are available for download from http://annabrown.name/psychometricsR

**How to cite this book**:

Brown, Anna. (2023). Psychometrics in Exercises using R and RStudio. Textbook and data resource. Available from https://bookdown.org/annabrown/psychometricsR.

## Why I wrote this book

This book is an outcome of my experience in teaching psychometrics and statistics in the past 13 years; first at the University of Cambridge in 2010-2012 under the ESRC Researcher Development initiative, and then at the University of Kent in 2012-2023 as part of my normal duties as the statistics lecturer.

This book was born from computing workshop exercises that I created for my students over the years to practice psychometric techniques that they learnt in lectures. When preparing exercises for them, it quickly became apparent that while there are many good textbooks about psychometric theory (my absolute favourite is “Test Theory: A Unified Treatment” by the late Roderick McDonald), there aren’t any comprehensive sources of practical exercises that students can use to internalise and practice these techniques. Various tutorials have good illustrations with data, but they do not provide step-by-step guides that an instructor can use to teach students to interpret results and make analysis decisions, and they do not provide self-test questions that students can answer to test own understanding.

This book is intended to fill this gap.

## What is this book for?

This book can be used **for teaching** by university lecturers and instructors. They may use data examples and analyses provided in this book as illustrations in lectures (acknowledging the source), or simply adopt the book for the practical/computing part of their course. Some of these exercises will be useful as part of the general statistics curriculum, and some will be more suitable for special courses such as “Item Response Theory” or “Structural Equation Modelling” or “Measurement Invariance”.

This book can be used for **self-study** by anybody who want to acquire practical skills in conducting psychometric analyses. These may be students and researchers in the fields of psychology, or any behavioural or social science, of any age and level – undergraduate and postgraduate, PhD and postdoctoral researchers, and seasoned researchers who want to acquire new skills in psychometrics. These may also be practitioners in various fields of assessment who need to be able to make sense of their data or create new assessments.

This book can also be used **for self-study** by people with some experience in Psychometrics, but wanting to learn how to do these analyses in R, perhaps moving from another software program like SPSS.

## How to use this book

If you are **an instructor**, you can use this book as you see fit for your course and your students, perhaps prioritising their needs in either software or statistical curriculum depending on their level as described below.

If you are **a student** using the book for self-study, the way you will use this book will depend on where you begin in psychometrics (and in R/RStudio!).

Beginners in R/RStudio should start from the beginning (including the “Getting started with R and RStudio” section), gradually building skills in data manipulations using R. You will establish your own routine when working with exercises (consider each one as a mini data analysis project), and soon will feel confident to build a portfolio of packages and functions. Intermediate or advanced Psychometricians who only begin in R/RStudio will find the learning process easier, because you will be applying familiar methods in a new software environment. You may even compare outputs from R with other software you used before. You may be pleasantly surprised!

Beginners in Psychometrics should also start from the beginning, gradually building their skills in conducting analyses using specific techniques and methods, for instance computing a test score in the presence of missing data. The exercises are ordered so that later exercises often (but not always!) rely on previous ones. References to previous exercises that are necessary to understand the current exercise is always given, so you can refresh your knowledge if necessary. Intermediate or advanced users of R/RStudio but beginners in Psychometrics can skip my advice on R tips and tricks, but should follow the order of exercises to build their psychometric skills.

## How this book is organised

The book is organised into 24 exercises, each showcasing unique psychometric techniques. Although exercises are self-contained, some will refer to related techniques described in previous exercises, so it is recommended to approach the exercises in order, particularly if you are new to Psychometrics. The exercises are grouped into 10 parts:

**Part I. Introduction to psychometric scaling methods**

This part contains 4 exercises, which teach techniques for scaling ordinal questionnaire data, nominal questionnaire data, and ranked preferences data.

**Part II. Classical Test Theory and Reliability Theory**

This part contains 2 exercises, teaching how to conduct item analysis and reliability analysis of polytomous questionnaire data and dichotomous questionnaire data.

**Part III. Test homogeneity and Single-Factor Model**

This part contains 2 exercises, teaching how to fitting a single-factor model to polytomous item scores and to dichotomous item scores.

**Part IV. Exploratory Factor Analysis (EFA)**

This part contains 3 exercises, teaching how to conduct EFA of polytomous item scores, and of correlation matrices of subtest scores or multidimensional test scores.

**Part V. Item Response Theory (IRT) analysis**

This part contains 2 exercises, teaching how to fit 1PL and 2PL models to dichotomous questionnaire data, and a graded response model to polytomous questionnaire data.

**Part VI. Differential Item Functioning (DIF) analysis**

This part contains 2 exercises, teaching how to test for DIF dichotomous questionnaire data using binary logistic regression, and polytomous questionnaire data using ordinal logistic regression.

**Part VII. Confirmatory Factor Analysis (CFA)**

This part contains 2 exercises, teaching how to fit CFA models to polytomous item scores, and to a correlation matrix of subtest scores.

**Part VIII. Path analysis**

This part contains 2 exercises, teaching how to fit a path model to observed test scores, and an autoregressive model to longitudinal test measurements.

**Part IX. Structural equation modelling**

This part contains 3 exercises, teaching how to fit a latent autoregressive model and a growth curve model to longitudinal test measurements, and how to test for longitudinal measurement invariance in repeated test measurements.

**Part X. Multiple-group structural equation modelling**

This part contains 2 exercises, teaching how to test for measurement invariance across groups, and how to test for measurement invariance across time and experimental groups using multiple-group analysis settings.

## How to work with exercises in this book

Each exercise will begin with objectives and a summary of techniques that will be taught. Then, it will name a data set to be analysed, and any R packages needed to conduct these analyses, for example:

Data file | Example.csv |

R package | psych |

Data sets (and accompanying materials such as questionnaire items) are provided on the **dedicated website**, http://annabrown.name/psychometricsR, or occasionally data will be part of R packages used for analyses. Packages will need to be installed on your computer from R repositories.

The exercises will comprise several steps, each describing a specific activity or technique, including how to import/load and save the data, how to examine the data, and how to run specified analyses.

The main body of each exercise presents a **“Worked Example”**, where I showcase a technique, taking a student through analyses step by step. The student needs to reproduce my analyses and outputs by following descriptions in the Worked Example. Moreover, I will encourage students to learn how to apply the presented techniques to new variables, make sense of outputs and interpret results by presenting them with **self-test questions**. Answering these questions is an important part of learning. Students should attempt to answer the question independently, and then verify their answers with the answers provided at the end of each Exercise.