Learn R Programming

MixedPsy (version 1.2.0)

PsychPlot: Plot Psychometric Function from GLM

Description

Plot a psychometric function given an object of class glm or brglm. The plot can be drawn on a new or existing ggplot object.

Usage

PsychPlot(
  model.obj,
  addTo = NULL,
  showData = TRUE,
  ps.type = "solid",
  ps.size = 1,
  ps.lab = ""
)

Value

PsychPlot returns a ggplot object.

Arguments

model.obj

the fitted psychometric function. An object of class glm or brglm.

addTo

specifies an existing ggplot object where the new line should be plotted. If no object is given, the function is drawn on a new plot.

showData

logical, defines if proportion of binomial responses for each stimulus level are presented. Default is TRUE.

ps.type, ps.size

type and size of the plotted line (see "ggplot2-spec").

ps.lab

label assigned to the psychometric curve. The label is coded by the color aesthetic.

References

Moscatelli, A., Mezzetti, M., & Lacquaniti, F. (2012). Modeling psychophysical data at the population-level: The generalized linear mixed model. Journal of Vision, 12(11):26, 1-17. doi:10.1167/12.11.26

Knoblauch, K., & Maloney, L. T. (2012). Modeling psychophysical data in R (Vol. 32). Springer Science & Business Media.

See Also

glm for for Generalized Linear Models. PsychFunction for estimation of PSE and JND. MixPlot for plotting individual responses from a GLMM.

Examples

Run this code
data.S1 <- subset(simul_data, Subject == "S1")
psych.S1 <- PsychFunction(ps.formula = cbind(Longer, Total - Longer) ~ X, 
ps.link = "probit", ps.data = data.S1)
plotP1 <- PsychPlot(psych.S1$model, showData = TRUE, ps.lab = "S1") 

data.S2 <- subset(simul_data, Subject == "S2")
glm.S2 <- glm(formula = cbind(Longer, Total - Longer) ~ X, 
           family = binomial(link = "probit"), data = data.S2)
plotP2 <- PsychPlot(glm.S2, addTo = plotP1, ps.lab = "S2")

Run the code above in your browser using DataLab