Skip to content

Commit 7d0aa78

Browse files
RauschRausch
authored andcommitted
Adding two new models
1 parent 6d53f11 commit 7d0aa78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+415
-1169
lines changed

.Rbuildignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ QuickTests.R
44
usefultools.R
55
^.*\.Rproj$
66
^\.Rproj\.user$
7-
LICENSE
87
README.rmd
98
README_files
109
paper.bib
@@ -17,3 +16,5 @@ StatConfR.pdf
1716
.github
1817
.Rd2pdf14268
1918
statConfR.Rcheck
19+
^dev$
20+
LICENSE

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: statConfR
22
Type: Package
33
Title: Models of Decision Confidence and Measures of Metacognition
4-
Version: 0.2.1
4+
Version: 0.2.2
55
Date: 2025-09-24
66
Authors@R: c(
77
person("Manuel", "Rausch", email = "[email protected]",

NAMESPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export(estimateMetaI)
44
export(fitConf)
55
export(fitConfModels)
66
export(fitMetaDprime)
7-
export(groupBMS)
87
export(plotConfModelFit)
98
export(simConf)
109
import(ggplot2)
@@ -20,6 +19,5 @@ importFrom(stats,optim)
2019
importFrom(stats,plnorm)
2120
importFrom(stats,pnorm)
2221
importFrom(stats,qnorm)
23-
importFrom(stats,rgamma)
2422
importFrom(stats,rmultinom)
2523
importFrom(utils,tail)

R/fitConf.R

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#' a factor with a warning),
2121
#' * \code{correct} (encoding whether the response was correct; should be 0 for incorrect responses and 1 for correct responses)
2222
#' @param model `character` of length 1. The generative model that should be
23-
#' fitted. Models implemented so far: 'WEV', 'SDT', 'GN', 'PDA', 'IG',
23+
#' fitted. Models implemented so far: 'WEV', 'SDT', 'GN', 'PDA', 'IG', 'RCE', 'CAS',
2424
#' 'ITGc', 'ITGcm', 'logN', and 'logWEV'.
2525
#' @param nInits `integer`. Number of starting values used for maximum likelihood optimization.
2626
#' Defaults to 5.
@@ -135,7 +135,7 @@
135135
#' amount of evidence available for the discrimination decision and can be smaller
136136
#' as well as greater than 1.
137137
#'
138-
#' ### \strong{Logistic noise model (logN)}
138+
#' ### \strong{Lognormal noise model (logN)}
139139
#' According to logN, the same sample
140140
#' of sensory evidence is used to generate response and confidence, i.e.,
141141
#' \eqn{y=x} just as in SDT (Shekhar & Rahnev, 2021). However, according to logN, the confidence criteria
@@ -154,7 +154,7 @@
154154
#' \overline{\theta}_{-1,L-1}, \overline{\theta}_{1,1}, ... \overline{\theta}_{1,L-1}},
155155
#' as free parameters.
156156
#'
157-
#' ### \strong{Logistic weighted evidence and visibility model (logWEV)}
157+
#' ### \strong{Lognormal weighted evidence and visibility model (logWEV)}
158158
#' logWEV is a combination of logN and WEV proposed by Shekhar and Rahnev (2023).
159159
#' Conceptually, logWEV assumes that the observer combines evidence about decision-relevant features
160160
#' of the stimulus with the strength of evidence about choice-irrelevant features (Rausch et al., 2018).
@@ -180,18 +180,19 @@
180180
#' The mean of \eqn{x_{-1}} is given by \eqn{(1 - S) \times 0.25 \times d}; the mean
181181
#' of \eqn{x_1} is given by \eqn{(1 + S) \times 0.25 \times d}. The sensory evidence
182182
#' used for the discrimination choice is \eqn{x = x_2 - x_1},
183-
#' which implies that the discrimination decision is equivalent to standard SDT.
183+
#' which implies that the process underlying the discrimination decision is equivalent to standard SDT.
184184
#' The confidence decision variable y is \eqn{y = - x_1} if the response R is -1 and \eqn{y = x_2} otherwise.
185185
#'
186186
#' ### \strong{CASANDRE (CAS)}
187187
#' Generation of the primary choice in the CASANDRE model follows standard SDT assumptions.
188188
#' For confidence, the CASANDRE model assumes an additional stage of processing based on the observer’s estimate of the
189189
#' perceived reliability of their choices (Boundy-Singer et al., 2023).
190-
#' The confidence variable \eqn(y) is equal to \eqn{x / \hat{sigma}}. \eqn{\hat{sigma}}
191-
#' represents a noisy internal estimate of the sensory noise.
192-
#' It is assumed that \eqn{\hat{sigma}} is sampled from a lognormal distribution with a mean fixed to 1
193-
#' and a free noise parameter sigma. Conceptually, sigma represents the uncertainty
194-
#' in an individual's estimate of their own sensory uncertainty.
190+
#' The confidence decision variable y is given by \eqn{y = \frac{x}{\hat{\sigma}}}.
191+
#' \eqn{\hat{\sigma}} represents a noisy internal estimate of the sensory noise.
192+
#' It is assumed that \eqn{\hat{\sigma}} is sampled from a lognormal distribution with a mean fixed to 1
193+
#' and a free noise parameter \eqn{\sigma}.
194+
#' Conceptually, \eqn{\sigma} represents the uncertainty in an individual's estimate of their own sensory uncertainty.
195+
#'
195196
#'
196197
#' @author Sebastian Hellmann, \email{[email protected]}\cr
197198
#' Manuel Rausch, \email{[email protected]}

R/fitConfModels.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#' the models given in the second argument are fitted to each subset of `data`
3131
#' determined by the different values of this column)
3232
#' @param models `character`. The different computational models that should be
33-
#' fitted. Models implemented so far: 'WEV', 'SDT', 'GN', 'PDA', 'IG', 'ITGc', 'RCE',
33+
#' fitted. Models implemented so far: 'WEV', 'SDT', 'GN', 'PDA', 'IG', 'ITGc', 'RCE', 'CAS',
3434
#' 'ITGcm', 'logN', and 'logWEV'. Alternatively, if `model="all"` (default),
3535
#' all implemented models will be fit.
3636
#' @param nInits `integer`. Number of initial values used for maximum likelihood optimization.
@@ -160,7 +160,7 @@
160160
#' amount of evidence available for the discrimination decision and can be smaller
161161
#' as well as greater than 1.
162162
#'
163-
#' ### \strong{Logistic noise model (logN)}
163+
#' ### \strong{Lognormal noise model (logN)}
164164
#' According to logN, the same sample
165165
#' of sensory evidence is used to generate response and confidence, i.e.,
166166
#' \eqn{y=x} just as in SDT (Shekhar & Rahnev, 2021). However, according to logN, the confidence criteria
@@ -179,7 +179,7 @@
179179
#' \overline{\theta}_{-1,L-1}, \overline{\theta}_{1,1}, ... \overline{\theta}_{1,L-1}},
180180
#' as free parameters.
181181
#'
182-
#' ### \strong{Logistic weighted evidence and visibility model (logWEV)}
182+
#' ### \strong{Lognormal weighted evidence and visibility model (logWEV)}
183183
#' logWEV is a combination of logN and WEV proposed by Shekhar and Rahnev (2023).
184184
#' Conceptually, logWEV assumes that the observer combines evidence about decision-relevant features
185185
#' of the stimulus with the strength of evidence about choice-irrelevant features (Rausch et al., 2018).
@@ -205,18 +205,18 @@
205205
#' The mean of \eqn{x_{-1}} is given by \eqn{(1 - S) \times 0.25 \times d}; the mean
206206
#' of \eqn{x_1} is given by \eqn{(1 + S) \times 0.25 \times d}. The sensory evidence
207207
#' used for the discrimination choice is \eqn{x = x_2 - x_1},
208-
#' which implies that the discrimination decision is equivalent to standard SDT.
208+
#' which implies that the process underlying the discrimination decision is equivalent to standard SDT.
209209
#' The confidence decision variable y is \eqn{y = - x_1} if the response R is -1 and \eqn{y = x_2} otherwise.
210210
#'
211211
#' ### \strong{CASANDRE (CAS)}
212212
#' Generation of the primary choice in the CASANDRE model follows standard SDT assumptions.
213213
#' For confidence, the CASANDRE model assumes an additional stage of processing based on the observer’s estimate of the
214214
#' perceived reliability of their choices (Boundy-Singer et al., 2023).
215-
#' The confidence variable \eqn(y) is equal to \eqn{x / \hat{sigma}}. \eqn{\hat{sigma}}
216-
#' represents a noisy internal estimate of the sensory noise.
217-
#' It is assumed that \eqn{\hat{sigma}} is sampled from a lognormal distribution with a mean fixed to 1
218-
#' and a free noise parameter sigma. Conceptually, sigma represents the uncertainty
219-
#' in an individual's estimate of their own sensory uncertainty.
215+
#' The confidence decision variable y is given by \eqn{y = \frac{x}{\hat{\sigma}}}.
216+
#' \eqn{\hat{\sigma}} represents a noisy internal estimate of the sensory noise.
217+
#' It is assumed that \eqn{\hat{\sigma}} is sampled from a lognormal distribution with a mean fixed to 1
218+
#' and a free noise parameter \eqn{\sigma}.
219+
#' Conceptually, \eqn{\sigma} represents the uncertainty in an individual's estimate of their own sensory uncertainty.
220220
#'
221221
#' @author
222222
#' Sebastian Hellmann, \email{[email protected]}\cr

R/int_fitRCE.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ ll_RCE <-
106106
p <- c(t(p))
107107
ds <- cumsum(exp(p[1:(nCond)])) # enforce that sensitivity is ordered
108108

109-
b <- p[nCond+nRatings]
110109
theta <- p[nCond+nRatings]
111110
c_RA <- c(-Inf, p[nCond+nRatings-1] -
112111
rev(cumsum(c(exp(p[(nCond+1):(nCond+nRatings-2)])))),
@@ -148,8 +147,9 @@ ll_RCE <-
148147

149148
p_SB_RB <- outer(1:nCond, 1:nRatings, P_SBRB)
150149
p_SB_RA <- outer(1:nCond, 1:nRatings, P_SBRA)
151-
p_SA_RA <- outer(1:nCond, 1:nRatings, P_SARA)
152-
p_SA_RB <- outer(1:nCond, 1:nRatings, P_SARB)
150+
p_SA_RA <- outer(1:nCond, 1:nRatings, P_SARA) # rowSums(p_SB_RA) + rowSums(p_SB_RB)
151+
p_SA_RB <- outer(1:nCond, 1:nRatings, P_SARB) # rowSums(p_SA_RA) + rowSums(p_SA_RB)
152+
153153

154154
p_SB_RB[(is.na(p_SB_RB))| is.nan(p_SB_RB)| p_SB_RB < 10^-64] <- 10^-64
155155
p_SB_RA[(is.na(p_SB_RA))| is.nan(p_SB_RA)| p_SB_RA < 10^-64] <- 10^-64

R/plotConfModelFit.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ plotConfModelFit <- function(data, fitted_pars, model = NULL){
120120
'IG' = "Independent Gaussian model",
121121
'ITGc' = "Independent truncated Gaussian model: HMetad-Version",
122122
'ITGcm' = "Independent truncated Gaussian model: Meta-d'-Version",
123-
'logN' = "Logistic noise model",
124-
'logWEV' = "Logistic weighted evidence and visibility model",
123+
'logN' = "Lognormal noise model",
124+
'logWEV' = "Lognormal weighted evidence and visibility model",
125125
'PDA' = "Post-decisional accumulation model",
126126
'WEV' = "Weighted evidence and visibility model",
127127
'SDT' = "Signal detection rating model",

StatConfR.pdf

13.6 KB
Binary file not shown.
File renamed without changes.

man/fitConf.Rd

Lines changed: 27 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)