Skip to content

Instantly share code, notes, and snippets.

@markushuff
markushuff / get_n_eb_times.R
Last active December 4, 2021 16:15
Get a list including the n highest event boundaries of a segmag object (Papenmeier, 2016; https://cran.r-project.org/package=segmag). Sometimes it is necessary to get just a list of the n highest event boundaries w/o doing the time consuming bootstrapping method. Note, this function requires the segmag package.
get_n_eb_times <- function(n, segmag)
{
eb_times <- get_eb_times(segmag,
cutoff = mean(segmag$data$segmentation_magnitude))
out <- segmag$data[segmag$data$time %in% eb_times, ]
out <- out[order(out$segmentation_magnitude, decreasing = TRUE),]
out[1:n,]
}
@markushuff
markushuff / d_sub_a.R
Last active March 17, 2017 09:20
How to calculate sensitivity d_a ("d sub a")? Step-by-step example from the Macmillan and Creelman book.
# Calculation of d_a ("d sub a"). A step-by-step tutorial based on the book:
# Macmillan, N. A., & Creelman, C. D. (2004). Detection theory: A user’s guide.
# Psychology Press.
#
# pp. 57ff
library(ggplot2)
library(plyr)
# Create data set