bp_opt {YEAB} | R Documentation |
Find the best fit for individual trials using optim
Description
Find the best fit for individual trials by minimizing the negative sum of areas between the response rate and the target rate.
Usage
bp_opt(r_times, trial_duration, optim_method = "Brent")
Arguments
r_times |
Vector of response times |
trial_duration |
Duration of the trial |
optim_method |
character, the optimization method to use |
Value
A data frame with the following columns:
-
bp
: The breakpoint -
r1
: The response rate before the breakpoint -
r2
: The response rate after the breakpoint -
d1
: The duration of the first state -
d2
: The duration of the second state
Examples
data("r_times")
r_times <- r_times[r_times < 60]
bp_from_opt <- bp_opt(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 = bp_from_opt$bp)
[Package YEAB version 1.0.6 Index]