dimanche 29 janvier 2017

how to estimate the value of time with random parameter using mixed logit model in R

I would like to know more specifically how to estimate the value of time with random parameter using mixed logit model.

First, I have created a data set as below.

enter image description here

The estimattion of the fixed parameter using the mlogit is as attached below, and using this result, the value of travel time per hour turned out to be 90.95$.

Referring the result above, I followed the next three steps suggested in “Kenneth Train's exercises using the mlogit package for R(2012)" for mixed logit model.

  1. I assumed lognormal distribution, for both time and cost are negative for all people.
  2. Therefore, I put negative sign for both time and cost to use lognormal distribution.
  3. I estimated the random paramter with mlogit.

As the fixed parameter above, I would like to know which of the method below is the right way to calculate value of time using the estimated random parameter.

  1. Calculating with 'exp(Estimate parameter' or 'median of the random coefficients' for the estimated parameter has lognormal distribution; exp(-2.09959)/exp(-2.37945)*60=0.12250719/0.09260118*60=79.37$/h

  2. Calculating with 'mean of of the random coefficients'; 00.1533085/0.1967394*60 = 46.75$/h

Thank you very much, and I look forward hearing from you.

> ############### loading data ###############
> library(mlogit)
> data<-read.table("c:/1/data.txt", header=T)
> data_fixed<-mlogit.data(data, choice="choice", shape="long", alt.levels=c("highway","freeway"))
> 
> 
> ############### fixed parameter logit ###############
> 
> summary(fixed<-mlogit(choice ~  cost + time, data_fixed))

Call:
mlogit(formula = choice ~ cost + time, data = data_fixed, method = "nr", 
print.level = 0)

Frequencies of alternatives:
highway freeway 
0.47887 0.52113 

nr method
5 iterations, 0h:0m:0s 
g'(-H)^-1g = 2.1E-06 
successive function values within tolerance limits 

Coefficients :
                     Estimate Std. Error t-value  Pr(>|t|)    
freeway:(intercept) -0.516425   0.220266 -2.3446   0.01905 *  
cost                -0.077591   0.045392 -1.7093   0.08739 .  
time                -0.117620   0.017278 -6.8074 9.936e-12 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Log-Likelihood: -211.29
McFadden R^2:  0.14022 
Likelihood ratio test : chisq = 68.918 (p.value = 1.0832e-15)
> -0.117620/-0.077591*60
[1] 90.95385


> ############### MIXED LOGIT ###############
> ############### loading  opposited data ###############
> data_random<-mlogit.data(data, choice="choice", shape="long", alt.levels=c("highway","freeway"), 
+                          opposite=c('time','cost'))
> 
> ############### random parameter logit ###############
> summary(random<-mlogit(choice ~  cost + time, data_random,rpar=c(cost='ln', time='ln'), 
+                        R=500, halton = NA))

Call:
mlogit(formula = choice ~ cost + time, data = data_random, rpar = c(cost = "ln", 
time = "ln"), R = 500, halton = NA)

Frequencies of alternatives:
highway freeway 
0.47887 0.52113 

bfgs method
4 iterations, 0h:0m:10s 
g'(-H)^-1g =  0.99 
last step couldn't find higher value 

Coefficients :
                    Estimate Std. Error t-value  Pr(>|t|)    
freeway:(intercept) -0.55373    0.32828 -1.6867  0.091652 .  
cost                -2.37945    0.86705 -2.7443  0.006064 ** 
time                -2.09959    0.28893 -7.2667 3.684e-13 ***
sd.cost             -1.22766    1.75183 -0.7008  0.483435    
sd.time              0.66975    0.49450  1.3544  0.175611    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Log-Likelihood: -209.78
McFadden R^2:  0.14637 
Likelihood ratio test : chisq = 71.94 (p.value = 8.835e-15)

random coefficients
     Min.    1st Qu.     Median      Mean   3rd Qu. Max.
cost    0 0.04045766 0.09260118 0.1967394 0.2119495  Inf
time    0 0.07797829 0.12250719 0.1533085 0.1924640  Inf
> exp(-2.09959)/exp(-2.37945)*60
[1] 79.37668
> 0.12250719/0.09260118*60
[1] 79.3773
> 0.1533085/0.1967394*60
[1] 46.75479




Aucun commentaire:

Enregistrer un commentaire