Page 1 of 1

Conditionals from WTP space mixed logit perfectly correlated across individuals

Posted: 20 Apr 2022, 17:17
by bartoszbartk
Hi,

I estimated a mixed logit in WTP space for four normally distributed ES attributes and a lognormally distributed price attribute. Here's the output of the model:

Code: Select all

Estimation method                : bfgs
Model diagnosis                  : successful convergence 
Number of individuals            : 1481
Number of rows in database       : 13329
Number of modelled outcomes      : 13329

Number of cores used             :  3 
Number of inter-individual draws : 1000 (sobol)

LL(start)                        : -21189.34
LL(0)                            : -14643.4
LL(C)                            : -13293.59
LL(final)                        : -9075.805
Rho-square (0)                   :  0.3802 
Adj.Rho-square (0)               :  0.3794 
AIC                              :  18175.61 
BIC                              :  18265.58 


Estimated parameters             :  12
Time taken (hh:mm:ss)            :  00:41:48.97 
     pre-estimation              :  00:05:46.44 
     estimation                  :  00:22:51.68 
     post-estimation             :  00:13:10.85 
Iterations                       :  79  
Min abs eigenvalue of Hessian    :  37.39719 

Estimates:
                     Estimate        s.e.   t.rat.(0)  p(1-sided)    Rob.s.e. Rob.t.rat.(0)  p(1-sided)
asc_1                 0.00000          NA          NA          NA          NA            NA          NA
asc_2                 0.01991     0.02567      0.7759      0.2189     0.02922        0.6815    0.247775
asc_3                -2.58419     0.09175    -28.1651      0.0000     0.11845      -21.8160    0.000000
mu_b_drought         -0.64173     0.09266     -6.9254   2.174e-12     0.12688       -5.0578   2.120e-07
mu_b_flood           -0.58441     0.09985     -5.8529   2.416e-09     0.13888       -4.2081   1.288e-05
mu_b_climate         -0.74696     0.06022    -12.4045      0.0000     0.06668      -11.2024    0.000000
mu_b_water           -2.16371     0.07843    -27.5866      0.0000     0.11316      -19.1216    0.000000
mu_log_b_price       -4.02942     0.04899    -82.2573      0.0000     0.05402      -74.5904    0.000000
sigma_b_drought       0.55974     0.14421      3.8815   5.191e-05     0.20398        2.7440    0.003034
sigma_b_flood         0.50849     0.12936      3.9309   4.232e-05     0.15677        3.2436  5.9009e-04
sigma_b_climate       0.93712     0.08362     11.2075      0.0000     0.09213       10.1722    0.000000
sigma_b_water         2.87686     0.11856     24.2659      0.0000     0.16507       17.4284    0.000000
sigma_log_b_price     1.40620     0.06173     22.7806      0.0000     0.06884       20.4284    0.000000
I then calculated conditional WTPs for all individuals. However, they are perfectly correlated across individuals, i.e. if individual 1 has a higher WTP for drought than individual 2, she also "automatically" has a higher WTP for flood, climate and water. This obviously doesn't make sense, but I don't see where I may have made a mistake. So, it'd be great if someone has an idea where/what it may be...

Here's the relevant(?) part of the code:

Code: Select all

apollo_draws = list(
  interDrawsType = "sobol",
  interNDraws = 1000,
  interNormDraws = c("draws_price_inter","draws_ES_inter")
)

apollo_randCoeff = function(apollo_beta,apollo_inputs){
  randcoeff = list()
  randcoeff[["b_drought"]] = mu_b_drought + sigma_b_drought * draws_ES_inter
  randcoeff[["b_flood"]] = mu_b_flood + sigma_b_flood * draws_ES_inter
  randcoeff[["b_climate"]] = mu_b_climate + sigma_b_climate * draws_ES_inter
  randcoeff[["b_water"]] = mu_b_water + sigma_b_water * draws_ES_inter
  randcoeff[["b_price"]] = -exp(mu_log_b_price + sigma_log_b_price * draws_price_inter)
  return(randcoeff)
}

apollo_inputs <- apollo_validateInputs()

