From djourdain at ait.asia Wed Apr 4 00:56:50 2018 From: djourdain at ait.asia (Damien Jourdain) Date: Tue, 3 Apr 2018 16:56:50 +0200 Subject: [Limdep Nlogit List] Simulating unconditional WTP Message-ID: <005401d3cb5c$00df99c0$029ecd40$@cirad.fr> Dear All, I ran the following RPL-EC model. It gives me reasonable results. ? ML-EC Model Sample; ALL$ Calc; Ran(12345)$ RPLOGIT ; Choices = 1,2,3 ; Lhs = CHOICE, CSET, ALT ; Model: U(1) = A1 + BE*BENEF + LA*LAB + CA*CASH +RI*RISK + FEL*FERTLO +FEH* FERTHI / U(2,3) = BE*BENEF + LA*LAB + CA*CASH +RI*RISK + FEL*FERTLO +FEH* FERTHI ; Fcn = BE(l), LA(n), CA(n), RI(n), FEH(n) ; Pds = 6 ; Pts = 20 ; Shuffled ; Correlation ; WTP = LA/BE, CA/BE, RI/BE, FEH/BE ; ECM = (2,3) ; Parameters ; Maxit = 300$ I have obtained the conditional WTP (using the WTP command) but in fact I would like to manipulate simulated un-conditional WTPs. As the coefficients are correlated, I understand that I have to use the Cholesky decomposition (provided in the model output) to be able to draw correlated random coefficients. I have two set of questions: First, can I use the WALD command to develop these simulations (I know this can be done with an MNL model, but I do not see any simple manner to use the B and VARB matrices obtained from the model for a RPL model. Second, as I assumed that I could not use WALD, I developed the following commands for simulating the first three random coefficients: SAMPLE; 1-1000$ create ; rna1 = rnn(0,1) ; rna2 = rnn(0,1) ; rna3 = rnn(0,1) ; rna4 = rnn(0,1) ; rna5 = rnn(0,1) ; rna6 = rnn(0,1) ; MUBEN = B(1) + B(8) * RNA1 ; MULAB = B(2) + B(13) * RNA2 + B(9) * RNA3 ; MUCAS = B(3) + B(14) * RNA4 + B(15) * RNA5 + B(10) * RNA6 $ (the coefficients are correct and correspond to the Cholesky matrix coefficients ) When checking the simulated coefficients, I can reproduce the coefficients mean and standard deviation, but they are not correlated as I had expected given that I used the Cholesky coefficients to reproduce these correlations I do not understand what I have done wrong? Any help is welcomed. Damien DSTAT; RHS = MUBEN, MULAB, MUCAS; out=2$ --------+------------------------------------------------------------------- -- | Standard Missing Variable| Mean Deviation Minimum Maximum Cases Values --------+------------------------------------------------------------------- -- MUBEN| -3.7348 .408152 -5.023775 -2.357132 1000 0 MULAB| -.02753 .028474 -.117069 .048933 1000 0 MUCAS| -.015962 .015583 -.064371 .035926 1000 0 --------+------------------------------------------------------------------- -- Descriptive Statistics for 3 variables DSTAT results are matrix LASTDSTA in current project. Correlations computed for 3 variables. --------+-------------------------- Cor.Mat.| MUBEN MULAB MUCAS --------+-------------------------- MUBEN| 1.00000 .04327 -.04466 MULAB| .04327 1.00000 -.01857 MUCAS| -.04466 -.01857 1.00000 I am really far off the model outputs --------+-------------------------------------------- Cor.Mat.| ONE LA CA RI FEH --------+-------------------------------------------- ONE| 1.00000 -.61706 -.83717 .07331 -.06425 LA| -.61706 1.00000 .23113 -.52217 -.23501 CA| -.83717 .23113 1.00000 .09078 -.16867 RI| .07331 -.52217 .09078 1.00000 .63762 FEH| -.06425 -.23501 -.16867 .63762 1.00000 Dr. Damien Jourdain Agricultural and Natural Resources Economist Visiting Assistant Professor Asian Institute of Technology / CIRAD G-EAU Natural Resource Management / Water Engineering and Management From wgreene at stern.nyu.edu Wed Apr 4 01:13:10 2018 From: wgreene at stern.nyu.edu (William Greene) Date: Tue, 3 Apr 2018 11:13:10 -0400 Subject: [Limdep Nlogit List] Simulating unconditional WTP In-Reply-To: <005401d3cb5c$00df99c0$029ecd40$@cirad.fr> References: <005401d3cb5c$00df99c0$029ecd40$@cirad.fr> Message-ID: Damien. The simulated coefficients are not correlated because you used independent random draws to create them. You should be using rna1 in the first one, rna1,rna2 in the second one and rna1,rna2,rna3 in the third one. /B, Greene On Tue, Apr 3, 2018 at 10:56 AM, Damien Jourdain wrote: > Dear All, > > > > I ran the following RPL-EC model. It gives me reasonable results. > > ? ML-EC Model > > Sample; ALL$ > > Calc; Ran(12345)$ > > RPLOGIT > > ; Choices = 1,2,3 > > ; Lhs = CHOICE, CSET, ALT > > ; Model: > > U(1) = A1 + BE*BENEF + LA*LAB + CA*CASH +RI*RISK + FEL*FERTLO +FEH* > FERTHI / > > U(2,3) = BE*BENEF + LA*LAB + CA*CASH +RI*RISK + FEL*FERTLO +FEH* > FERTHI > > ; Fcn = BE(l), LA(n), CA(n), RI(n), FEH(n) > > ; Pds = 6 > > ; Pts = 20 > > ; Shuffled > > ; Correlation > > ; WTP = LA/BE, CA/BE, RI/BE, FEH/BE > > ; ECM = (2,3) > > ; Parameters > > ; Maxit = 300$ > > > > > > I have obtained the conditional WTP (using the WTP command) but in fact I > would like to manipulate simulated un-conditional WTPs. As the coefficients > are correlated, I understand that I have to use the Cholesky decomposition > (provided in the model output) to be able to draw correlated random > coefficients. I have two set of questions: > > > > First, can I use the WALD command to develop these simulations (I know this > can be done with an MNL model, but I do not see any simple manner to use > the > B and VARB matrices obtained from the model for a RPL model. > > > > Second, as I assumed that I could not use WALD, I developed the following > commands for simulating the first three random coefficients: > > > > SAMPLE; 1-1000$ > > create > > ; rna1 = rnn(0,1) > > ; rna2 = rnn(0,1) > > ; rna3 = rnn(0,1) > > ; rna4 = rnn(0,1) > > ; rna5 = rnn(0,1) > > ; rna6 = rnn(0,1) > > ; MUBEN = B(1) + B(8) * RNA1 > > ; MULAB = B(2) + B(13) * RNA2 + B(9) * RNA3 > > ; MUCAS = B(3) + B(14) * RNA4 + B(15) * RNA5 + B(10) * RNA6 > > $ > > > > (the coefficients are correct and correspond to the Cholesky matrix > coefficients ) > > > > When checking the simulated coefficients, I can reproduce the coefficients > mean and standard deviation, but they are not correlated as I had expected > given that I used the Cholesky coefficients to reproduce these correlations > > > > I do not understand what I have done wrong? > > > > Any help is welcomed. > > > > > > > > Damien > > > > > > > > > > DSTAT; RHS = MUBEN, MULAB, MUCAS; out=2$ > > --------+--------------------------------------------------- > ---------------- > -- > > | Standard > Missing > > Variable| Mean Deviation Minimum Maximum Cases > Values > > --------+--------------------------------------------------- > ---------------- > -- > > MUBEN| -3.7348 .408152 -5.023775 -2.357132 1000 > 0 > > MULAB| -.02753 .028474 -.117069 .048933 1000 > 0 > > MUCAS| -.015962 .015583 -.064371 .035926 1000 > 0 > > --------+--------------------------------------------------- > ---------------- > -- > > > > Descriptive Statistics for 3 variables > > DSTAT results are matrix LASTDSTA in current project. > > > > Correlations computed for 3 variables. > > > > --------+-------------------------- > > Cor.Mat.| MUBEN MULAB MUCAS > > --------+-------------------------- > > MUBEN| 1.00000 .04327 -.04466 > > MULAB| .04327 1.00000 -.01857 > > MUCAS| -.04466 -.01857 1.00000 > > > > > > I am really far off the model outputs > > --------+-------------------------------------------- > > Cor.Mat.| ONE LA CA RI FEH > > --------+-------------------------------------------- > > ONE| 1.00000 -.61706 -.83717 .07331 -.06425 > > LA| -.61706 1.00000 .23113 -.52217 -.23501 > > CA| -.83717 .23113 1.00000 .09078 -.16867 > > RI| .07331 -.52217 .09078 1.00000 .63762 > > FEH| -.06425 -.23501 -.16867 .63762 1.00000 > > > > > > > > > > > > > > Dr. Damien Jourdain > > Agricultural and Natural Resources Economist > > Visiting Assistant Professor > > Asian Institute of Technology / CIRAD G-EAU > > Natural Resource Management / Water Engineering and Management > > _______________________________________________ > Limdep site list > Limdep at mailman.sydney.edu.au > http://limdep.itls.usyd.edu.au > > -- William Greene Department of Economics Stern School of Business, New York University 44 West 4 St., 7-90 New York, NY, 10012 URL: https://protect-au.mimecast.com/s/YjmXCD1jy9twjlkLTWn5pG?domain=people.stern.nyu.edu Email: wgreene at stern.nyu.edu Ph. +1.212.998.0876 Editor in Chief: Journal of Productivity Analysis Editor in Chief: Foundations and Trends in Econometrics Associate Editor: Economics Letters Associate Editor: Journal of Business and Economic Statistics Associate Editor: Journal of Choice Modeling From djourdain at ait.asia Wed Apr 4 01:46:09 2018 From: djourdain at ait.asia (Damien Jourdain) Date: Tue, 3 Apr 2018 17:46:09 +0200 Subject: [Limdep Nlogit List] Simulating unconditional WTP In-Reply-To: References: <005401d3cb5c$00df99c0$029ecd40$@cirad.fr> Message-ID: <006201d3cb62$e50219b0$af064d10$@cirad.fr> Dear Prof Greene, Thank you for your rapid spotting of my mistake! As a follow-up question, I noticed quite similar correlations when running DSTAT for the conditional and unconditional parameters. (see below) The simulation now works very well. However, I notice a large difference in terms of correlation for one attribute (LAB) between conditional and un-conditional parameters. Should I draw any conclusion from these large difference in correlation for this attribute (model specification, data?) Yours respectfully, Damien SAMPLE; 1-1000$ create ; rna1 = rnn(0,1) ; rna2 = rnn(0,1) ; rna3 = rnn(0,1) ; MUBEN = exp(B(1) + B(8) * RNA1) ?? This was a lognormal distribution ; MULAB = B(2) + B(13) * RNA1 + B(9) * RNA2 ; MUCAS = B(3) + B(14) * RNA1 + B(15) * RNA2 + B(10) * RNA3 $ I compared the following three correlation matrices The one obtained directly from the NLOGIT output, the one from simulated parameters, and the one from conditional parameters Correlation matrix (model output) --------+-------------------------------------------- Cor.Mat.| ONE LA CA RI FEH --------+-------------------------------------------- ONE| 1.00000 -.61706 -.83717 .07331 -.06425 LA| -.61706 1.00000 .23113 -.52217 -.23501 CA| -.83717 .23113 1.00000 .09078 -.16867 RI| .07331 -.52217 .09078 1.00000 .63762 FEH| -.06425 -.23501 -.16867 .63762 1.00000 Correlation matrix of the simulated conditional parameters --------+-------------------------------------------- Cor.Mat.| MUBEN MULAB MUCAS MURIS MUFEH --------+-------------------------------------------- MUBEN| 1.00000 -.59427 -.79918 .04706 -.07725 MULAB| -.59427 1.00000 .23176 -.51297 -.23958 MUCAS| -.79918 .23176 1.00000 .09940 -.18260 MURIS| .04706 -.51297 .09940 1.00000 .62600 MUFEH| -.07725 -.23958 -.18260 .62600 1.00000 Correlation matrix of the conditional parameters --------+-------------------------------------------- Cor.Mat.| BBEN BLAB BCAS BRIS BHI --------+-------------------------------------------- BBEN| 1.00000 -.57742 -.83278 .14806 -.07852 BLAB| -.57742 1.00000 .75064 .56024 .46689 BCAS| -.83278 .75064 1.00000 .08143 -.11306 BRIS| .14806 .56024 .08143 1.00000 .33236 BHI| -.07852 .46689 -.11306 .33236 1.00000 De : William Greene [mailto:wgreene at stern.nyu.edu] Envoy? : Tuesday, April 03, 2018 5:13 PM ? : Limdep and Nlogit Mailing List; djourdain at ait.asia Objet : Re: [Limdep Nlogit List] Simulating unconditional WTP Damien. The simulated coefficients are not correlated because you used independent random draws to create them. You should be using rna1 in the first one, rna1,rna2 in the second one and rna1,rna2,rna3 in the third one. /B, Greene On Tue, Apr 3, 2018 at 10:56 AM, Damien Jourdain wrote: Dear All, I ran the following RPL-EC model. It gives me reasonable results. ? ML-EC Model Sample; ALL$ Calc; Ran(12345)$ RPLOGIT ; Choices = 1,2,3 ; Lhs = CHOICE, CSET, ALT ; Model: U(1) = A1 + BE*BENEF + LA*LAB + CA*CASH +RI*RISK + FEL*FERTLO +FEH* FERTHI / U(2,3) = BE*BENEF + LA*LAB + CA*CASH +RI*RISK + FEL*FERTLO +FEH* FERTHI ; Fcn = BE(l), LA(n), CA(n), RI(n), FEH(n) ; Pds = 6 ; Pts = 20 ; Shuffled ; Correlation ; WTP = LA/BE, CA/BE, RI/BE, FEH/BE ; ECM = (2,3) ; Parameters ; Maxit = 300$ I have obtained the conditional WTP (using the WTP command) but in fact I would like to manipulate simulated un-conditional WTPs. As the coefficients are correlated, I understand that I have to use the Cholesky decomposition (provided in the model output) to be able to draw correlated random coefficients. I have two set of questions: First, can I use the WALD command to develop these simulations (I know this can be done with an MNL model, but I do not see any simple manner to use the B and VARB matrices obtained from the model for a RPL model. Second, as I assumed that I could not use WALD, I developed the following commands for simulating the first three random coefficients: SAMPLE; 1-1000$ create ; rna1 = rnn(0,1) ; rna2 = rnn(0,1) ; rna3 = rnn(0,1) ; rna4 = rnn(0,1) ; rna5 = rnn(0,1) ; rna6 = rnn(0,1) ; MUBEN = B(1) + B(8) * RNA1 ; MULAB = B(2) + B(13) * RNA2 + B(9) * RNA3 ; MUCAS = B(3) + B(14) * RNA4 + B(15) * RNA5 + B(10) * RNA6 $ (the coefficients are correct and correspond to the Cholesky matrix coefficients ) When checking the simulated coefficients, I can reproduce the coefficients mean and standard deviation, but they are not correlated as I had expected given that I used the Cholesky coefficients to reproduce these correlations I do not understand what I have done wrong? Any help is welcomed. Damien DSTAT; RHS = MUBEN, MULAB, MUCAS; out=2$ --------+------------------------------------------------------------------- -- | Standard Missing Variable| Mean Deviation Minimum Maximum Cases Values --------+------------------------------------------------------------------- -- MUBEN| -3.7348 .408152 -5.023775 -2.357132 1000 0 MULAB| -.02753 .028474 -.117069 .048933 1000 0 MUCAS| -.015962 .015583 -.064371 .035926 1000 0 --------+------------------------------------------------------------------- -- Descriptive Statistics for 3 variables DSTAT results are matrix LASTDSTA in current project. Correlations computed for 3 variables. --------+-------------------------- Cor.Mat.| MUBEN MULAB MUCAS --------+-------------------------- MUBEN| 1.00000 .04327 -.04466 MULAB| .04327 1.00000 -.01857 MUCAS| -.04466 -.01857 1.00000 I am really far off the model outputs --------+-------------------------------------------- Cor.Mat.| ONE LA CA RI FEH --------+-------------------------------------------- ONE| 1.00000 -.61706 -.83717 .07331 -.06425 LA| -.61706 1.00000 .23113 -.52217 -.23501 CA| -.83717 .23113 1.00000 .09078 -.16867 RI| .07331 -.52217 .09078 1.00000 .63762 FEH| -.06425 -.23501 -.16867 .63762 1.00000 Dr. Damien Jourdain Agricultural and Natural Resources Economist Visiting Assistant Professor Asian Institute of Technology / CIRAD G-EAU Natural Resource Management / Water Engineering and Management _______________________________________________ Limdep site list Limdep at mailman.sydney.edu.au http://limdep.itls.usyd.edu.au -- William Greene Department of Economics Stern School of Business, New York University 44 West 4 St., 7-90 New York, NY, 10012 URL: https://protect-au.mimecast.com/s/2KMRCmOxDQt81Yp1tGlv5M?domain=people.stern.nyu.edu Email: wgreene at stern.nyu.edu Ph. +1.212.998.0876 Editor in Chief: Journal of Productivity Analysis Editor in Chief: Foundations and Trends in Econometrics Associate Editor: Economics Letters Associate Editor: Journal of Business and Economic Statistics Associate Editor: Journal of Choice Modeling From richard.turner at imarketresearch.com Wed Apr 11 06:07:04 2018 From: richard.turner at imarketresearch.com (Richard Turner) Date: Tue, 10 Apr 2018 16:07:04 -0400 Subject: [Limdep Nlogit List] Run Models by Factor or Group Level Message-ID: Greetings, I have a factor/categorical variable with 52 levels. I would like to run a model by each level. Is this possible using "PROC/ENDPROC" in NLOGIT? After reading this documentation , it wasn't clear to me how to iterate over the levels of my factor (Additionally, my factor levels are not enumerated sequentially). I simplified my data so that my factor variable only had two levels: 1 and 2. I tried using the below code: CALC ; i=1$ PROC CALC ; List; i;i=i+1$ Sample;all$ REJECT; FACTOR_VAR#i$ DISCRETECHOICE ;LHS=CHO, CSET ;RHS= NALvl1, NALvl2, NALvl3, NALvl4, NALvl5, NALvl6, NALvl7, NALvl8, NALvl9, NALvl10, NALvl11, NALvl12, NALvl13, NALvl14, NALvl15$ Sample;all$ GO TO ; i <= 2 $ ENDPROC EXECUTE After running the code I get this output and only one model is estimated: [CALC] I = 1.0000000 [CALC] I = 2.0000000 Calculator: Computed 2 scalar results Error 29: REJECT:0 obs. in resulting sample. Current sample restored. Regards, _____________________________________________ Richard From wgreene at stern.nyu.edu Wed Apr 11 06:58:56 2018 From: wgreene at stern.nyu.edu (William Greene) Date: Tue, 10 Apr 2018 16:58:56 -0400 Subject: [Limdep Nlogit List] Run Models by Factor or Group Level In-Reply-To: References: Message-ID: Richard. You should be able to use the following. Proc$ DISCRETE ; If [ Factor = i ] ; Lhs = cho,cset ; Rhs = etc... $ EndProc $ Execute ; i = 1,52 $ Nonsequential doesn't matter. Do note that FACTOR_VAR is not a valid name - it has 10 characters. You'll want to be sure that the factor variable has a valid name in the proc. Either way, your loop is only set up to run once, so it ran correctly. Regards Bill Greene On Tue, Apr 10, 2018 at 4:07 PM, Richard Turner < richard.turner at imarketresearch.com> wrote: > Greetings, > > I have a factor/categorical variable with 52 levels. I would like to run a > model by each level. Is this possible using "PROC/ENDPROC" in NLOGIT? After > reading this documentation > Short-Student-Manual.pdf>, > it wasn't clear to me how to iterate over the levels of my factor > (Additionally, > my factor levels are not enumerated sequentially). > > I simplified my data so that my factor variable only had two levels: 1 and > 2. > > I tried using the below code: > CALC ; i=1$ > PROC > CALC ; List; i;i=i+1$ > Sample;all$ > REJECT; FACTOR_VAR#i$ > DISCRETECHOICE > ;LHS=CHO, CSET > ;RHS= > NALvl1, NALvl2, NALvl3, NALvl4, NALvl5, NALvl6, NALvl7, NALvl8, > NALvl9, NALvl10, NALvl11, NALvl12, NALvl13, NALvl14, NALvl15$ > Sample;all$ > GO TO ; i <= 2 $ > ENDPROC > EXECUTE > > After running the code I get this output and only one model is estimated: > [CALC] I = 1.0000000 > [CALC] I = 2.0000000 > Calculator: Computed 2 scalar results > Error 29: REJECT:0 obs. in resulting sample. Current sample restored. > > Regards, > _____________________________________________ > > Richard > _______________________________________________ > Limdep site list > Limdep at mailman.sydney.edu.au > http://limdep.itls.usyd.edu.au > > -- William Greene Department of Economics Stern School of Business, New York University 44 West 4 St., 7-90 New York, NY, 10012 URL: https://protect-au.mimecast.com/s/TuOBC3Q8Z2FowwR0Hqf0K2?domain=people.stern.nyu.edu Email: wgreene at stern.nyu.edu Ph. +1.212.998.0876 Editor in Chief: Journal of Productivity Analysis Editor in Chief: Foundations and Trends in Econometrics Associate Editor: Economics Letters Associate Editor: Journal of Business and Economic Statistics Associate Editor: Journal of Choice Modeling