Skip to content

Commit

Permalink
more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelRausch committed Apr 11, 2024
1 parent 410a5e2 commit cb87e31
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 40 deletions.
9 changes: 7 additions & 2 deletions R/fitConf.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,14 @@
#'

#' @export
fitConf <- function(data, model = "SDT", nInits = 5,
nRestart = 4#, var="constant"
fitConf <- function(data, model = "SDT",
condition = NULL, stimulus = NULL, correct = NULL, rating = NULL,
nInits = 5, nRestart = 4,
) {
if (!is.null(condition)) data$condition <- data[,condition]
if (!is.null(stimulus)) data$stimulus <- data[,stimulus]
if (!is.null(correct)) data$correct <- data[,correct]
if (!is.null(rating)) data$rating <- data[,rating]
if (is.null(data$condition)) data$condition <- 1
if (!is.factor(data$condition)) {
data$condition <- factor(data$condition)
Expand Down
4 changes: 4 additions & 0 deletions R/fitConfModels.R
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ fitConfModels <- function(data, models="all", nInits = 5, nRestart = 4, #var="c
warning("Duplicate models are dropped")
models <- unique(models)
}
if (!is.null(condition)) data$condition <- data[,condition]
if (!is.null(stimulus)) data$stimulus <- data[,stimulus]
if (!is.null(correct)) data$correct <- data[,correct]
if (!is.null(rating)) data$rating <- data[,rating]
if (is.null(data$condition)) data$condition <- factor(1)
if (!is.factor(data$condition)) {
data$condition <- factor(data$condition)
Expand Down
5 changes: 3 additions & 2 deletions R/int_fitMetaDprime.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int_fitMetaDprime <- function(ratings, stimulus, correct,
m <- try(optim(par = inits[j,], fn = negLoglMetaD, gr = NULL,
nC_rS1 = nC_rS1, nI_rS1 = nI_rS1, nC_rS2 = nC_rS2, nI_rS2 = nI_rS2,
nRatings = nRatings, cprime = cprime,
control = list(maxit = 10^6, reltol = 10^-8)), silent=T)
control = list(maxit = 10^4, reltol = 10^-4)), silent=T)
for(i in 2:nRestart){
try(m <- try(optim(par = m$par, fn = negLoglMetaD, gr = NULL,
nC_rS1 = nC_rS1, nI_rS1 = nI_rS1, nC_rS2 = nC_rS2, nI_rS2 = nI_rS2,
Expand Down Expand Up @@ -118,7 +118,8 @@ int_fitMetaDprime <- function(ratings, stimulus, correct,
dprime = dprime,
cprime = cprime,
c = dprime * cprime,
metaD = NA, Ratio = NA, ModelVersion = ModelVersion)
metaD = NA, Ratio = NA,
ModelVersion = ModelVersion)

if(exists("fit")){
if(is.list(fit)){
Expand Down
44 changes: 24 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
# statConfR: Models of Decision Confidence and Metacognition

This package includes functions to fit meta-d´/d´ as well as several
static models of decision making and confidence derived from signal
detection theory to test the assumptions underlying meta-d´/d´ and which
may serve as an alternative when the assumptions of meta-d´/d´ do not
hold. Currently, the following models are included:
The statConfR package provides functions to fit static models of
decision-making and confidence derived from signal detection theory for
binary discrimination tasks, as well as meta-d′/d′ (Rausch & Hellmann,
2024). The package can be used to test the assumptions underlying
meta-d′/d′. Several models provide a metacognition parameter that may
serve as an alternative when the assumptions of meta-d′/d′ assuming the
corresponding model provides a better fit to the data. Currently, the
following models are included:

- Signal Detection Rating Model
- Signal detection rating model

- Gaussian Noise Model
- Gaussian noise model

- Weighted Evidence and Visibility Model
- Weighted evidence and visibility model

- Post-decisional Accumulation Model

- Independent Gaussian model

- Independent Truncated Gaussian Model (the model underlying the
meta-d´/d´ method)
- Independent truncated gaussian Model (the model underlying the
meta-d′/d′ method, see Rausch et al., 2023)

See Rausch et al. (2023) for more detail about the models.
- Lognormal noise model

- Lognormal weighted evidence and visibility model

- Response-congruent evidence model

## Installation

Expand Down Expand Up @@ -131,19 +138,12 @@ head(fitted_pars)
## 6 -1.2341607 -0.07619421 0.2861275 1.2793275 2.018620

If the Truncated Gaussian model performs best in the model comparison,
metacognitive efficiency can be quantified using meta-d’/d’:
metacognitive efficiency can be quantified using meta-d′/d′:

``` r
MetaDs <- fitMetaDprime(MaskOri, model="ML", .parallel = TRUE)
```

## Future development

The package is still under active development. We plan to include more
models from the literature and function to compute the predicted
distribution of responses for given parameter sets. For any suggestions
and contributions, please contact us!

## Contact

For comments, remarks, and questions please contact either
Expand All @@ -154,4 +154,8 @@ or [submit an issue](https://github.com/ManuelRausch/StatConfR/issues).

Rausch, M., Hellmann, S. & Zehetleitner, M. (2023). Measures of
metacognitive efficiency across cognitive models of decision confidence.
[doi: 10.31234/osf.io/kdz34](https://doi.org/10.31234/osf.io/kdz34)
Psychological Methods.
[doi:10.1037/met0000634](https://doi.org/10.1037/met0000634) Rausch, M.,
& Hellmann, S. (2024). statConfR: An R Package for Static Models of
Decision Confidence and Metacognition. PsyArXiv.
[doi:10.31234/osf.io/dk6mr](https://doi.org/10.31234/osf.io/dk6mr)
35 changes: 19 additions & 16 deletions README.rmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "README"
author: "Sebastian Hellmann and Manuel Rausch"
date: "2023-09-15"
date: "2024-04-10"
output:
md_document:
variant: gfm
Expand All @@ -18,9 +18,14 @@ gitbranch <- "main/"

# statConfR: Models of Decision Confidence and Metacognition

This package includes functions to fit meta-d´/d´ as well as several
static models of decision making and confidence derived from signal detection theory. It can be used to test the
assumptions underlying meta-d´/d´ and which may serve as an alternative when the assumptions of meta-d´/d´ do not hold. Currently, the following models are included:
The statConfR package provides functions to fit static models of
decision-making and confidence derived from signal detection theory for
binary discrimination tasks, as well as meta-d′/d′ (Rausch & Hellmann,
2024). The package can be used to test the assumptions underlying
meta-d′/d′. Several models provide a metacognition parameter that may
serve as an alternative when the assumptions of meta-d′/d′ assuming the
corresponding model provides a better fit to the data. Currently, the
following models are included:

- Signal detection rating model

Expand All @@ -33,13 +38,13 @@ assumptions underlying meta-d´/d´ and which may serve as an alternative when t
- Independent Gaussian model

- Independent truncated gaussian Model (the model underlying the
meta-d´/d´ method)
meta-d′/d′ method, see Rausch et al., 2023)

- Lognormal noise model

- Lognormal weighted evidence and visibility model

See Rausch et al. (2023) for more detail about the models.
- Response-congruent evidence model

## Installation

Expand Down Expand Up @@ -443,19 +448,12 @@ head(fitted_pars)
```

If the Truncated Gaussian model performs best in the model comparison,
metacognitive efficiency can be quantified using meta-d'/d':
metacognitive efficiency can be quantified using meta-d′/d′:

``` r
MetaDs <- fitMetaDprime(MaskOri, model="ML", .parallel = TRUE)
```

## Future development

The package is still under active development. We plan to include more
models from the literature and function to compute the predicted
distribution of responses for given parameter sets. For any suggestions
and contributions, please contact us!

## Contact

For comments, remarks, and questions please contact either
Expand All @@ -467,4 +465,9 @@ or [submit an issue](https://github.com/ManuelRausch/StatConfR/issues).

Rausch, M., Hellmann, S. & Zehetleitner, M. (2023). Measures of
metacognitive efficiency across cognitive models of decision confidence.
[doi: 10.31234/osf.io/kdz34](https://doi.org/10.31234/osf.io/kdz34)
Psychological Methods.
[doi:10.1037/met0000634](https://doi.org/10.1037/met0000634)

Rausch, M., & Hellmann, S. (2024). statConfR: An R Package for Static
Models of Decision Confidence and Metacognition. PsyArXiv.
[doi:10.31234/osf.io/dk6mr](https://doi.org/10.31234/osf.io/dk6mr)

0 comments on commit cb87e31

Please sign in to comment.