Mc Fadden R square in MLOGIT
Posted: Wed May 22, 2013 2:48 am
Hello,
I am running a multinomial logit regression model with the following program:
------------------------------------------
' declare parameter vector (2 for 2 equations of starting values)
coef(9) b2
coef(9) b3
' set up the likelihood function by issuing a series of append statements
logl mlogit
mlogit.append @logl logl1
mlogit.append xb2 = b2(1)+b2(2)*x1+b2(3)*x2+b2(4)*x3+b2(5)*x4+b2(6)*x5+b2(7)*x6+b2(8)*x7+b2(9)*x8
mlogit.append xb3 = b3(1)+b3(2)*x1+b3(3)*x2+b3(4)*x3+b3(5)*x4+b3(6)*x5+b3(7)*x6+b3(8)*x7+b3(9)*x8
' define prob for each choice
mlogit.append denom = 1+exp(xb2)+exp(xb3)
mlogit.append pr1 = 1/denom
mlogit.append pr2 = exp(xb2)/denom
mlogit.append pr3 = exp(xb3)/denom
' specify likelihood
mlogit.append logl1 = (1-dd2-dd3)*log(pr1)+dd2*log(pr2)+dd3*log(pr3)
' specify analytic derivatives (Generally, Eviews estimate numerical derivatives)
for !i=2 to 3
mlogit.append @deriv b{!i}(1) grad{!i}1 b{!i}(2) grad{!i}2 b{!i}(3) grad{!i}3 b{!i}(4) grad{!i}4 b{!i}(5) grad{!i}5 b{!i}(6) grad{!i}6 b{!i}(7) grad{!i}7 b{!i}(8) grad{!i}8 b{!i}(9) grad{!i}9
mlogit.append grad{!i}1 = dd{!i}-pr{!i}
mlogit.append grad{!i}2 = grad{!i}1*x1
mlogit.append grad{!i}3 = grad{!i}1*x2
mlogit.append grad{!i}4 = grad{!i}1*x3
mlogit.append grad{!i}5 = grad{!i}1*x4
mlogit.append grad{!i}6 = grad{!i}1*x5
mlogit.append grad{!i}7 = grad{!i}1*x6
mlogit.append grad{!i}8 = grad{!i}1*x7
mlogit.append grad{!i}9 = grad{!i}1*x8
next
' get starting values from binomial logit (one choice for starting values for the coefficients of the mean equation)
equation eq2.binary(d=l) dd2 c x1 x2 x3 x4 x5 x6 x7 x8
b2 = eq2.@coefs
equation eq3.binary(d=l) dd3 c x1 x2 x3 x4 x5 x6 x7 x8
b3 = eq3.@coefs
' check whether you have specified the analytic derivatives correctly (fairly close to the numeric derivatives)
freeze(tab1) mlogit.checkderiv
show tab1
' estimate the model
mlogit.ml(showopts,m=1000,c=1e-5)
show mlogit.output
------------------------------------------
I know that in the binary model, the Mc Fadden R square is already provided in the regression output. I would like to know if it is possible to use it in this model as well and how can I add that in this program?
Thank You
G
I am running a multinomial logit regression model with the following program:
------------------------------------------
' declare parameter vector (2 for 2 equations of starting values)
coef(9) b2
coef(9) b3
' set up the likelihood function by issuing a series of append statements
logl mlogit
mlogit.append @logl logl1
mlogit.append xb2 = b2(1)+b2(2)*x1+b2(3)*x2+b2(4)*x3+b2(5)*x4+b2(6)*x5+b2(7)*x6+b2(8)*x7+b2(9)*x8
mlogit.append xb3 = b3(1)+b3(2)*x1+b3(3)*x2+b3(4)*x3+b3(5)*x4+b3(6)*x5+b3(7)*x6+b3(8)*x7+b3(9)*x8
' define prob for each choice
mlogit.append denom = 1+exp(xb2)+exp(xb3)
mlogit.append pr1 = 1/denom
mlogit.append pr2 = exp(xb2)/denom
mlogit.append pr3 = exp(xb3)/denom
' specify likelihood
mlogit.append logl1 = (1-dd2-dd3)*log(pr1)+dd2*log(pr2)+dd3*log(pr3)
' specify analytic derivatives (Generally, Eviews estimate numerical derivatives)
for !i=2 to 3
mlogit.append @deriv b{!i}(1) grad{!i}1 b{!i}(2) grad{!i}2 b{!i}(3) grad{!i}3 b{!i}(4) grad{!i}4 b{!i}(5) grad{!i}5 b{!i}(6) grad{!i}6 b{!i}(7) grad{!i}7 b{!i}(8) grad{!i}8 b{!i}(9) grad{!i}9
mlogit.append grad{!i}1 = dd{!i}-pr{!i}
mlogit.append grad{!i}2 = grad{!i}1*x1
mlogit.append grad{!i}3 = grad{!i}1*x2
mlogit.append grad{!i}4 = grad{!i}1*x3
mlogit.append grad{!i}5 = grad{!i}1*x4
mlogit.append grad{!i}6 = grad{!i}1*x5
mlogit.append grad{!i}7 = grad{!i}1*x6
mlogit.append grad{!i}8 = grad{!i}1*x7
mlogit.append grad{!i}9 = grad{!i}1*x8
next
' get starting values from binomial logit (one choice for starting values for the coefficients of the mean equation)
equation eq2.binary(d=l) dd2 c x1 x2 x3 x4 x5 x6 x7 x8
b2 = eq2.@coefs
equation eq3.binary(d=l) dd3 c x1 x2 x3 x4 x5 x6 x7 x8
b3 = eq3.@coefs
' check whether you have specified the analytic derivatives correctly (fairly close to the numeric derivatives)
freeze(tab1) mlogit.checkderiv
show tab1
' estimate the model
mlogit.ml(showopts,m=1000,c=1e-5)
show mlogit.output
------------------------------------------
I know that in the binary model, the Mc Fadden R square is already provided in the regression output. I would like to know if it is possible to use it in this model as well and how can I add that in this program?
Thank You
G