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.

WTP-space estimates in latent class context

Ask questions about how to estimate models and how to change your settings for estimation.
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: WTP-space estimates in latent class context

Post by stephanehess »

Tim

so there is no general answer to your question, but the following approach is what I would do:

1. ALWAYS start with a MNL model in preference space, helping you to ensure your data works, etc.
2. Transition this to WTP space for MNL.
3. Use the results from point 2 as starting values for MMNL.

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Jane
Posts: 5
Joined: 02 Nov 2020, 04:24

Re: WTP-space estimates in latent class context

Post by Jane »

Hi there,

I am also having trouble getting my MNL and MMNL DCE model to converge reliably in WTP space. I have fed it different starting values and that didn't seem to help.

utility functions are:

V[['alt1']] = b_cos * (b_si*sib_2 + b_in*in_2 +
b_fen*fen_2 + b_dow*dow_2 + b_hom*hom_2 + b_res*res_2 + cos_2)

V[['alt2']] = b_cos * (b_si*si_3 + b_in*in_3 +
b_fen*fen_3 + b_dow*dow_3 + b_hom*hom_3 + b_res*res_3 + cos_3)

V[['alt3']] = b_stsquo

Here is one output:

Model run at : 2021-06-21 18:37:06
Estimation method : bfgs
Model diagnosis : successful convergence
Number of individuals : 227
Number of observations : 1362

Number of cores used : 1
Model without mixing

LL(start) : -1496.31
LL(0) : -1496.31
LL(final) : -1413.889
Rho-square (0) : 0.0551
Adj.Rho-square (0) : 0.0497
AIC : 2843.78
BIC : 2885.51


Estimated parameters : 8
Time taken (hh:mm:ss) : 00:00:8.71
pre-estimation : 00:00:3.37
estimation : 00:00:2.54
post-estimation : 00:00:2.8
Iterations : 62
Min abs eigenvalue of Hessian : 0.001468

Estimates:
Estimate s.e. t.rat.(0) p(2-sided) Rob.s.e. Rob.t.rat.(0) p(2-sided)
b_stsquo -0.040031 0.130917 -0.3058 0.7598 0.172126 -0.2326 0.816098
b_cos -0.007473 0.001057 -7.0671 1.582e-12 0.001344 -5.5598 2.701e-08
b_res -3.086183 0.544013 -5.6730 1.403e-08 0.702741 -4.3916 1.125e-05
b_si -15.875527 11.823559 -1.3427 0.1794 12.826177 -1.2377 0.215811
b_in -44.787487 12.312240 -3.6376 2.7515e-04 13.665344 -3.2775 0.001047
b_fen -106.724422 16.928645 -6.3044 2.894e-10 22.165280 -4.8149 1.472e-06
b_dow -99.567562 16.871151 -5.9016 3.599e-09 23.477542 -4.2410 2.226e-05
b_hom -87.519828 16.499282 -5.3045 1.130e-07 21.074208 -4.1529 3.282e-05




this model above gives me negative WTP coefficents... although in this run the absolute value of the coefficient could be acceptable, so I'm not sure why that is happening?

I got the output below when i fed the model starting values estimated as ratios from the comparable preference space version of the model.




Estimation method : bfgs
Model diagnosis : successful convergence
Number of individuals : 227
Number of observations : 1362

Number of cores used : 1
Model without mixing

LL(start) : -2522.606
LL(0) : -1496.31
LL(final) : -1439.121
Rho-square (0) : 0.0382
Adj.Rho-square (0) : 0.0329
AIC : 2894.24
BIC : 2935.97


Estimated parameters : 8
Time taken (hh:mm:ss) : 00:00:10.58
pre-estimation : 00:00:1.9
estimation : 00:00:6.32
post-estimation : 00:00:2.36
Iterations : 144
Min abs eigenvalue of Hessian : 4e-06

Estimates:
Estimate s.e. t.rat.(0) p(2-sided) Rob.s.e. Rob.t.rat.(0) p(2-sided)
b_stsquo -0.1581 0.1420 -1.1129 0.26575 0.2044 -0.7733 0.439343
b_cos 4.5736e-04 2.0901e-04 2.1882 0.02866 1.5939e-04 2.8695 0.004111
b_res 28.8314 14.6742 1.9648 0.04944 10.0767 2.8612 0.004220
b_si -173.4055 210.1909 -0.8250 0.40938 220.3143 -0.7871 0.431234
b_in 276.9957 220.0300 1.2589 0.20807 186.7849 1.4830 0.138083
b_fen 741.2362 366.9222 2.0201 0.04337 180.5926 4.1045 4.053e-05
b_dow 316.7679 258.9028 1.2235 0.22114 280.0205 1.1312 0.257958
b_hom 623.9091 316.1663 1.9734 0.04845 164.1782 3.8002 1.4458e-04

