Learn R Programming

DstarM (version 0.1.0)

plotObserved: Plot histogram of data with overlayed model predicted density.

Description

Plots histograms for each condition-response pair/ condition/ response with overlayed estimated densities.

Usage

plotObserved(resObserved, data, what = "cr", layout = NULL, main = NULL, linesArgs = list(), ggplot = FALSE, prob = NULL, probType = 3, ...)

Arguments

resObserved
output of estObserved.
data
The dataset used to estimate the model.
what
What to plot. Can be 'cr' for 'condition-response pairs, 'c' for condition, and 'r' for response.
layout
An optional layout matrix.
main
an optional vector containing names for each plot.
linesArgs
A list containing named arguments to be passed to lines.
ggplot
Logical, should ggplot2 be used instead of base R graphics? If set to TRUE, some arguments from linesArgs and ... will be ignored (but can be added to plots manually).
prob
Should a qqplot of observed vs model implied quantiles be plotted? If NULL (the default) then a histogram overlayed with model implied densities will be plotted. Otherwise, this argument should be a vector of probabilities to be passed to estQdf.
probType
A numeric value defining several plotting options. 0 does nothing, 1 removes the 0% quantile, 2 removes the 100% quantile and 3 removes both the 0% and 100% quantile.
...
Further arguments to be passed to hist.

Value

if ggplot is FALSE invisible(), otherwise a list

Details

Keep in mind when using what = 'c' or what = 'r' pdfs are simply averaged, not weighted to the number of observed responses.

Examples

Run this code
# simulate data with three stimuli of different difficulty.
# this implies different drift rates across conditions.
# define a time grid. A more reasonable stepsize is .01; this is just for speed.
tt = seq(0, 5, .1)
pars = c(.8, 2, .5, .5, .5, # condition 1
        .8, 3, .5, .5, .5, # condition 2
        .8, 4, .5, .5, .5) # condition 3
pdfND = dbeta(tt, 10, 30)
# simulate data
lst = simData(n = 3e5, pars = pars, tt = tt, pdfND = pdfND, return.pdf = TRUE)
dat = lst$dat
# define restriction matrix
restr = matrix(1:5, 5, 3)
restr[2, 2:3] = 6:7 # allow drift rates to differ
# fix variance parameters
fixed = matrix(c('sz1', .5, 'sv1', .5), 2, 2)
## Not run: 
# # Run D*M analysis
# resD = estDstarM(dat = dat, tt = tt, restr = restr, fixed = fixed)
# # Estimate nondecision density
# resND = estND(resD)
# # Estimate observed density
# resObs = estObserved(resD, resND)
# # plot histograms with overlayed
# # densities per condition-response pair
# plotObserved(resObserved = resObs, data = dat,
#             xlim = c(0, 1))
# # plot estimated and true densities
# plot(resObs, col = rep(1:3, each = 2), xlim = 0:1)
# matlines(tt, lst$pdfNormalized, col = rep(1:3, each = 2), lty = 2)
# # other uses of plotObserved
# plotObserved(resObserved = resObs, data = dat, what = 'cr', xlim = c(0, 1))
# plotObserved(resObserved = resObs, data = dat, what = 'c', xlim = c(0, 1))
# plotObserved(resObserved = resObs, data = dat, what = 'r', xlim = c(0, 1))
# ## End(Not run)

Run the code above in your browser using DataLab