plotrw: Plot Random Walk

View source: R/plot.R

plotrwR Documentation

Plot Random Walk

Description

This function allows to plot random walks.

Usage

plotrw(
  data,
  sims.df = NULL,
  sims.df.col = "rw",
  color = "black",
  coordy = c(-absolutemax, absolutemax),
  mu = NULL,
  p = 0.5
)

Arguments

data

A vector containing the random walk to be drawn or a list containing multiple vectors.

sims.df

A dataframe containing simulations, including column "simid" and "index". Set to NULL if you don't want to display simulations.

sims.df.col

The name of the column of the simulation dataframe to compare to.

color

A color in which the Random Walk will be drawn.

coordy

A vector containing the minimum and maximum value of the y-coordinates to be drawn.

mu

If bits are summed up for a single step, this is the mean of the sum.

p

Indicate the probability of success for a single step.

Details

The Random Walk can be plotted by itself or in comparison to simulated data sets. GGplot2 is used to draw an image. A random walk typically goes +1 for every correct choice and -1 for every incorrect one. Depending on the amount of simulations, drawing might take a while. It might be wise to chose a smaller simulation set for this purpose.

Examples

p.rw <- plotrw(tbl$rw)
p.rw

plotrw(tbl$rw, sims.df = sims, sims.df.col = "rw", coordy = c(-50,50))

plotrw(list(exp = exp$rw, con = con$rw), mu = 5)

df$rw <- cumsum(ifelse(df$correct == TRUE, 1, -1))
plotrw(df$rw, p = 0.2) # 1 in 5 probability of success

sims1000 <- subset(sims, simid <= 1000)
plotrw(tbl, sims.df = sims1000)

mrzdcmps/changeofevidence documentation built on Feb. 27, 2025, 3:10 a.m.