plotObserved: Plot quantiles of data against model implied quantiles.

Description Usage Arguments Details Value Examples

View source: R/plotObserved.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
plotObserved(
  resObserved,
  data,
  what = c("cr", "c", "r"),
  layout = NULL,
  main = NULL,
  linesArgs = list(),
  ggplot = FALSE,
  prob = seq(0, 1, 0.01),
  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

Deprecated and ignored.

prob

Should a qqplot of observed vs model implied quantiles be plotted? By default, it is seq(0, 1, .01), the probabilities between 0 and 1 to compare the model implied quantiles to the observed quantiles. If this argument is NULL, then a histogram overlayed with model implied densities will be plotted. Internally, estQdf is used for generating quantiles.

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.

Details

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

Value

if ggplot is FALSE invisible(), otherwise a list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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)

vandenman/DstarM documentation built on Nov. 3, 2021, 8:22 p.m.