diff --git a/R/fitConf.R b/R/fitConf.R index 8c24bc7..127683b 100644 --- a/R/fitConf.R +++ b/R/fitConf.R @@ -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) diff --git a/R/fitConfModels.R b/R/fitConfModels.R index 9cdc930..dd8d06a 100644 --- a/R/fitConfModels.R +++ b/R/fitConfModels.R @@ -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) diff --git a/R/int_fitMetaDprime.R b/R/int_fitMetaDprime.R index fd45f85..45eb0d5 100644 --- a/R/int_fitMetaDprime.R +++ b/R/int_fitMetaDprime.R @@ -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, @@ -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)){ diff --git a/README.md b/README.md index 12b4298..335ffbb 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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) diff --git a/README.rmd b/README.rmd index e9f3473..d91b7fc 100644 --- a/README.rmd +++ b/README.rmd @@ -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 @@ -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 @@ -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 @@ -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 @@ -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)