View source: R/apollo_insertFunc.R
apollo_insertFunc | R Documentation |
Takes a likelihood function and inserts function ()
before key elements to allow for analytic gradient calculation
apollo_insertFunc(f, like = TRUE, randCoeff = FALSE, lcPars = FALSE)
f |
Function. Expressions inside it will be turned into functions. Usually |
like |
Logical. Must be TRUE if |
randCoeff |
Logical. Must be TRUE if |
lcPars |
Logical. Must be TRUE if |
It modifies the definition of the following models.
apollo_mnl
: Turns all elements inside mnl_settings$V
into functions.
apollo_ol
: Turns ol_settings$V
and all elements inside ol_settings$tau
into functions.
apollo_op
: Turns op_settings$V
and all elements inside op_settings$tau
into functions.
apollo_normalDensity
: Turns normalDensity_settings$xNormal
, normalDensity_settings$mu
and normalDensity_settings$sigma
into functions.
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.
Function f
but with relevant expressions turned into function definitions.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.