Learn R Programming

YEAB (version 1.0.6)

berm: Biexponential Refractory Model (BERM)

Description

Implements the biexponential refractory model (BERM) using maximum likelihood estimation to fit parameters for inter-response times (IRTs) within and between bouts.

The model is defined as: $$p(IRT = \tau | \tau \ge \delta) = p w e^{-w (\tau - \delta)} + (1 - p) b e^{-b (\tau - \delta)}$$ where \(w\) and \(b\) are the rates for within and between bouts, \(p\) is the proportion of responses in bouts, and \(\delta\) is the refractory period.

Calculates the negative log-likelihood for the BERM model.

Maps an unconstrained d_hat onto the observed minimum inter-response time (d), ensuring that it aligns with model constraints.

Converts raw parameters into their constrained forms to enforce model constraints on parameters such as w, l0, l1, and d.

Optimizes the log-likelihood function to estimate BERM model parameters based on observed inter-response times.

Usage

berm(irt, delta)

berm_log_likelihood(params, irt)

map_onto(d, d_hat)

param_conver(params, min_irt, parnames = c("w", "l0", "l1", "d"))

optimize_berm(irt)

Value

A data frame with estimated parameters \(w\) (within-bout rate), \(b\) (between-bout rate), \(p\)

(proportion of responses in bouts), and \(\delta\) (adjusted refractory period).

Negative log-likelihood value used for parameter estimation.

Adjusted refractory period used in likelihood estimation.

A named numeric vector of transformed parameters with constraints applied.

A named vector of optimized parameters for the BERM model.

Arguments

irt

A numeric vector of inter-response times.

delta

A numeric value for the refractory period.

params

A numeric vector of raw, unconstrained parameters.

d

Minimum inter-response time.

d_hat

Transformed parameter to be mapped onto d.

min_irt

Minimum inter-response time for mapping d.

parnames

Optional vector of parameter names for labeling.

Details

This function computes the negative log-likelihood based on biexponential functions for the BERM model, adjusting parameters using param_conver to meet constraints.

Examples

Run this code
set.seed(43)
l1 <- 1 / 0.5
l2 <- 1 / 0.1
p <- 0.4
n <- 200
delta <- 0.03
irt <- c(rexp(round(n * p), l1), rexp(round(n * (1 - p)), l2)) + delta
optimize_berm(irt)

set.seed(43)
l1 <- 1 / 0.5
l2 <- 1 / 0.1
p <- 0.4
n <- 200
delta <- 0.03
irt <- c(rexp(round(n * p), l1), rexp(round(n * (1 - p)), l2)) + delta
optimize_berm(irt)

Run the code above in your browser using DataLab