Including agent effect with large set of alternatives

123 views
Skip to first unread message

Carlos Romero

unread,
Nov 10, 2021, 2:14:53 AM11/10/21
to Biogeme

Dear Prof. Bierlaire,

I am estimating a seat choice model with panel data (5 observations per individual) and I am dealing with introducing the agent effect in the utility functions. My model has a large set of alternatives (>20) and all their attributes are included in the utility function. I want to introduce the agent effect by means of an error component distributed only across individuals (and not alternatives).

I looked into the panel data examples on the biogeme website (e.g. 13panelNormalized.py) and I realized the utility functions always have one different error component for each alternative. But I would like only to include a individual error term, not an alternative-based one.

Should it be correct to introduce a single error component N(0,sigma) for all the alternatives but one to address the agent effect? My code (Betas, V’s and AV’s defined as usual, not copied below) is as follows:

database = db.Database('Panel', Panel)
database.panel("respondentId")
globals().update(database.variables)

# Error component
SIGMA = Beta('SIGMA',1.0,None, None, 0)
ERRORCOMP = SIGMA * bioDraws('ERRORCOMP', ‘NORMAL_ANTI’)

# Utility functions (just written the first 4)
V1 = B1 * X1_1 + B2 * X2_1 + B3 * X3_1
V2 = B1 * X1_2 + B2 * X2_2 + B3 * X3_2 + ERRORCOMP
V3 = B1 * X1_3 + B2 * X2_3 + B3 * X3_3 + ERRORCOMP
V4 = B1 * X1_4 + B2 * X2_4 + B3 * X3_4 + ERRORCOMP

#Likelihood and model estimation (as usual)
obsprob = models.logit(V, av, seatChoice)
condprobIndiv = PanelLikelihoodTrajectory(obsprob)
logprob = log(MonteCarlo(condprobIndiv))
biogeme = bio.BIOGEME(database, logprob, numberOfDraws=num_draws)

 

Best regards,

Carlos

Bierlaire Michel

unread,
Nov 10, 2021, 8:46:08 AM11/10/21
to carlos9...@gmail.com, Bierlaire Michel, Biogeme

On 9 Nov 2021, at 20:05, Carlos Romero <carlos9...@gmail.com> wrote:

Dear Prof. Bierlaire,

I am estimating a seat choice model with panel data (5 observations per individual) and I am dealing with introducing the agent effect in the utility functions. My model has a large set of alternatives (>20) and all their attributes are included in the utility function. I want to introduce the agent effect by means of an error component distributed only across individuals (and not alternatives).

I looked into the panel data examples on the biogeme website (e.g. 13panelNormalized.py)


I recently realized that this example is incorrect. Indeed, the error term must not be normalized for panel data. The correct file is 12panel.py.

and I realized the utility functions always have one different error component for each alternative.


Yes, that’s how it should be. It is like alternative specific constants.

But I would like only to include a individual error term, not an alternative-based one.


This does not capture anything meaningful. 

Should it be correct to introduce a single error component N(0,sigma) for all the alternatives but one to address the agent effect? My code (Betas, V’s and AV’s defined as usual, not copied below) is as follows:

database = db.Database('Panel', Panel)
database.panel("respondentId")
globals().update(database.variables)

# Error component
SIGMA = Beta('SIGMA',1.0,None, None, 0)
ERRORCOMP = SIGMA * bioDraws('ERRORCOMP', ‘NORMAL_ANTI’)

# Utility functions (just written the first 4)
V1 = B1 * X1_1 + B2 * X2_1 + B3 * X3_1
V2 = B1 * X1_2 + B2 * X2_2 + B3 * X3_2 + ERRORCOMP
V3 = B1 * X1_3 + B2 * X2_3 + B3 * X3_3 + ERRORCOMP
V4 = B1 * X1_4 + B2 * X2_4 + B3 * X3_4 + ERRORCOMP

#Likelihood and model estimation (as usual)
obsprob = models.logit(V, av, seatChoice)
condprobIndiv = PanelLikelihoodTrajectory(obsprob)
logprob = log(MonteCarlo(condprobIndiv))
biogeme = bio.BIOGEME(database, logprob, numberOfDraws=num_draws)
 

Best regards,

Carlos


--
You received this message because you are subscribed to the Google Groups "Biogeme" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biogeme+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/biogeme/f6529f8c-242a-4a27-894e-2eabde467697n%40googlegroups.com.

Carlos Romero

unread,
Nov 11, 2021, 8:50:21 AM11/11/21
to Biogeme

Dear Prof. Bierlaire

Thank you for your quick reply. I am now looking for a more efficient (i.e. less computer time consuming) approach to account for panel effect in my model, since otherwise I would have to include more than 20 error components N(0,sigma). My question now is: Would I correctly address the panel effects on individuals if I only use random parameters (random betas) for an appropriate number of variables (as for example eq. (1) in Cherchi, Cirillo & Ortuzar, 2017)? Or should I anyway include an error component for each alternative even if I am adding random parameters?

Therefore, if I am right, this would be my code (based on the accurate 12panel.py but without including the alternative specific constant because I am not expecting any meaningful hidden preference for alternative j over alternative j+1):  


database = db.Database('Panel', Panel)
database.panel("respondentId")
globals().update(database.variables)

# Random Parameters
B1 = Beta('B1', 0,None, None, 0)
B1_S = Beta('B1_S',1.0,None, None, 0)
B1_RND = B1 + B1_S * bioDraws(‘B1_RND’, ‘NORMAL_ANTI’)

B2 = Beta('B2', 0,None, None, 0)
B2_S = Beta('B2_S',1.0,None, None, 0)
B2_RND = B2 + B2_S * bioDraws(‘B2_RND’, ‘NORMAL_ANTI’)

# Fixed parameter
B3 = Beta('B3', 0,None, None, 0)

# Utility functions (just written the first 4)
V1 = B1_RND * X1_1 + B2_RND * X2_1 + B3 * X3_1
V2 = B1_RND * X1_2 + B2_RND * X2_2 + B3 * X3_2
V3 = B1_RND * X1_3 + B2_RND * X2_3 + B3 * X3_3
V4 = B1_RND * X1_4 + B2_RND * X2_4 + B3 * X3_4

#Likelihood and model estimation (as usual)
obsprob = models.logit(V, av, seatChoice)
condprobIndiv = PanelLikelihoodTrajectory(obsprob)
logprob = log(MonteCarlo(condprobIndiv))
biogeme = bio.BIOGEME(database, logprob, numberOfDraws=num_draws)

 

Best regards,

Carlos

Bierlaire Michel

unread,
Nov 11, 2021, 8:54:01 AM11/11/21
to carlos9...@gmail.com, Bierlaire Michel, Biogeme
If you don’t include an agent effect, the assumption that the epsilon’s are independent across time is wrong, as there are persistent components in the error term. 
The consequence is that the estimators are not efficient anymore, and you lose a significant amount of precision. 
The advice is to investigate the model specification without the agent effects, in order to save estimation time. Once you are happy with the specification, run the estimation with the agent effects on a server with many processors in order to obtain the final estimates.

Reply all
Reply to author
Forward
0 new messages