Important: Read this before posting to this forum

  1. This forum is for questions related to the use of Apollo. We will answer some general choice modelling questions too, where appropriate, and time permitting. We cannot answer questions about how to estimate choice models with other software packages.
  2. There is a very detailed manual for Apollo available at http://www.ApolloChoiceModelling.com/manual.html. This contains detailed descriptions of the various Apollo functions, and numerous examples are available at http://www.ApolloChoiceModelling.com/examples.html. In addition, help files are available for all functions, using e.g. ?apollo_mnl
  3. Before asking a question on the forum, users are kindly requested to follow these steps:
    1. Check that the same issue has not already been addressed in the forum - there is a search tool.
    2. Ensure that the correct syntax has been used. For any function, detailed instructions are available directly in Apollo, e.g. by using ?apollo_mnl for apollo_mnl
    3. Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
    4. Make sure that R is using the latest official release of Apollo.
  4. If the above steps do not resolve the issue, then users should follow these steps when posting a question:
    1. provide full details on the issue, including the entire code and output, including any error messages
    2. posts will not immediately appear on the forum, but will be checked by a moderator first. This may take a day or two at busy times. There is no need to submit the post multiple times.

standard errors of average marginal effects

Ask questions about post-estimation functions (e.g. prediction, conditionals, etc) or other processing of results.
Post Reply
marie
Posts: 1
Joined: 12 May 2023, 17:18

standard errors of average marginal effects

Post by marie »

Hi,

I would like to estimate standard errors of average marginal effects. I am running a MXL model on a DCE where participants could choose an option between three different contracts (A, B or C).
I estimated average marginal effects following the example http://apollochoicemodelling.com/files/ ... variates.r . I have dummy variables so my code is the following:

### Use the estimated model to make predictions
predictions_base = apollo_prediction(model, apollo_probabilities, apollo_inputs)
### Level change (env_C=1 to env_C=2)
database$env_C = 2
### Rerun predictions with the new data
apollo_inputs = apollo_validateInputs()
predictions_new = apollo_prediction(model, apollo_probabilities, apollo_inputs)
### Return to original data
database$env_C = 1
apollo_inputs = apollo_validateInputs()
### Compute change in probabilities
change=predictions_new-predictions_base
change=change[,-ncol(change)]
change=change[,-c(1,2)]
### Mean of changes to compute average marginal effects
mean(change$contratC)
mean(change$contratA)
mean(change$contratB)

Ideally, I would like to apply the Delta-method to get the estimate standard errors of the average marginal effect. From what I understood from the manual the function apollo_deltaMethod can be apply to model parameters. However, I do not know how to apply the Delta-method to my expression of interest which is change=predictions_new-predictions_base. Is it possible to do it? Do you have any recommendation on the procedure to follow?

Besides, I read in the manual that “In addition, an optional setting called runs has been included that computes standard errors across multiple prediction runs based on different draws from the estimates and covariance matrix for the model parameters”. However, I do not know how to easily access standard errors values? The result retuned by the function do not specify standard errors if I am not mistaken?

Thank you for your help,

Marie
stephanehess
Site Admin
Posts: 1002
Joined: 24 Apr 2020, 16:29

Re: standard errors of average marginal effects

Post by stephanehess »

Marie

have a look at the help file for apollo_prediction. If you run it with the runs setting, it will produce an array for you with the runs at different draws from the asymptotic parameter distribution and you can then use those to calculate standard errors for your marginal effects

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply