tef_fitAll2brms: Refit a TEfitAll model with brms

View source: R/tef_fitAll2brms.R

tef_fitAll2brmsR Documentation

Refit a TEfitAll model with brms

Description

This method has been superceded by TEbrm. Please use that method instead.

Usage

tef_fitAll2brms(
  TEs3s,
  fixef = NA,
  nIter = 2000,
  nChains = 3,
  nCores = 2,
  errFun = NA,
  prior_dispersion = 2
)

Arguments

TEs3s

TEfitAll model

fixef

Parameters vary as random effects by the TEs3s grouping variable. However, if you have main effects (e.g., group differences), enter them as a data frame here.

nIter

number of iterations

nChains

number of chains

nCores

number of cores

errFun

the error function to use. Defaults to the same as the TEfitAll model, if possible.

prior_dispersion

This number, multiplied by the SD of each TEfitAll parameter, is used as the prior SD for that parameter.

Details

Passes a TEfitAll model to [nonlinear mixed-effects Bayesian] fitting using brms-package. Note that, due to the extensive time needed to fit brms-package models, this function is less tested than most functions in the TEfits package. Functionality is experimental.

Priors for nonlinear parameters are informed by the distributions of parameters in the TEfitAll object [models]. However, any fixed effects should be minimally influenced by these priors

TEfitAll bernoulli models are fit using either bernoulli or Beta response distributions in brms depending on whether the TEfitAll distrIibution is binary. TEfitAll logcosh models are fit using a asym_laplace response distribution in brms predicting the .5 quantile.

If sampling issues occur, increased number of iterations are recommended. Also, running one chain at a time may help; these models should later be merged using brms::combine_models().

Value

A brms-package nonlinear mixed-effects model object.

Note

Under development. Partial functionality.

Examples

## Not run: 
dat <- anstrain
dat$condition <- rep(c('A','B'),each=500)

# Model with time and one categorical fixed effect
mod_tef <- TEfitAll(dat[,c('acc','trialNum')], groupingVar = dat$subID)
mod_brm <- tef_fitAll2brms(mod_tef,nChains=1,fixef=data.frame(condition=dat$condition))

# Model with time, one categorical fixed effect, and one by-groupingVar (subID) random slope
dat$absRat <- scale(abs(dat$ratio))
mod_tef <- TEfitAll(dat[,c('acc','trialNum',"absRat")], groupingVar = dat$subID,covarTerms=list(pRate=c(F)))
mod_brm <- tef_fitAll2brms(mod_tef,nChains=1,fixef=data.frame(condition=dat$condition))

## End(Not run)


akcochrane/TEfits documentation built on June 12, 2025, 11:10 a.m.