pupil_solve: Main function that fits the penalized additive pupil model.

View source: R/model_setup_helpers.R

pupil_solveR Documentation

Main function that fits the penalized additive pupil model.

Description

This function fits one of the penalized pupil models that are available with this package.

Usage

pupil_solve(
  pulse_spacing,
  data,
  factor_id = "subject",
  model = "WIER_SHARED",
  n = 10.1,
  t_max = 930,
  f = 1/(10^24),
  drop_last = 500,
  maxiter_inner = 10000,
  maxiter_outer = 25,
  convergence_tol = 1e-08,
  should_collect_progress = F,
  start_lambda = 0.1,
  should_accum_H = F,
  init_cf = NULL,
  expand_by = 800,
  sample_length = 20,
  time_id = "time",
  pupil_id = "pupil"
)

Arguments

pulse_spacing

Model pulses every 'pulse_spacing' samples. Setting this to 1 ensures 1 pulse every sample

data

Aggregated data with a time and pupil column. Also needs a factor column

factor_id

Name of the factor column. Model will estimate demand trajectory for each level of this factor

model

Model template.

n

Choice for parameter defined by Hoeks & Levelt (number of laters)

t_max

Choice for parameter defined by Hoeks & Levelt (response maximum in ms)

f

Choice for parameter defined by Wierda et al. (scaling factor)

drop_last

Drop pulses that would happen in the last drop_last ms

maxiter_inner

Maximum steps taken by inner optimizer

maxiter_outer

Maximum steps taken by outer optimizer

convergence_tol

Convergence check to terminate early

should_collect_progress

If T, then the entire coefficient update history is collected and returned. VERY COSTLY.

start_lambda

Initial lambda value. Must be > 0 if a penalty should be used! Setting this to 0 and maxiter_outer=1, leads to estimation of an un-penalized additive model, i.e., recovers the traditional NNLS estimate used by Wierda et al. (2012) and Denison et al. (2012).

should_accum_H

Whether Hessian should be approximated using BFGS rule or not (see Fletcher, R. (2000). Practical Methods of Optimization). If not, then least squares Hessian matrix is used. With the BFGS rule models ended up being much smoother in our simulations. So this should be set to true if under-smoothing is observed. However, the BFGS update is much more costly and takes much more time!

init_cf

NULL or vector with initial coefficient estimate

expand_by

Time in ms by which to expand the time-series in the past. Then pulses that happened before the recorded time-window can still be approximated! See artificial_data_analysis vignette for details.

sample_length

Duration in ms of a single sample. If pupil dilation time-course was down-sampled to 50HZ, set this to 20

time_id

Name of time column in data

pupil_id

Name of pupil column in data

Details

See the artificial_data_analysis vignette for details and usage examples.


JoKra1/papss documentation built on June 15, 2022, 8:57 a.m.