knitr::opts_chunk$set(echo = TRUE) library(memoryROC)
Version: 1.2
License: GPL-2
URL: https://github.com/JAQuent/memoryROC
Contact: alexander.quent@rub.de
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.
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)
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.
responseScale <- 6:1 rates <- cumRates(responseScale, sampleData$confidenceRatings, sampleData$oldNew) rates
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.
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
This function combindes the functions cumRates and fitDPSD for easier 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
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))$$
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)
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.
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)
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.
dPrime(c(6,5,4), sampleData$confidenceRatings, sampleData$oldNew)
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.
responseBias(c(6,5,4), sampleData$confidenceRatings, sampleData$oldNew)
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.
recollection <- 0.4895505 familiarity <- 0.9709519 fittedRates <- returnFittedROC(recollection, familiarity) head(fittedRates)
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.