apollo_insertFunc {apollo}R Documentation

Modifies function to make it compatible with analytic gradients

Description

Takes a likelihood function and inserts function () before key elements to allow for analytic gradient calculation

Usage

apollo_insertFunc(f, like = TRUE, randCoeff = FALSE, lcPars = FALSE)

Arguments

f

Function. Expressions inside it will be turned into functions. Usually apollo_probabilities or apollo_randCoeff.

like

Logical. Must be TRUE if f is apollo_probabilities. FALSE otherwise.

randCoeff

Logical. Must be TRUE if f is apollo_randCoeff. FALSE otherwise.

lcPars

Logical. Must be TRUE if f is apollo_lcPars. FALSE otherwise.

Details

It modifies the definition of the following models.

It can only track a maximum of 3 levels of depth in definitions. For example: V <- list() V[["A"]] <- b1*x1A + b2*x2A V[["B"]] <- b1*x1B + b2*x2B mnl_settings1 <- list(alternatives=c("A", "B"), V = V, choiceVar= Y, avail = 1, componentName="MNL1") P[["MNL1"]] <- apollo_mnl(mnl_settings1, functionality) But it may not be able to deal with the following: VA <- b1*x1A + b2*x2A V <- list() V[["A"]] <- VA V[["B"]] <- b1*x1B + b2*x2B mnl_settings1 <- list(alternatives=c("A", "B"), V = V, choiceVar= Y, avail = 1, componentName="MNL1") P[["MNL1"]] <- apollo_mnl(mnl_settings1, functionality) But that might be enough given how apollo_dVdB works.

Value

Function f but with relevant expressions turned into function definitions.


[Package apollo version 0.3.1 Index]