There are several packages to fit the psychometric function in R, for the single subject analysis. Among others: `psyphy`

, `quickpsy`

, `MPDiR`

. See CRAN Task View: Psychometric Models and Methods for an overview of the different packages. Now, I also included a simple function for the analysis of single subject data in `MERpsychophysics`

.

The function is called `psych.function`

. Model fitting is based on `glm`

. The function plot the fitted model on an existing plot and provides an estimate of the PSE, the JND and the related confidence intervals. These estimates are computed via delta method. I chose to add the fitted model to an existing plot, so that the user can customize the plot layout using `par`

. Several participant and/or conditions can be added to the plot by recursive usage of the function (see the example below).

source("MERpsychophysics.r")
#this ensure that your output will match mine
set.seed(32787)
#this is to simulate data (one subject)
datafr.S1 <- MERsimulate(fixeff = c(-7.5, 0.0875), nsubject = 1,
constant = T)
#psychometric function to fit single-subject data
plot(Longer/Total ~ X, data = datafr.S1)
fit.S1 = psych.function(ps.formula = cbind(Longer, Total - Longer) ~ X,
ps.link = "probit", ps.data = datafr.S1,
x.range = c(40, 120), ps.lines = T)
fit.S1
#this simulates a second participant
datafr.S2 <- MERsimulate(fixeff = c(-6.8, 0.0875), nsubject = 1,
constant = T)
points(Longer/Total ~ X, data = datafr.S2, col = "red")
fit.S2 = psych.function(ps.formula = cbind(Longer, Total - Longer) ~ X,
ps.link = "probit", ps.data = datafr.S2,
x.range = c(40, 120), ps.lines = T,
ps.col = "red")
fit.S2

This is the plot generated by the R code above (see also `MERdemo.R`

). Each participant is plotted in a different color. The line segment on the curve is the 95% confidence interval of the PSE estimated via delta method. For the moment it only works with uni-variable models, you can use the standard R function `glm`

to fit multivariable models.

### Like this:

Like Loading...

## Leave a Reply