Page 1 of 1

Second order latent variable

Posted: 31 Aug 2020, 07:35
by anders
Dear Hess and Palma,

I was wondering whether it is possible to define and incorporate a second-order latent variable in a hybrid choice model using Apollo? So a latent variable which is defined by the combination of two first-order latent variables.

Thank you very much
Anders

Re: Second order latent variable

Posted: 07 Sep 2020, 11:01
by stephanehess
Hi Anders

yes, this can be done. The following rough code shows you how to do it:

apollo_randCoeff = function(apollo_beta, apollo_inputs){
randcoeff = list()

randcoeff[["LV1"]] = gamma_fem_LV1 * female + eta_LV1
randcoeff[["LV2"]] = gamma_employed_LV2 * employed + eta_LV2
randcoeff[["LV3"]] = gamma_LV1_LV3 * LV1 + gamma_LV2_LV3 * LV2

return(randcoeff)
}

Re: Second order latent variable

Posted: 30 Sep 2020, 14:18
by anders
Thank you very much, Stephane.

I guess you need to define all three latent variables in the utility function to get the model to run?
In general, I am only interested in incorporating LV3 in the utility function in your example for example through interaction terms, but then the model can't run because it can't find LV2 and LV1 when LV2 and LV2 are only defined in the step where I define the random components.

All the best
Anders

Re: Second order latent variable

Posted: 30 Sep 2020, 20:56
by stephanehess
Anders

your model will "run" even if only LV3 is used in the utility function, and the code will find LV1 and LV2. However, if LV1 and LV2 are only used inside LV3, then it's not clear why you would not just write a single LV. Or are LV1 and LV2 also used in the measurement components, in which case it is fine

Stephane