Dear all,
I am new to the forum and after finding the d-efficient design for my unlabelled experiment (two alternatives: 1 & 2), and collecting pilot data, I am now preparing for the choice modelling.
The five attributes & corresponding levels are the following:
Years of life (yol): 0.5, 1, 3
Quality of life gains (qol): 20, 40, 60
Experience (exp): Poor(0), Fair(1), Good(2)
Size (size): 50, 5000, 10000
Equity (equ): 25, 50, 75
Apart from interactions with socio-demographics, I want to add interactions between two of the continuous attributes yol & qol. I am trying the following in R, but it is not working:
### Vector of parameters, including any that are kept fixed in estimation
apollo_beta=c(asc = 0,
byol = 0,
bqol = 0,
bexp_fair = 0,
bexp_good = 0,
bsize = 0,
bequ = 0,
bage = 0,
byol_female = 0
)
apollo_fixed = c()
# ################################################################# #
#### GROUP AND VALIDATE INPUTS ####
# ################################################################# #
apollo_inputs = apollo_validateInputs()
# ################################################################# #
#### DEFINE MODEL AND LIKELIHOOD FUNCTION ####
# ################################################################# #
apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){
### Function initialisation: do not change the following three commands
### Attach inputs and detach after function exit
apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))
### Create list of probabilities P
P = list()
### Create coefficients with interactions
b_years = byol + byol_female * (female==1)
b_yolqol1 = bqol + byol*yol1
b_yolqol2 = bqol + byol*yol2
### List of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[["Alt1"]] = asc + b_years*yol1 + b_yolqol1*qol1 + bexp_fair*(exp1==1) + bexp_good*(exp1==2) + bsize*size1 + bequ*equ1 + bage*age
V[["Alt2"]] = b_years*yol2 + b_yolqol2*qol2 + bexp_fair*(exp2==1) + bexp_good*(exp2==2) + bsize*size2 + bequ*equ2
OR should I simply add directly to the interactions between attributes to the utility functions (this one is working, but I want to confirm whether this is okay):
### Vector of parameters, including any that are kept fixed in estimation
apollo_beta=c(asc = 0,
byol = 0,
bqol = 0,
bqy = 0,
bexp_fair = 0,
bexp_good = 0,
bsize = 0,
bequ = 0,
bage = 0,
byol_female = 0
)
### Create coefficients with interactions (only with socio-demographics):
b_years = byol + byol_female * (female==1)
### List of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[["Alt1"]] = asc + b_years*yol1 + bqol*qol1 + bqy*((qol1)*yol1) + bexp_fair*(exp1==1) + bexp_good*(exp1==2) + bsize*size1 + bequ*equ1 + bage*age
V[["Alt2"]] = b_ years*yol2 + bqol*qol2 + bqy*((qol2)*yol2) + bexp_fair*(exp2==1) + bexp_good*(exp2==2) + bsize*size2 + bequ*equ2
I would appreciate very much your help with this. Thanks!
Best wishes,
Pamela.
Important: Read this before posting to this forum
- 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.
- 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
- Before asking a question on the forum, users are kindly requested to follow these steps:
- Check that the same issue has not already been addressed in the forum - there is a search tool.
- 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
- Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
- Make sure that R is using the latest official release of Apollo.
- Users can check which version they are running by entering packageVersion("apollo").
- Then check what is the latest full release (not development version) at http://www.ApolloChoiceModelling.com/code.html.
- To update to the latest official version, just enter install.packages("apollo"). To update to a development version, download the appropriate binary file from http://www.ApolloChoiceModelling.com/code.html, and install the package from file
- If the above steps do not resolve the issue, then users should follow these steps when posting a question:
- provide full details on the issue, including the entire code and output, including any error messages
- 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.
Unlabelled experiment & interactions between attributes
-
- Site Admin
- Posts: 998
- Joined: 24 Apr 2020, 16:29
Re: Unlabelled experiment & interactions between attributes
Pamela
can you explain exactly what is happening when you say "it is not working"?
Stephane
can you explain exactly what is happening when you say "it is not working"?
Stephane
Re: Unlabelled experiment & interactions between attributes
Hi Stephane,
Thanks for your response.
I run it again and the model is actually working well.
The results are virtually the same, except for the value of the coefficient “bage” (although this is a synthetic variable).
When including interactions between attributes, should I use the first approach (i.e. defining the interactions before defining the utility functions) or the second one (i.e. defining the interaction within the utility function directly), or both are the same?
Many thanks!
Best wishes,
Pamela.
Thanks for your response.
I run it again and the model is actually working well.
The results are virtually the same, except for the value of the coefficient “bage” (although this is a synthetic variable).
When including interactions between attributes, should I use the first approach (i.e. defining the interactions before defining the utility functions) or the second one (i.e. defining the interaction within the utility function directly), or both are the same?
Many thanks!
Best wishes,
Pamela.
-
- Site Admin
- Posts: 998
- Joined: 24 Apr 2020, 16:29
Re: Unlabelled experiment & interactions between attributes
The two approaches should give the same results, so use whichever you find easier
Re: Unlabelled experiment & interactions between attributes
Thanks, Stephane!
Best wishes,
Pamela.
Best wishes,
Pamela.