Changes in parameter estimates from starting values:
Initial Estimate Difference
b_stsquo 0.00000 -0.1581 -0.15808
b_cos -0.01000 4.5736e-04 0.01046
b_res 3.00000 28.8314 25.83145
b_simpboxhab 12.50000 -173.4055 -185.90552
b_insuboxhab 45.00000 276.9957 231.99574
b_fencecon 115.00000 741.2362 626.23623
b_downcon 100.00000 316.7679 216.76786
b_homecon 94.00000 623.9091 529.90906
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: WTP-space estimates in latent class context

Post by stephanehess »

Jane

could you please also report the model in preference space, and show us the full code?

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Jane
Posts: 5
Joined: 02 Nov 2020, 04:24

Re: WTP-space estimates in latent class context

Post by Jane »

Hi Stephane,

Here is the code in preference space for the base MNL. and the model output below that. I have calculated WTP from this model used these as starting values but that didn't seem to help. I have also tried starting with 0 and small negative starting value for cost. just to clarify, as far as the code goes, to get from preference space to WTP space in Apollo I do this by adjusting the specification of the Utilities?

### Initialise code
apollo_initialise()

### Set core controls
apollo_control = list(
modelName ="clogit_penguins",
indivID ="responseid")

### Vector of parameters, including any that are kept fixed in estimation
apollo_beta = c(b_stsquo = 0,
b_cos = 0,
b_res=0,
b_simpboxhab = 0,
b_insuboxhab = 0,
b_fencecon = 0,
b_downcon = 0,
b_homecon = 0 )

### Vector with names (in quotes) of parameters to be kept fixed at their starting value in apollo_beta, use apollo_beta_fixed = c() if none
apollo_fixed = c()

apollo_inputs = apollo_validateInputs()

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

### List of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[['alt1']] = b_simpboxhab*simpboxhab_2 + b_insuboxhab*insuboxhab_2 +
b_fencecon*fencecon_2 + b_downcon*downcon_2+ b_homecon*homecon_2 + b_res*res_2 + b_cos*cos_2

V[['alt2']] = b_simpboxhab*simpboxhab_3 + b_insuboxhab*insuboxhab_3 +
b_fencecon*fencecon_3 + b_downcon*downcon_3 + b_homecon*homecon_3 + b_res*res_3 + b_cos*cos_3

V[['alt3']] = b_stsquo

### Define settings for MNL model component
mnl_settings = list(
alternatives = c(alt1=1, alt2=2, alt3=3),
avail = list(alt1=1, alt2=1, alt3=1),
choiceVar = choice,
V = 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 ESTIMATION ####
model = apollo_estimate(apollo_beta, apollo_fixed,
apollo_probabilities, apollo_inputs,
estimate_settings=list(hessianRoutine="numDeriv"))


Estimation method : bfgs
Model diagnosis : successful convergence
Number of individuals : 227
Number of observations : 1362

Model without mixing

LL(start) : -1496.31
LL(0) : -1496.31
LL(final) : -1413.662
Rho-square (0) : 0.0552
Adj.Rho-square (0) : 0.0499
AIC : 2843.32
BIC : 2885.06


Estimated parameters : 8
Time taken (hh:mm:ss) : 00:00:3.25
pre-estimation : 00:00:0.78
estimation : 00:00:0.63
post-estimation : 00:00:1.84
Iterations : 14
Min abs eigenvalue of Hessian : 20.30897

Estimates:
Estimate s.e. t.rat.(0) p(2-sided) Rob.s.e. Rob.t.rat.(0) p(2-sided)
b_stsquo -0.031986 0.131313 -0.2436 0.8076 0.173705 -0.1841 0.8539
b_cos -0.007195 0.001091 -6.5952 4.248e-11 0.001437 -5.0072 5.524e-07
b_res 0.022627 0.003661 6.1802 6.402e-10 0.003646 6.2056 5.449e-10
b_simpboxhab 0.090657 0.090858 0.9978 0.3184 0.098289 0.9223 0.3563
b_insuboxhab 0.315192 0.090766 3.4726 5.1548e-04 0.093347 3.3766 7.3396e-04
b_fencecon 0.826850 0.127056 6.5078 7.627e-11 0.128532 6.4330 1.251e-10
b_downcon 0.728225 0.133670 5.4479 5.096e-08 0.143046 5.0908 3.565e-07
b_homecon 0.677990 0.120757 5.6145 1.971e-08 0.122593 5.5304 3.195e-08
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: WTP-space estimates in latent class context

Post by stephanehess »

Jane

the specification looks fine, and the preference space and WTP space model go to a very similar LL (-1413.662 vs -1413.889). However, it should really be the same. What version of Apollo are you using?

In relation to your question "this model above gives me negative WTP coefficents... although in this run the absolute value of the coefficient could be acceptable, so I'm not sure why that is happening?" the model is behaving exactly as it should, and the signs you are getting in WTP space are consistent with the same ones you would get in preference space as the ratio of partial derivatives

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