Learn R Programming

YEAB (version 1.0.6)

exhaustive_sbp: Single breakpoint algorithm, the exhaustive version as the one used in Guilhardi & Church 2004

Description

Single breakpoint algorithm, the exhaustive version as the one used in Guilhardi & Church 2004

Usage

exhaustive_sbp(r_times, trial_duration)

Value

A data frame of 3 columns bp a numeric value which corresponds to the time at which a break point was detected r1 a numeric value of the response rate before the breakpoint r2 a numeric value of the responser rate after the breakpoint d1 a numeric value of the duration of the first state d2 a numeric value of the duration of the second state

Arguments

r_times

numeric, the times at which a response was emitted in a trial

trial_duration

numeric, the duration of the IF interval

Details

This algorithm performs an extensive search of every combination (t1, t2) where t1 starts in the first response through (length(r_times) - 1)

Examples

Run this code
data("r_times")
r_times <- r_times[r_times < 60]
single_bp <- exhaustive_sbp(r_times, 60)

plot(r_times, seq_along(r_times),
  xlim = c(0, max(r_times)),
  main = "Cummulative Record",
  xlab = "Time (s)",
  ylab = "Cum Resp",
  col = 2, type = "s"
)
abline(v = single_bp$bp)

bp_from_opt <- bp_opt(r_times, 60)
abline(v = bp_from_opt$bp, col = 3)

Run the code above in your browser using DataLab