Learn R Programming

apollo (version 0.3.2)

apollo_deltaMethod: Delta method for Apollo models

Description

Applies the Delta method to calculate the standard errors of transformations of parameters.

Usage

apollo_deltaMethod(model, deltaMethod_settings)

Value

Matrix containing value, s.e. and t-ratio resulting from the requested expression or operation. This is also printed to screen.

Arguments

model

Model object. Estimated model object as returned by function apollo_estimate.

deltaMethod_settings

List. Contains settings for this function. User input is required for all settings except those with a default or marked as optional.

  • expression: Character vector. A character vector with a single or multiple arbitrary functions of the estimated parameters, as text. For example: c(VTT="b1/b2*60"). Each expression can only contain model parameters (estimated or fixed), numeric values, and operands. At least one of the parameters used needs to not have been fixed in estimation. Variables in the database cannot be included. If the user does not provide a name for an expression, then the expression itself is used in the output. If this setting is provided, then operation, parName1, parName2, multPar1 and multPar2 are ignored.

  • allPairs: Logical. If set to TRUE, Delta method calculations are carried out for the ratio and difference for all pairs of parameters and returned as two separate matrices with values and t-ratios. FALSE by default.

  • varcov: Character. Type of variance-covariance matrix to use in calculations. It can take values "classical", "robust" and "bootstrap". Default is "robust".

  • printPVal: Logical or Scalar. TRUE or 1 for printing p-values for one-sided test, 2 for printing p-values for two-sided test, FALSE for not printing p-values. FALSE by default.

  • operation: Character. Function to calculate the delta method for. See details. Not used if expression is provided.

  • parName1: Character. Name of the first parameter if operation is used. See details. Not used if expression is provided.

  • parName2: Character. Name of the second parameter if operation is used. See details. Not used if expression is provided.. Optional depending on operation.

  • multPar1: Numeric scalar. An optional value to scale parName1. Not used if expression is provided.

  • multPar2: Numeric scalar. An optional value to scale parName2. Not used if expression is provided.

Details

apollo_deltaMethod can be used in two ways. The first and recommended way is to provide an element called expression inside its argument deltaMethod_settings. expression should contain the expression or expressions for which the standard error is/are to be calculated, as text. For example, to calculate the ratio between parameters b1 and b2, expression=c(vtt="b1/b2") should be used.

The second method is to provide the name of a specific operation inside deltaMethod_settings. The following five operations are supported.

  • sum: Calculates the s.e. of parName1 + parName2

  • diff: Calculates the s.e. of parName1 - parName2 and parName2 - parName1

  • prod: Calculates the s.e. of parName1*parName2

  • ratio: Calculates the s.e. of parName1/parName2 and parName2/parName1

  • exp: Calculates the s.e. of exp(parName1)

  • logistic: If only parName1 is provided, it calculates the s.e. of exp(parName1)/(1+exp(parName1)) and 1/(1+exp(parName1)). If parName1 and parName2 are provided, it calculates exp(par_i)/(1+exp(parName1)+exp(parName2)) for i=1, 2, and 3 (par_3 = 1).

  • lognormal: Calculates the mean and s.d. of a lognormal distribution based on the mean (parName1) and s.d. (parName2) of the underlying normal.

By default, apollo_deltaMethod uses the robust covariance matrix. However, the user can change this through the varcov setting.