apollo_probabilities = function(apollo_beta,apollo_inputs,functionality="estimate"){
  apollo_attach(apollo_beta,apollo_inputs)
  on.exit(apollo_detach(apollo_beta,apollo_inputs))
  P = list()
  V = list()
  V[['alt1']] = asc_1 + b_price * (b_drought * drought.1 + b_flood * flood.1 + b_climate * climate.1 + b_water * water.1 + price.1)
  V[['alt2']] = asc_2 + b_price * (b_drought * drought.2 + b_flood * flood.2 + b_climate * climate.2 + b_water * water.2 + price.2)
  V[['alt3']] = asc_3 + b_price * (b_drought * drought.3 + b_flood * flood.3 + b_climate * climate.3 + b_water * water.3 + price.3)
  mnl_settings = list(
    alternatives = c(alt1=1,alt2=2,alt3=3),
    choiceVar = choice,
    V = V
  ) 
  P[["model"]] = apollo_mnl(mnl_settings,functionality)
  P = apollo_panelProd(P,apollo_inputs,functionality)
  P = apollo_avgInterDraws(P,apollo_inputs,functionality)
  P = apollo_prepareProb(P,apollo_inputs,functionality)
  return(P)
}

mxl_wtp <- apollo_estimate(apollo_beta,apollo_fixed,apollo_probabilities,apollo_inputs)

apollo_modelOutput(mxl_wtp,
                   modelOutput_settings=list(printPVal=1))

conditionals <- apollo_conditionals(mxl_wtp,apollo_probabilities,apollo_inputs)
Best,
Bartosz

Re: Conditionals from WTP space mixed logit perfectly correlated across individuals

Posted: 21 Apr 2022, 10:20
by stephanehess
Bartosz

could you please provide the output for the post-processing part too, including a summary of the conditionals?

Thanks

Stephane

Re: Conditionals from WTP space mixed logit perfectly correlated across individuals

Posted: 21 Apr 2022, 10:58
by bartoszbartk
Hi Stephane,

thanks for the quick response. Here are the summaries of the conditionals:

Code: Select all

> summary(conditionals[["b_drought"]])
       ID           post.mean          post.sd       
 Min.   :   1.0   Min.   :-1.7831   Min.   :0.04655  
 1st Qu.: 375.0   1st Qu.:-0.9891   1st Qu.:0.24811  
 Median : 750.0   Median :-0.6229   Median :0.34211  
 Mean   : 750.3   Mean   :-0.6335   Mean   :0.32663  
 3rd Qu.:1124.0   3rd Qu.:-0.3317   3rd Qu.:0.41559  
 Max.   :1500.0   Max.   : 0.4152   Max.   :0.70105  
> summary(conditionals[["b_flood"]])
       ID           post.mean          post.sd       
 Min.   :   1.0   Min.   :-1.6212   Min.   :0.04229  
 1st Qu.: 375.0   1st Qu.:-0.9000   1st Qu.:0.22540  
 Median : 750.0   Median :-0.5673   Median :0.31079  
 Mean   : 750.3   Mean   :-0.5770   Mean   :0.29673  
 3rd Qu.:1124.0   3rd Qu.:-0.3027   3rd Qu.:0.37754  
 Max.   :1500.0   Max.   : 0.3758   Max.   :0.63687  
> summary(conditionals[["b_climate"]])
       ID           post.mean          post.sd       
 Min.   :   1.0   Min.   :-2.6578   Min.   :0.07794  
 1st Qu.: 375.0   1st Qu.:-1.3285   1st Qu.:0.41539  
 Median : 750.0   Median :-0.7154   Median :0.57276  
 Mean   : 750.3   Mean   :-0.7332   Mean   :0.54685  
 3rd Qu.:1124.0   3rd Qu.:-0.2278   3rd Qu.:0.69578  
 Max.   :1500.0   Max.   : 1.0226   Max.   :1.17370  
> summary(conditionals[["b_water"]])
       ID           post.mean          post.sd      
 Min.   :   1.0   Min.   :-8.0297   Min.   :0.2393  
 1st Qu.: 375.0   1st Qu.:-3.9490   1st Qu.:1.2752  
 Median : 750.0   Median :-2.0670   Median :1.7583  
 Mean   : 750.3   Mean   :-2.1215   Mean   :1.6788  
 3rd Qu.:1124.0   3rd Qu.:-0.5701   3rd Qu.:2.1360  
 Max.   :1500.0   Max.   : 3.2687   Max.   :3.6032  
