Skip to content

Instantly share code, notes, and snippets.

@jirilukavsky
Created February 6, 2019 09:49
Show Gist options
  • Save jirilukavsky/6479d34eece737c8cbc6ac00170244b1 to your computer and use it in GitHub Desktop.
Save jirilukavsky/6479d34eece737c8cbc6ac00170244b1 to your computer and use it in GitHub Desktop.
Sample data and minimalistic code to show analysis of psychophysics data. Data are from Muller-Lyer illusion experiment, where people compare a length of the line with a standard (featuring Muller-Lyer endings).
# example of fitting psychophysic curve to data are from one subject
# data from Muller-Lyer illusion, subjects are supposed to compare stimulus to
# standard (length = 100)
# columns:
# - length - length of stimulus line
# - pp - proportion of saying "longer"
# - id
# - N - is 10 for each value of length
# - k - count of saying "longer" (k = pp * N)
library(dplyr)
library(ggthemes)
library(quickpsy)
db <-
structure(list(length = c(
85, 88, 91, 94, 97, 100, 103, 106, 109,
112, 115, 118, 121, 124, 127
), pp = c(
0, 0, 0, 0.1, 0, 0.1, 0.1,
0.3, 0.5, 0.5, 0.8, 0.9, 0.9, 1, 1
), id = c(
"subject_1", "subject_1",
"subject_1", "subject_1", "subject_1", "subject_1", "subject_1",
"subject_1", "subject_1", "subject_1", "subject_1", "subject_1",
"subject_1", "subject_1", "subject_1"
), N = c(
10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
), k = c(
0, 0, 0, 1,
0, 1, 1, 3, 5, 5, 8, 9, 9, 10, 10
)), row.names = c(NA, -15L), class = c(
"tbl_df",
"tbl", "data.frame"
))
fit1 <- quickpsy(
db, length, k, N,
grouping = .(id), B = 100
)
plotcurves(fit1, panel = id) + theme_minimal()
fit1$par
fit1$thresholds
# plotpar(fit1)
# plotthresholds(fit1, geom = 'point')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment