Important: Read this before posting to this forum

  1. 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.
  2. 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
  3. Before asking a question on the forum, users are kindly requested to follow these steps:
    1. Check that the same issue has not already been addressed in the forum - there is a search tool.
    2. 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
    3. Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
    4. Make sure that R is using the latest official release of Apollo.
  4. If the above steps do not resolve the issue, then users should follow these steps when posting a question:
    1. provide full details on the issue, including the entire code and output, including any error messages
    2. 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

Ask questions about model specifications. Ideally include a mathematical explanation of your proposed model.
Post Reply
psalazar
Posts: 13
Joined: 22 Sep 2022, 13:56

Unlabelled experiment & interactions between attributes

Post by psalazar »

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.
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: Unlabelled experiment & interactions between attributes

Post by stephanehess »

Pamela

can you explain exactly what is happening when you say "it is not working"?

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
psalazar
Posts: 13
Joined: 22 Sep 2022, 13:56

Re: Unlabelled experiment & interactions between attributes

Post by psalazar »

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.
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: Unlabelled experiment & interactions between attributes

Post by stephanehess »

The two approaches should give the same results, so use whichever you find easier
--------------------------------
Stephane Hess
www.stephanehess.me.uk
psalazar
Posts: 13
Joined: 22 Sep 2022, 13:56

Re: Unlabelled experiment & interactions between attributes

Post by psalazar »

Thanks, Stephane!

Best wishes,

Pamela.
Post Reply