How can I intergate Linear regression into latent variable model (full information estimation)?

108 views
Skip to first unread message

LIXU LI

unread,
Apr 1, 2021, 12:11:00 PM4/1/21
to Biogeme
Dear Prof. Bierlaire,
I want to use Choice model with the latent variable. Maximum likelihood (full information) estimation. I find some examples in BIOGEME, but that example (05latentChoiceFull.py) is based on Ordered probit (i.e. 02oneLatentOrdered.pyMeasurement equation where the indicators are discrete.).
However, my measurement equation is continuous (i.e., 01oneLatentRegression.py). How can I adjust my syntax? I don't know how to express the distributions of the indicators and the latent variables in the Joint likelihood function.
Belows are some of my code:

### Latent variable: structural equation 
# Define a random parameter, normally distributed, designed to be used for numerical integration
omega = RandomVariable('omega')
density = dist.normalpdf(omega)
sigma_s1 = Beta('sigma_s1', 1, None, None, 0)

# EA is a Latent variable
EA = coef_intercept_EA +\
     coef_Gender_EA * Gender +\
     coef_Age_EA * Age +\
     sigma_s1 * omega

### Measurement equations
INTER_EA01 = Beta('INTER_EA01', 0, None, None, 1)
INTER_EA03 = Beta('INTER_EA03', 0, None, None, 0)
B_EA01_F1 = Beta('B_EA01_F1', 1, None, None, 1)
B_EA03_F1 = Beta('B_EA03_F1', 1, None, None, 0)
MODEL_EA01 = INTER_EA01 + B_EA01_F1 * EA
MODEL_EA03 = INTER_EA03 + B_EA03_F1 * EA
SIGMA_STAR_EA01 = Beta('SIGMA_STAR_EA01', 1, 0, None, 0)
SIGMA_STAR_EA03 = Beta('SIGMA_STAR_EA03', 1, 0, None, 0)

### This syntax is from 01oneLatentRegression.py, do I need to adjust it when using full information estimation? Or how can I write these syntax?
F = {}
F['EA01'] = Elem({0: 0,
                     1: ll.loglikelihoodregression(EA01,
                                                   MODEL_EA01,
                                                   SIGMA_STAR_EA01)},
                    (EA01 > 0)*(EA01 < 6))
F['EA03'] = Elem({0: 0,
                     1: ll.loglikelihoodregression(EA03,
                                                   MODEL_EA03,
                                                   SIGMA_STAR_EA03)},
                    (EA03 > 0)*(EA03 < 6))

###  Choice model
ASC_BEV = Beta('ASC_BEV', choiceBetas['ASC_BEV'], None, None, 0)
ASC_CFV = Beta('ASC_CFV', choiceBetas['ASC_CFV'], None, None, 0)
ASC_NONE = Beta('ASC_NONE', 0, None, None, 1)
BETA_EA_BEV = Beta('BETA_EA_BEV', choiceBetas['BETA_EA_BEV'], None, None, 0)
BETA_EA_CFV = Beta('BETA_EA_CFV', choiceBetas['BETA_EA_CFV'], None, None, 0)
### Definition of utility functions:
V0 = ASC_BEV + \
     BETA_EA_BEV * EA
V1 = ASC_CFV + \
     BETA_EA_CEV * EA
V2 = ASC_NONE
# Associate utility functions with the numbering of alternatives
V = {0: V0,
     1: V1,
     2: V2}
# Conditional to omega, a logit model (called the kernel) for the choice
condprob = models.logit(V, None, Choice)

# Conditional to omega,  the product (distributions) of the indicators and the latent variables. I don't know how to write the syntax in this step in the case of linear regression? In 01oneLatentRegression.py, it is: loglike = bioMultSum(F). 

### After the above step, the following step should be
loglike = log(Integrate(condlike * density, 'omega')) 
logger = msg.bioMessage() 
logger.setGeneral() 
biogeme = bio.BIOGEME(database, loglike) 
biogeme.modelName = 'XXXXl' 
results = biogeme.estimate()

Thank you very much for your help. I am looking forward to your reply, thank you!

Bierlaire Michel

unread,
Apr 1, 2021, 1:09:25 PM4/1/21
to lixu...@gmail.com, Bierlaire Michel, Biogeme
If the inditator I is defined by a linear regression, you have
I = sum_k beta_k x_k + sigma * eps, which is normally distributed with mean sum_k beta_k x_k and variance sigma^2.
If phi is the standard normal pdf, the pdf of I is 

Phi((I - sum_k beta_k x_k) / sigma)  / sigma.  

This is the contribution to the likelihood.


--
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/2bc0bf6f-0f94-4260-93c1-44febb1e3a1cn%40googlegroups.com.

LIXU LI

unread,
Apr 2, 2021, 4:10:57 AM4/2/21
to Biogeme
Thank you for your repley, Prof. Bierlaire. But, I still don’t know how to write my  syntax for condlike in my case when indicators are  linear regression . Could you provide some examples for me? (i.e.,  condlike = )

LIXU LI

unread,
Apr 2, 2021, 4:11:38 AM4/2/21
to Biogeme
I have 2 latent variables defined by linear regression,  normally distributed. 1 latent variable has 2 indicators, and the other one has 3 indicators.  How can I expree the pdf that contributes to the likelihood?

在2021年4月2日星期五 UTC+8 上午1:09:25<michel.b...@epfl.ch> 写道:
Reply all
Reply to author
Forward
0 new messages