[Limdep Nlogit List] Run Models by Factor or Group Level

William Greene wgreene at stern.nyu.edu
Wed Apr 11 06:58:56 AEST 2018


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
> <https://protect-au.mimecast.com/s/M55xC2xZYvCWvvEOtny8Ol?domain=people.stern.nyu.edu
> 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


More information about the Limdep mailing list