Calculates density from a Normal distribution at a specific value with a specified mean and standard deviation.
apollo_normalDensity(normalDensity_settings, functionality)
List of arguments to the functions. It must contain the following.
outcomeNormal
: Numeric vector. Dependant variable.
xNormal
: Numeric vector. Single explanatory variable.
mu
: Numeric scalar. Intercept of the linear model.
sigma
: Numeric scalar. Variance of error component of linear model to be estimated.
rows
: Boolean vector. Consideration of rows in the likelihood calculation, FALSE to exclude. Length equal to the number of observations (nObs). Default is "all"
, equivalent to rep(TRUE, nObs)
.
componentName
: Character. Name given to model component.
Character. Can take different values depending on desired output.
"estimate": Used for model estimation.
"prediction": Used for model predictions.
"validate": Used for validating input.
"zero_LL": Used for calculating null likelihood.
"shares_LL": Used for calculating likelihood with constants only.
"conditionals": Used for calculating conditionals.
"output": Used for preparing output after model estimation.
"raw": Used for debugging.
The returned object depends on the value of argument functionality
as follows.
"estimate"
: vector/matrix/array. Returns the likelihood for each observation.
"prediction"
: Not implemented. Returns NA.
"validate"
: Same as "estimate"
, but it also runs a set of tests to validate the function inputs.
"zero_LL"
: Not implemented. Returns a vector of NA with as many elements as observations.
"shares_LL"
: Not implemented. Returns a vector of NA with as many elements as observations.
"conditionals"
: Same as "estimate"
"output"
: Same as "estimate"
but also writes summary of input data to internal Apollo log.
"raw"
: Same as "estimate"
This function estimates the linear model outcomeNormal = mu + xNormal + epsilon, where epsilon is a random error distributed Normal(0,sigma).
If using this function in the context of an Integrated Choice and Latent Variable (ICLV) model with continuous
indicators, then outcomeNormal
would be the value of the indicator, xNormal
would be the value of the latent variable (possibly
multiplied by a parameter to measure its correlation with the indicator, e.g. xNormal=lambda*LV), and mu
would be
an additional parameter to be estimated (the mean of the indicator, which should be fixed to zero if the indicator is
centered around its mean beforehand).