> summary(conditionals[["b_price"]])
       ID           post.mean            post.sd        
 Min.   :   1.0   Min.   :-0.442621   Min.   :0.001671  
 1st Qu.: 375.0   1st Qu.:-0.075396   1st Qu.:0.006485  
 Median : 750.0   Median :-0.023745   Median :0.016856  
 Mean   : 750.3   Mean   :-0.047164   Mean   :0.053051  
 3rd Qu.:1124.0   3rd Qu.:-0.009375   3rd Qu.:0.076987  
 Max.   :1500.0   Max.   :-0.002312   Max.   :0.622292 
Is this sufficient or do you need something else?

Best,
Bartosz

Re: Conditionals from WTP space mixed logit perfectly correlated across individuals

Posted: 21 Apr 2022, 16:21
by stephanehess
I need to correlation matrix too

Re: Conditionals from WTP space mixed logit perfectly correlated across individuals

Posted: 26 Apr 2022, 14:20
by bartoszbartk
Hi! I am not sure that I sent my response last Thursday. Just in case I haven't, here's the correlation matrix of the mixed logit model:

Code: Select all

Classical correlation matrix:
                              asc_2             asc_3      mu_b_drought        mu_b_flood
asc_2                      1.000000          0.126005          0.005341        -7.292e-05
asc_3                      0.126005          1.000000         -0.164257         -0.253828
mu_b_drought               0.005341         -0.164257          1.000000          0.039354
mu_b_flood               -7.292e-05         -0.253828          0.039354          1.000000
mu_b_climate               0.031717         -0.153644          0.054097          0.005162
mu_b_water                -0.022015          0.025060          0.067795         -0.041714
mu_log_b_price             0.061910         -0.042201          0.020068         -0.041579
sigma_b_drought           -0.001850         -0.009101         -0.637231         -0.030843
sigma_b_flood              0.020309         -0.072966        7.3449e-04         -0.337305
sigma_b_climate           -0.017004          0.034703         -0.102213         -0.182499
sigma_b_water              0.010104          0.140248         -0.146235         -0.136997
sigma_log_b_price         -0.068678          0.166842         -0.069378         -0.165119
                       mu_b_climate        mu_b_water    mu_log_b_price   sigma_b_drought
asc_2                      0.031717          -0.02202           0.06191         -0.001850
asc_3                     -0.153644           0.02506          -0.04220         -0.009101
mu_b_drought               0.054097           0.06779           0.02007         -0.637231
mu_b_flood                 0.005162          -0.04171          -0.04158         -0.030843
mu_b_climate               1.000000           0.34790           0.04923         -0.137656
mu_b_water                 0.347901           1.00000           0.21963         -0.078048
mu_log_b_price             0.049233           0.21963           1.00000         -0.062936
sigma_b_drought           -0.137656          -0.07805          -0.06294          1.000000
sigma_b_flood             -0.148395          -0.05649          -0.02969         -0.085633
sigma_b_climate           -0.540120          -0.37312          -0.10915         -0.065454
sigma_b_water             -0.420246          -0.84059          -0.19548          0.101569
sigma_log_b_price         -0.034075          -0.06799          -0.05870         -0.110510
                      sigma_b_flood   sigma_b_climate     sigma_b_water sigma_log_b_price
asc_2                       0.02031          -0.01700           0.01010          -0.06868
asc_3                      -0.07297           0.03470           0.14025           0.16684
mu_b_drought             7.3449e-04          -0.10221          -0.14624          -0.06938
mu_b_flood                 -0.33731          -0.18250          -0.13700          -0.16512
mu_b_climate               -0.14839          -0.54012          -0.42025          -0.03408
mu_b_water                 -0.05649          -0.37312          -0.84059          -0.06799
mu_log_b_price             -0.02969          -0.10915          -0.19548          -0.05870
sigma_b_drought            -0.08563          -0.06545           0.10157          -0.11051
sigma_b_flood               1.00000          -0.02552          -0.04210          -0.06642
sigma_b_climate            -0.02552           1.00000           0.37675          -0.06089
sigma_b_water              -0.04210           0.37675           1.00000           0.10263
sigma_log_b_price          -0.06642          -0.06089           0.10263           1.00000

Robust correlation matrix:
                              asc_2             asc_3      mu_b_drought        mu_b_flood
