[Limdep Nlogit List] RPL/ML McFadden/Train specification test
Iain Pardoe
ipardoe at lcbmail.uoregon.edu
Sat Jan 20 06:49:14 EST 2007
I thought I'd share some simple code for computing the McFadden/Train
specification test (J. App. Econometrics, 2000) to determine if mixing
is needed for a multinomial logit model:
read;file="C:\Documents and Settings\ipardoe\My
Documents\limdep\misc\mt.txt";
nobs=27924;nvar=27;names=id,price,range,acc,speed,poll,size,big,lugg,cos
t,stav,
suv,spo,wag,tru,van,ev,comev,colev,cng,meth,colmet,nous1,ch,noev,nocng,n
ous2$
create ; rang1 = range/100
; acc1 = acc/10
; spee1 = speed/100
; size1 = size/10
; cost1 = cost/10 $
NLOGIT ; Lhs = ch
; Choices = A1,A2,B1,B2,C1,C2
; Rhs = price,rang1,acc1,spee1,poll,size1,big,lugg,cost1,stav,
suv,spo,wag,tru,van,ev,comev,colev,cng,meth,colmet
; Prob = prmnl $
calc ; list
; loglr = logl
; kr = kreg $
namelist ; z = price,rang1,acc1,spee1,poll,size1,big,lugg,cost1,stav $
matrix ; wmeans = Gsum(z,prmnl,id) $ ? limit 10 vars in matrix with this
many groups
create ; zpric = .5*(price-wmeans(id,1))^2
; zrang = .5*(rang1-wmeans(id,2))^2
; zacc = .5*(acc1-wmeans(id,3))^2
; zspee = .5*(spee1-wmeans(id,4))^2
; zpoll = .5*(poll-wmeans(id,5))^2
; zsize = .5*(size1-wmeans(id,6))^2
; zbig = .5*(big-wmeans(id,7))^2
; zlugg = .5*(lugg-wmeans(id,8))^2
; zcost = .5*(cost1-wmeans(id,9))^2
; zstav = .5*(stav-wmeans(id,10))^2 $
namelist ; z = ev,cng $
matrix ; wmeans = Gsum(z,prmnl,id) $
create ; zev = .5*(ev-wmeans(id,1))^2
; zcng = .5*(cng-wmeans(id,2))^2 $
NLOGIT ; Lhs = ch
; Choices = A1,A2,B1,B2,C1,C2
; Rhs = price,rang1,acc1,spee1,poll,size1,big,lugg,cost1,stav,
suv,spo,wag,tru,van,ev,comev,colev,cng,meth,colmet,
zpric,zrang,zacc,zspee,zpoll,zsize,zbig,zlugg,zcost,zstav,zev,zcng $
calc ; list
; loglu = logl
; ku = kreg
; lrtest = 2*(loglu-loglr)
; df = ku - kr
; pvalue = 1 - Chi(lrtest,df) $
This replicates the results in table 3 of the McFadden/Train paper
(although not exactly for some reason). The data are available from the
J. App. Econometrics data archive. There's probably a cleaner way of
calculating the artificial z-variables using matrices but I'm still
pretty new to limdep so this is the best I can do just now ...
Best wishes, Iain
Iain Pardoe <ipardoe at lcbmail.uoregon.edu>
Assistant Professor of Decision Sciences
Charles H. Lundquist College of Business
1208 University of Oregon
Eugene, OR 97403-1208, USA
Ph: 541-346-3250, Fax: 541-346-3341
http://lcb1.uoregon.edu/ipardoe
More information about the Limdep
mailing list