How to integrate out the prediction error of an imputed variable?
Posted: 09 Oct 2025, 13:03
First of all, many thanks for providing such a great open-source tool to the research community and providing detailed documentation and assistance.
Question in short
How can I use the apollo package to estimate a mixed logit model where, next to inter-observation draws for the random parameters, I integrate over intra-observations draws of an imputed independent variable? Does anyone have/know some example code for this?
And, can the function be adapted such that I supply the set of values of the imputed independent variable computed earlier, instead of relying on the values generated based on the draws generated within the apollo functions? In other words, I do not want to use apollo_draws() and apollo_randCoeffs() functions, but instead use apollo_avgIntraDraws() to average out over a set of pre-computed values resulting from draws of an imputed variable.
With more context
I am using the apollo package to estimate a discrete choice labor supply model where households choose the number of days per week to work, following Van Soest (1995). In each discrete choice, disposable income is calculated by multiplying hourly wage by the hours worked in that option and passing the resulting gross income through a detailed tax-benefit calculator.
For the unemployed, hourly wage has to be imputed. As is standard in the discrete choice structural labor supply literature, I want to integrate out the wage imputation error by including intra-person random draws from the wage imputation and averaging out over them in the maximum likelihood function. It is not possible to simultaneously estimate wages and the discrete choice model, as I first need to pass simulated gross income based on (imputed) wage through the tax-benefit calculator.
This raises two issues that, to my knowledge, have not been discussed in the manual. In this post (https://www.apollochoicemodelling.com/f ... mpute#p842), the issue of multiple imputation is discussed. However, I thought that simply stacking copied observations with added disturbances to the imputed variable yields biased results, as the likelihood contribution of each observation-draw combination should first be averaged at the observation level, before taking the log and summing across observations (aka, the mean of logs is not the same at the log of means).
First, the apollo functions are designed to generate intra- and inter-observation draws for random parameters. I am struggling to understand how to adapt the functions to a setting where it is the covariate that has a distribution. It also appears that the error "intra-person draws are used without a panel structure. This is not allowed!" would need to be overuled somehow; when taking draws from an imputed variable, intra-person draws with one observation is possible.
Second, I am not sure of to replace the interaction between the apollo_draws(), apollo_randCoeffs() and apoll_mnl() in a way that allows me to use a pre-generated set of covariate values to perform the apollo_avgIntraDraws() over. Section 6.1.3 discusses how to use pre-computed draws, but not how one can use a set of pre-computes values that result from those draws.
I am hoping someone has faced the same situation and can help me get started, or has advice on how to implement this in Apollo.
Question in short
How can I use the apollo package to estimate a mixed logit model where, next to inter-observation draws for the random parameters, I integrate over intra-observations draws of an imputed independent variable? Does anyone have/know some example code for this?
And, can the function be adapted such that I supply the set of values of the imputed independent variable computed earlier, instead of relying on the values generated based on the draws generated within the apollo functions? In other words, I do not want to use apollo_draws() and apollo_randCoeffs() functions, but instead use apollo_avgIntraDraws() to average out over a set of pre-computed values resulting from draws of an imputed variable.
With more context
I am using the apollo package to estimate a discrete choice labor supply model where households choose the number of days per week to work, following Van Soest (1995). In each discrete choice, disposable income is calculated by multiplying hourly wage by the hours worked in that option and passing the resulting gross income through a detailed tax-benefit calculator.
For the unemployed, hourly wage has to be imputed. As is standard in the discrete choice structural labor supply literature, I want to integrate out the wage imputation error by including intra-person random draws from the wage imputation and averaging out over them in the maximum likelihood function. It is not possible to simultaneously estimate wages and the discrete choice model, as I first need to pass simulated gross income based on (imputed) wage through the tax-benefit calculator.
This raises two issues that, to my knowledge, have not been discussed in the manual. In this post (https://www.apollochoicemodelling.com/f ... mpute#p842), the issue of multiple imputation is discussed. However, I thought that simply stacking copied observations with added disturbances to the imputed variable yields biased results, as the likelihood contribution of each observation-draw combination should first be averaged at the observation level, before taking the log and summing across observations (aka, the mean of logs is not the same at the log of means).
First, the apollo functions are designed to generate intra- and inter-observation draws for random parameters. I am struggling to understand how to adapt the functions to a setting where it is the covariate that has a distribution. It also appears that the error "intra-person draws are used without a panel structure. This is not allowed!" would need to be overuled somehow; when taking draws from an imputed variable, intra-person draws with one observation is possible.
Second, I am not sure of to replace the interaction between the apollo_draws(), apollo_randCoeffs() and apoll_mnl() in a way that allows me to use a pre-generated set of covariate values to perform the apollo_avgIntraDraws() over. Section 6.1.3 discusses how to use pre-computed draws, but not how one can use a set of pre-computes values that result from those draws.
I am hoping someone has faced the same situation and can help me get started, or has advice on how to implement this in Apollo.