asc_2                      1.000000           0.18102           0.01186          -0.01659
asc_3                      0.181025           1.00000          -0.24459          -0.39452
mu_b_drought               0.011863          -0.24459           1.00000           0.34691
mu_b_flood                -0.016590          -0.39452           0.34691           1.00000
mu_b_climate              -0.010516          -0.22516           0.26104           0.22337
mu_b_water                -0.050733          -0.01598          -0.05386          -0.13378
mu_log_b_price             0.021196          -0.04968           0.04820          -0.08879
sigma_b_drought           -0.020835           0.10603          -0.82400          -0.25026
sigma_b_flood              0.002560          -0.02096          -0.22030          -0.31229
sigma_b_climate            0.017949           0.21009          -0.22204          -0.37054
sigma_b_water              0.052807           0.19126          -0.03099          -0.09214
sigma_log_b_price          0.004919           0.17585          -0.03329          -0.29094
                       mu_b_climate        mu_b_water    mu_log_b_price   sigma_b_drought
asc_2                      -0.01052         -0.050733           0.02120          -0.02083
asc_3                      -0.22516         -0.015982          -0.04968           0.10603
mu_b_drought                0.26104         -0.053860           0.04820          -0.82400
mu_b_flood                  0.22337         -0.133775          -0.08879          -0.25026
mu_b_climate                1.00000          0.365899           0.20836          -0.26213
mu_b_water                  0.36590          1.000000           0.43720           0.08964
mu_log_b_price              0.20836          0.437202           1.00000          -0.08398
sigma_b_drought            -0.26213          0.089636          -0.08398           1.00000
sigma_b_flood              -0.33954          0.035310          -0.03850           0.15627
sigma_b_climate            -0.65118         -0.459851          -0.27852           0.06900
sigma_b_water              -0.46131         -0.906822          -0.37067          -0.03100
sigma_log_b_price          -0.06355         -0.002345          -0.02408          -0.17614
                      sigma_b_flood   sigma_b_climate     sigma_b_water sigma_log_b_price
asc_2                      0.002560           0.01795           0.05281          0.004919
asc_3                     -0.020955           0.21009           0.19126          0.175848
mu_b_drought              -0.220303          -0.22204          -0.03099         -0.033288
mu_b_flood                -0.312289          -0.37054          -0.09214         -0.290935
mu_b_climate              -0.339537          -0.65118          -0.46131         -0.063547
mu_b_water                 0.035310          -0.45985          -0.90682         -0.002345
mu_log_b_price            -0.038505          -0.27852          -0.37067         -0.024075
sigma_b_drought            0.156265           0.06900          -0.03100         -0.176140
sigma_b_flood              1.000000           0.15641          -0.12854         -0.089356
sigma_b_climate            0.156413           1.00000           0.48226         -0.025908
sigma_b_water             -0.128543           0.48226           1.00000          0.143636
sigma_log_b_price         -0.089356          -0.02591           0.14364          1.000000
Best,
Bartosz

Re: Conditionals from WTP space mixed logit perfectly correlated across individuals

Posted: 26 Apr 2022, 23:24
by stephanehess
Hi

no, I mean the correlation between the conditionals, and in fact the variance-covariance matrix

Stephane

Re: Conditionals from WTP space mixed logit perfectly correlated across individuals

Posted: 27 Apr 2022, 07:14
by bartoszbartk
Hi Stephane,

sorry, here they come:

Correlation matrix:

Code: Select all

          drought.m flood.m climate.m water.m
drought.m         1       1         1       1
flood.m           1       1         1       1
climate.m         1       1         1       1
water.m           1       1         1       1
Variance-covariance matrix:

Code: Select all

          drought.m   flood.m climate.m   water.m
drought.m 0.1959491 0.1780087 0.3280592 1.0071095
flood.m   0.1780087 0.1617108 0.2980232 0.9149019
climate.m 0.3280592 0.2980232 0.5492388 1.6861090
water.m   1.0071095 0.9149019 1.6861090 5.1761885
Best,
Bartosz

Re: Conditionals from WTP space mixed logit perfectly correlated across individuals

Posted: 27 Apr 2022, 19:55
by stephanehess
Bartosz

I had a look back at your code, and the issue is quite clear. You are using the same draws for all your non-price coefficients, so of course, they will be perfectly correlated

Stephane

Re: Conditionals from WTP space mixed logit perfectly correlated across individuals

Posted: 02 May 2022, 14:30
by bartoszbartk
Thanks for spotting this! I reran the models after correcting this mistake, all seems to be fine!
Best,
Bartosz