knitr::opts_chunk$set(echo = TRUE)
library(memoryROC)

General information

Version: 1.2

License: GPL-2

URL: https://github.com/JAQuent/memoryROC

Contact: alexander.quent@rub.de

Introduction

This package was written to analyse recognition memory performance and estimate the Dual Process Signal Detection (DPSD) parameters within R. Additional functions might be added, once I need them. This manual is supposed to provide a short description and explanation how to use the functions. If you have corrections and/or questions, feel free to contact me.

Data

The sample data is taken from a pilot recognition experiment using the remember/know procedure. In this experiment, this subject was asked to rate the recognition confidence from 1 (sure new) to 5 (sure old) or recollected (= 6). The data frame is sampleData contains the variables confidenceRatings, which contains confidence ratings, and oldNew, which contains information whether a stimuli had been studied (i.e. old, = 1) or had not been studied (i.e. new, = 0).

load("data/sampleData.RData")
head(sampleData)

Functions

cumRates

This function allows you to extract cumulative hit and false alarm rates for further memory ROC analysis. In the example above, the false alarm rate is given by the probability that a stimulus was rated as 6 (i.e. sure the stimulus was old/remember) under the condition that it was new/not-studied. The first value of the hit rate is given by the probability that a stimulus was rated as 6 (i.e. sure the stimulus was old/remember) under the condition that the stimulus was indeed old. The next two values are obtained by calculating the probability that a stimulus was rated with 6 or 5 under the condition that the stimulus was new for the false-alarm rate and under the condition that the stimulus was old for the hit rate. This is repeated for all confidence levels.

Example usage

responseScale <- 6:1
rates <- cumRates(responseScale, sampleData$confidenceRatings, sampleData$oldNew)
rates

fitDPSD

This function allows to estimate recollection and familiarity by fitting data to the DPSD model. The optimization is attempted by minimizing the total squared difference between observed and predicted hit and false alarm rates. The Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm from the function optim {stats}. The function first uses standard start values and then random values in order to find the set of parameters, which fit the data best by returning the values with the lowest total squared difference. A high number of iterations is necessary to get stable estimates.

Example usage

fitDPSD(rates$falseAlarm, rates$hit)
## Number of iterations: 200
## Number of failed runs: 0
## Minimum: 6e-04
## Maximum: 2.5042
## SD: 0.3222
## Mean: 0.1356
## Median: 0.0015

## $recollection
## [1] 0.4895525
## 
## $familiarity
## [1] 0.9709275

DPSD

This function combindes the functions cumRates and fitDPSD for easier usage.

Example usage

responseScale <- 6:1
DPSD(responseScale, sampleData$confidenceRatings, sampleData$oldNew)
## Number of iterations: 200
## Number of failed runs: 0
## Minimum: 6e-04
## Maximum: 2.0325
## SD: 0.3679
## Mean: 0.1498
## Median: 0.0015

## $recollection
## [1] 0.4895525
## 
## $familiarity
## [1] 0.9709275

rememberKnow

This function allows to estimate recollection and familiarity using Remember/Know procedure. In this procedure, recollection is given by the probability that an old/studied item were given a remember response, while familiarity is given by the probability that an old/studied item were given a know response divided by the probability that an old/studied item were not given a remember response.

$$recollection = P(remember)$$

$$familiarity = P(know)/(1 -P(remember))$$

Example usage

In the variable confidenceRatings the number 6 represents remember responses, while 5 & 4 represent know responses.

rememberLevels <- 6
knowLevels     <- c(5, 4)
rememberKnow(rememberLevels, knowLevels,  sampleData$confidenceRatings,  sampleData$oldNew)

rocAUC

This function calculates the AUC by summing the tri- and rectangles, which can be made of the ROC points. If missing, the y-intercept is added by linear interpolation. The last point, where both false Alarm rates reach 1, is also added.

Example usage

In the variable confidenceRatings the number 6 represents remember responses, while 5 & 4 represent know responses.

rememberLevels <- 6
rates          <- cumRates(responseScale, sampleData$confidenceRatings, sampleData$oldNew)
rocAUC(rates$falseAlarm, rates$hit)

dPrime

This function calculates the dimensionless statistic d-prime (d'). To do this, the percentage values are converted to z-values with the help of inverse cumulative distribution function (CDF) of the Gaussian distribution with a mean of 0 and a standard deviation of 1. Or as a equation:

$$d' = z(hit\ rate) - z(false\ alarm\ rate)$$ where $z(p), p \in [0,1]$ is the inverse Gaussian CDF.

Example usage

dPrime(c(6,5,4), sampleData$confidenceRatings, sampleData$oldNew)

responseBias

This function calculates the response bias (c):

$$c = -0.5 * (z(hit\ rate) + z(false\ alarm\ rate))$$ where $z(p), p \in [0,1]$ is the inverse Gaussian CDF.

Example usage

responseBias(c(6,5,4), sampleData$confidenceRatings, sampleData$oldNew)

returnFittedROC

This function allows you to get the corresponding false alarm and hit rates for a given set of recollection and familiarity assuming that the variance of the old item distribution is 1. This is helpful to compare raw hit and false alarm rates with fitted ones.

Example usage

recollection <- 0.4895505
familiarity  <- 0.9709519
fittedRates <- returnFittedROC(recollection, familiarity)
head(fittedRates)

License

memoryROC A package to analyse recognition memory data within R.

Copyright (C) 2025 Joern Alexander Quent

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.



JAQuent/memoryROC documentation built on June 9, 2025, 1:43 a.m.