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.

Effects coding MNL model and relative importance.

Ask questions about data format and processing of data, including the use of pre-estimation functions in Apollo. If your question relates to a specific error you are getting, please provide some of the output.
Post Reply
El2023
Posts: 1
Joined: 15 Jun 2023, 10:26

Effects coding MNL model and relative importance.

Post by El2023 »

Dear Apollo Choice Modelling forum,

Lately I have conducted a DCE with three attributes ("goede voorspelling", "onterecht ingrijpen", "onterecht geruststellen") with three attribute levels each that all consist of different percentages (Goede voorspelling: 90%, 70%, 50%(ref), Onterecht ingrijpen: 50%, 52%, 5%(ref), Onterecht geruststellen: 20%, 10%, 1% (ref)).

I want to estimate a simple MNL model using effects coding. I have chosen to use effects coding, because I prefer to also report a Beta-coefficient for the reference category (in dummy coding this is set to zero).

I have inserted an effects coding constraint in my R script. I have provided the code and output below. I have a few questions:
1. Am I doing this correctly?
2. In my model estimations, no Beta coefficient is provided for the reference category. It makes sense that I can calculate the Beta of the reference category using the coding constraint: ("b_Goede_voorspelling_50 = - b_Goede_voorspelling_70 - b_Goede_voorspelling_90"), is this correct?
3. How do I calculate the p-value for the Beta of the reference category? I would like to report this in the results of my paper.
4. I have now specified the attributes as categorical variables using effects coding. However, if the effect is linear, I could perhaps also insert them into the model as continuous variables. Is this a reasonable thought and how can I check linearity for each attribute?
3. To calculate the relative importance of each attribute, I calculated the distances between the lowest and highest attribute level coefficient for each attribute, added these distances for all attributes (total distance), and then calculated the percentage that the distance of each attribute contributed to the total distance. Is this an appropriate method? I found the method in this paper:(https://www.researchgate.net/publicatio ... Importance).

Thank you very much in advance for your help.

Kind regards,
Ellis


##############################################################################
apollo_control = list( modelName = "MNL_DCE_data",
modelDescr = "Simple MNL model on DCE choice data using effects coding",
indivID = "ID",
outputDirectory = "output")

apollo_beta=c(asc_choice1 = 0,
b_Goede_voorspelling_70 = 0,
b_Goede_voorspelling_90 = 0,
b_Onterecht_Ingrijpen_50 = 0,
b_Onterecht_Ingrijpen_25 = 0,
b_Onterecht_Geruststellen_20 = 0,
b_Onterecht_Geruststellen_10 = 0
)

apollo_fixed = c()
apollo_inputs = apollo_validateInputs()

apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){

### 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()

# effects coding constraint
b_Goede_voorspelling_50 = - b_Goede_voorspelling_70 - b_Goede_voorspelling_90
b_Onterecht_Ingrijpen_5 = - b_Onterecht_Ingrijpen_25 - b_Onterecht_Ingrijpen_50
b_Onterecht_Geruststellen_1 = - b_Onterecht_Geruststellen_10 - b_Onterecht_Geruststellen_20

### List of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[["choice1"]] = asc_choice1 + b_Goede_voorspelling_50 * (GV1 ==1) + b_Goede_voorspelling_70 * (GV1 ==2) + b_Goede_voorspelling_90 * (GV1 ==3) + b_Onterecht_Ingrijpen_50 * (OI1 ==1) + b_Onterecht_Ingrijpen_25 * (OI1 ==2) + b_Onterecht_Ingrijpen_5 * (OI1 ==3) + b_Onterecht_Geruststellen_20 * (OG1 ==1) + b_Onterecht_Geruststellen_10 * (OG1 ==2) + b_Onterecht_Geruststellen_1 * (OG1 ==3)

V[["choice2"]] = b_Goede_voorspelling_50 * (GV2 ==1) + b_Goede_voorspelling_70 * (GV2 ==2) + b_Goede_voorspelling_90 * (GV2 ==3) + b_Onterecht_Ingrijpen_50 * (OI2 ==1) + b_Onterecht_Ingrijpen_25 * (OI2 ==2) + b_Onterecht_Ingrijpen_5 * (OI2 ==3) + b_Onterecht_Geruststellen_20 * (OG2 ==1) + b_Onterecht_Geruststellen_10 * (OG2 ==2) + b_Onterecht_Geruststellen_1 * (OG2 ==3)

### Define settings for MNL model component
mnl_settings = list(
alternatives = c(choice1=1, choice2=2),
choiceVar = choice,
utilities = V
)

### Compute probabilities using MNL model
P[["model"]] = apollo_mnl(mnl_settings, functionality)

### Take product across observation for same individual
P = apollo_panelProd(P, apollo_inputs, functionality)

### Prepare and return outputs of function
P = apollo_prepareProb(P, apollo_inputs, functionality)
return(P)
}

model = apollo_estimate(apollo_beta, apollo_fixed,
apollo_probabilities, apollo_inputs)

summary(model)

MODEL OUPUT
estimate SE t-ratio p (1-sided)
asc_choice1 0.037 0.018 2.1 0.02 *
b_Goede_voorspelling_70 -0.023 0.019 -1.2 0.11
b_Goede_voorspelling_90 0.788 0.031 25.1 <2e-16 ***
b_Onterecht_Ingrijpen_50 -0.630 0.023 -27.4 <2e-16 ***
b_Onterecht_Ingrijpen_25 -0.012 0.021 -0.6 0.28
b_Onterecht_Geruststellen_20 -0.461 0.025 -18.3 <2e-16 ***
b_Onterecht_Geruststellen_10 0.044 0.024 1.8 0.04 *
stephanehess
Site Admin
Posts: 998
Joined: 24 Apr 2020, 16:29

Re: Effects coding MNL model and relative importance.

Post by stephanehess »

Ellis

your model specification is correct, as is the calculation of the beta for the reference level and the relative importance calculation (though I'm not a fan of this).

But it makes no sense to calculate p values for the reference category. Think about it this way. With categorical variables, the t-ratio for a level is a comparison against 0. So with dummy coding, that will tell you whether the utility for a given level is different from that for the base level (which has beta fixed to 0). With effects coding, this kind of calculation makes no sense at all.

Remember that only differences in utility matter, so you can use the delta method to calculate p-values for the differences between individual levels

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply